|
@@ -1,387 +1,27 @@
|
|
|
#pragma once
|
|
|
+#include "KeyboardListener.h"
|
|
|
#include "cbase.h"
|
|
|
|
|
|
-#define ELEMENT_BODY(T) \
|
|
|
- virtual T *setPos(float xPos, float yPos) { \
|
|
|
- if(m_vPos.x != xPos || m_vPos.y != yPos) { \
|
|
|
- m_vPos.x = xPos - m_vSize.x * m_vAnchor.x; \
|
|
|
- m_vPos.y = yPos - m_vSize.y * m_vAnchor.y; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPosX(float xPos) { \
|
|
|
- if(m_vPos.x != xPos) { \
|
|
|
- m_vPos.x = xPos - m_vSize.x * m_vAnchor.x; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPosY(float yPos) { \
|
|
|
- if(m_vPos.y != yPos) { \
|
|
|
- m_vPos.y = yPos - m_vSize.y * m_vAnchor.y; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPos(Vector2 position) { \
|
|
|
- if(m_vPos != position) { \
|
|
|
- m_vPos = position - m_vSize * m_vAnchor; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setPosAbsolute(float xPos, float yPos) { \
|
|
|
- if(m_vPos.x != xPos || m_vPos.y != yPos) { \
|
|
|
- m_vPos.x = xPos; \
|
|
|
- m_vPos.y = yPos; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPosAbsoluteX(float xPos) { \
|
|
|
- if(m_vPos.x != xPos) { \
|
|
|
- m_vPos.x = xPos; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPosAbsoluteY(float yPos) { \
|
|
|
- if(m_vPos.y != yPos) { \
|
|
|
- m_vPos.y = yPos; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPosAbsolute(Vector2 position) { \
|
|
|
- if(m_vPos != position) { \
|
|
|
- m_vPos = position; \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setScrollPos(float xPos, float yPos) { \
|
|
|
- if(m_vmPos.x != xPos || m_vmPos.y != yPos) { \
|
|
|
- m_vmPos.x = xPos - m_vSize.x * m_vAnchor.x; \
|
|
|
- m_vmPos.y = yPos - m_vSize.y * m_vAnchor.y; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPosX(float xPos) { \
|
|
|
- if(m_vmPos.x != xPos) { \
|
|
|
- m_vmPos.x = xPos - m_vSize.x * m_vAnchor.x; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPosY(float yPos) { \
|
|
|
- if(m_vmPos.y != yPos) { \
|
|
|
- m_vmPos.y = yPos - m_vSize.x * m_vAnchor.y; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPos(Vector2 position) { \
|
|
|
- if(m_vmPos != position) { \
|
|
|
- m_vmPos = position - m_vSize * m_vAnchor; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setScrollPosAbsolute(float xPos, float yPos) { \
|
|
|
- if(m_vmPos.x != xPos || m_vmPos.y != yPos) { \
|
|
|
- m_vmPos.x = xPos; \
|
|
|
- m_vmPos.y = yPos; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPosAbsoluteX(float xPos) { \
|
|
|
- if(m_vmPos.x != xPos) { \
|
|
|
- m_vmPos.x = xPos; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPosAbsoluteY(float yPos) { \
|
|
|
- if(m_vmPos.y != yPos) { \
|
|
|
- m_vmPos.y = yPos; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScrollPosAbsolute(Vector2 position) { \
|
|
|
- if(m_vmPos != position) { \
|
|
|
- m_vmPos = position; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setSize(float xSize, float ySize) { \
|
|
|
- if(m_vSize.x != xSize || m_vSize.y != ySize) { \
|
|
|
- m_vPos.x += (m_vSize.x - xSize) * m_vAnchor.x; \
|
|
|
- m_vPos.y += (m_vSize.y - ySize) * m_vAnchor.y; \
|
|
|
- m_vSize.x = xSize; \
|
|
|
- m_vSize.y = ySize; \
|
|
|
- onResized(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSizeX(float xSize) { \
|
|
|
- if(m_vSize.x != xSize) { \
|
|
|
- m_vPos.x += (m_vSize.x - xSize) * m_vAnchor.x; \
|
|
|
- m_vSize.x = xSize; \
|
|
|
- onResized(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSizeY(float ySize) { \
|
|
|
- if(m_vSize.y != ySize) { \
|
|
|
- m_vPos.y += (m_vSize.y - ySize) * m_vAnchor.y; \
|
|
|
- m_vSize.y = ySize; \
|
|
|
- onResized(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSize(Vector2 size) { \
|
|
|
- if(m_vSize != size) { \
|
|
|
- m_vPos += (m_vSize - size) * m_vAnchor; \
|
|
|
- m_vSize = size; \
|
|
|
- onResized(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setSizeAbsolute(float xSize, float ySize) { \
|
|
|
- if(m_vSize.x != xSize || m_vSize.y != ySize) { \
|
|
|
- m_vSize.x = xSize; \
|
|
|
- m_vSize.y = ySize; \
|
|
|
- onResized(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSizeAbsoluteX(float xSize) { \
|
|
|
- if(m_vSize.x != xSize) { \
|
|
|
- m_vSize.x = xSize; \
|
|
|
- onResized(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSizeAbsoluteY(float ySize) { \
|
|
|
- if(m_vSize.y != ySize) { \
|
|
|
- m_vSize.y = ySize; \
|
|
|
- onResized(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setSizeAbsolute(Vector2 size) { \
|
|
|
- if(m_vSize != size) { \
|
|
|
- m_vSize = size; \
|
|
|
- onResized(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setRelSize(float xSize, float ySize) { \
|
|
|
- if(m_vmSize.x != xSize || m_vmSize.y != ySize) { \
|
|
|
- m_vmPos.x += (m_vmSize.x - xSize) * m_vAnchor.x; \
|
|
|
- m_vmPos.y += (m_vmSize.y - ySize) * m_vAnchor.y; \
|
|
|
- m_vmSize.x = xSize; \
|
|
|
- m_vmSize.y = ySize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSizeX(float xSize) { \
|
|
|
- if(m_vmSize.x != xSize) { \
|
|
|
- m_vmPos.x += (m_vmSize.x - xSize) * m_vAnchor.x; \
|
|
|
- m_vmSize.x = xSize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSizeY(float ySize) { \
|
|
|
- if(m_vmSize.y != ySize) { \
|
|
|
- m_vmPos.y += (m_vmSize.y - ySize) * m_vAnchor.y; \
|
|
|
- m_vmSize.y = ySize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSize(Vector2 size) { \
|
|
|
- if(m_vmSize != size) { \
|
|
|
- m_vmPos += (m_vmSize - size) * m_vAnchor; \
|
|
|
- m_vmSize = size; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setRelSizeAbsolute(float xSize, float ySize) { \
|
|
|
- if(m_vmSize.x != xSize || m_vmSize.y != ySize) { \
|
|
|
- m_vmSize.x = xSize; \
|
|
|
- m_vmSize.y = ySize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSizeAbsoluteX(float xSize) { \
|
|
|
- if(m_vmSize.x != xSize) { \
|
|
|
- m_vmSize.x = xSize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSizeAbsoluteY(float ySize) { \
|
|
|
- if(m_vmSize.y != ySize) { \
|
|
|
- m_vmSize.y = ySize; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setRelSizeAbsolute(Vector2 size) { \
|
|
|
- if(m_vmSize != size) { \
|
|
|
- m_vmSize = size; \
|
|
|
- updateLayout(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setAnchor(float xAnchor, float yAnchor) { \
|
|
|
- if(m_vAnchor.x != xAnchor || m_vAnchor.y != yAnchor) { \
|
|
|
- m_vmPos.x -= m_vmSize.x * (xAnchor - m_vAnchor.x); \
|
|
|
- m_vmPos.y -= m_vmSize.y * (yAnchor - m_vAnchor.y); \
|
|
|
- m_vPos.x -= m_vSize.x * (xAnchor - m_vAnchor.x); \
|
|
|
- m_vPos.y -= m_vSize.y * (yAnchor - m_vAnchor.y); \
|
|
|
- m_vAnchor.x = xAnchor; \
|
|
|
- m_vAnchor.y = yAnchor; \
|
|
|
- if(m_parent != NULL) updateLayout(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchorX(float xAnchor) { \
|
|
|
- if(m_vAnchor.x != xAnchor) { \
|
|
|
- m_vmPos.x -= m_vmSize.x * (xAnchor - m_vAnchor.x); \
|
|
|
- m_vPos.x -= m_vSize.x * (xAnchor - m_vAnchor.x); \
|
|
|
- m_vAnchor.x = xAnchor; \
|
|
|
- if(m_parent != NULL) updateLayout(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchorY(float yAnchor) { \
|
|
|
- if(m_vAnchor.y != yAnchor) { \
|
|
|
- m_vmPos.y -= m_vmSize.y * (yAnchor - m_vAnchor.y); \
|
|
|
- m_vPos.y -= m_vSize.y * (yAnchor - m_vAnchor.y); \
|
|
|
- m_vAnchor.y = yAnchor; \
|
|
|
- if(m_parent != NULL) updateLayout(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchor(Vector2 anchor) { \
|
|
|
- if(m_vAnchor != anchor) { \
|
|
|
- m_vmPos -= m_vmSize * (anchor - m_vAnchor); \
|
|
|
- m_vPos -= m_vSize * (anchor - m_vAnchor); \
|
|
|
- m_vAnchor = anchor; \
|
|
|
- if(m_parent != NULL) updateLayout(); \
|
|
|
- onMoved(); \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setAnchorAbsolute(float xAnchor, float yAnchor) { \
|
|
|
- if(m_vAnchor.x != xAnchor || m_vAnchor.y != yAnchor) { \
|
|
|
- m_vAnchor.x = xAnchor, m_vAnchor.y = yAnchor; \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchorAbsoluteX(float xAnchor) { \
|
|
|
- if(m_vAnchor.x != xAnchor) { \
|
|
|
- m_vAnchor.x = xAnchor; \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchorAbsoluteY(float yAnchor) { \
|
|
|
- if(m_vAnchor.y != yAnchor) { \
|
|
|
- m_vAnchor.y = yAnchor; \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setAnchorAbsolute(Vector2 anchor) { \
|
|
|
- if(m_vAnchor != anchor) { \
|
|
|
- m_vAnchor = anchor; \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- \
|
|
|
- virtual T *setVisible(bool visible) { \
|
|
|
- m_bVisible = visible; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setActive(bool active) { \
|
|
|
- m_bActive = active; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setKeepActive(bool keepActive) { \
|
|
|
- m_bKeepActive = keepActive; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setDrawManually(bool drawManually) { \
|
|
|
- m_bDrawManually = drawManually; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setPositionManually(bool positionManually) { \
|
|
|
- m_bPositionManually = positionManually; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setEnabled(bool enabled) { \
|
|
|
- if(enabled != m_bEnabled) { \
|
|
|
- m_bEnabled = enabled; \
|
|
|
- if(m_bEnabled) { \
|
|
|
- onEnabled(); \
|
|
|
- } else { \
|
|
|
- onDisabled(); \
|
|
|
- } \
|
|
|
- } \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setBusy(bool busy) { \
|
|
|
- m_bBusy = busy; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setName(UString name) { \
|
|
|
- m_sName = name; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setParent(CBaseUIElement *parent) { \
|
|
|
- m_parent = parent; \
|
|
|
- return this; \
|
|
|
- } \
|
|
|
- virtual T *setScaleByHeightOnly(bool scaleByHeightOnly) { \
|
|
|
- m_bScaleByHeightOnly = scaleByHeightOnly; \
|
|
|
- return this; \
|
|
|
- }
|
|
|
-
|
|
|
-#include "KeyboardListener.h"
|
|
|
+// Guidelines for avoiding hair pulling:
|
|
|
+// - Don't use m_vmSize
|
|
|
+// - When an element is standalone, use getPos/setPos
|
|
|
+// - In a container or in a scrollview, use getRelPos/setRelPos and call update_pos() on the container
|
|
|
|
|
|
class CBaseUIElement : public KeyboardListener {
|
|
|
public:
|
|
|
- CBaseUIElement(float xPos = 0, float yPos = 0, float xSize = 0, float ySize = 0, UString name = "");
|
|
|
+ CBaseUIElement(float xPos = 0, float yPos = 0, float xSize = 0, float ySize = 0, UString name = "") {
|
|
|
+ m_vPos.x = xPos;
|
|
|
+ m_vPos.y = yPos;
|
|
|
+ m_vmPos.x = m_vPos.x;
|
|
|
+ m_vmPos.y = m_vPos.y;
|
|
|
+ m_vSize.x = xSize;
|
|
|
+ m_vSize.y = ySize;
|
|
|
+ m_vmSize.x = m_vSize.x;
|
|
|
+ m_vmSize.y = m_vSize.y;
|
|
|
+ m_sName = name;
|
|
|
+ }
|
|
|
virtual ~CBaseUIElement() { ; }
|
|
|
|
|
|
- ELEMENT_BODY(CBaseUIElement)
|
|
|
-
|
|
|
// main
|
|
|
virtual void draw(Graphics *g) = 0;
|
|
|
virtual void mouse_update(bool *propagate_clicks);
|
|
@@ -398,17 +38,110 @@ class CBaseUIElement : public KeyboardListener {
|
|
|
inline UString getName() const { return m_sName; }
|
|
|
inline const Vector2 &getRelPos() const { return m_vmPos; }
|
|
|
inline const Vector2 &getRelSize() const { return m_vmSize; }
|
|
|
- inline const Vector2 &getAnchor() const { return m_vAnchor; }
|
|
|
- inline CBaseUIElement *getParent() const { return m_parent; }
|
|
|
|
|
|
virtual bool isActive() { return m_bActive || isBusy(); }
|
|
|
virtual bool isVisible() { return m_bVisible; }
|
|
|
virtual bool isEnabled() { return m_bEnabled; }
|
|
|
virtual bool isBusy() { return m_bBusy && isVisible(); }
|
|
|
- virtual bool isDrawnManually() { return m_bDrawManually; }
|
|
|
- virtual bool isPositionedManually() { return m_bPositionManually; }
|
|
|
virtual bool isMouseInside() { return m_bMouseInside && isVisible(); }
|
|
|
- virtual bool isScaledByHeightOnly() { return m_bScaleByHeightOnly; }
|
|
|
+
|
|
|
+ virtual CBaseUIElement *setPos(float xPos, float yPos) {
|
|
|
+ if(m_vPos.x != xPos || m_vPos.y != yPos) {
|
|
|
+ m_vPos.x = xPos;
|
|
|
+ m_vPos.y = yPos;
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setPosX(float xPos) {
|
|
|
+ if(m_vPos.x != xPos) {
|
|
|
+ m_vPos.x = xPos;
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setPosY(float yPos) {
|
|
|
+ if(m_vPos.y != yPos) {
|
|
|
+ m_vPos.y = yPos;
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setPos(Vector2 position) { return setPos(position.x, position.y); }
|
|
|
+
|
|
|
+ virtual CBaseUIElement *setRelPos(float xPos, float yPos) {
|
|
|
+ m_vmPos.x = xPos;
|
|
|
+ m_vmPos.y = yPos;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setRelPosX(float xPos) {
|
|
|
+ m_vmPos.x = xPos;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setRelPosY(float yPos) {
|
|
|
+ m_vmPos.y = yPos;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setRelPos(Vector2 position) { return setRelPos(position.x, position.y); }
|
|
|
+
|
|
|
+ virtual CBaseUIElement *setSize(float xSize, float ySize) {
|
|
|
+ if(m_vSize.x != xSize || m_vSize.y != ySize) {
|
|
|
+ m_vSize.x = xSize;
|
|
|
+ m_vSize.y = ySize;
|
|
|
+ onResized();
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setSizeX(float xSize) {
|
|
|
+ if(m_vSize.x != xSize) {
|
|
|
+ m_vSize.x = xSize;
|
|
|
+ onResized();
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setSizeY(float ySize) {
|
|
|
+ if(m_vSize.y != ySize) {
|
|
|
+ m_vSize.y = ySize;
|
|
|
+ onResized();
|
|
|
+ onMoved();
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setSize(Vector2 size) { return setSize(size.x, size.y); }
|
|
|
+
|
|
|
+ virtual CBaseUIElement *setVisible(bool visible) {
|
|
|
+ m_bVisible = visible;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setActive(bool active) {
|
|
|
+ m_bActive = active;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setKeepActive(bool keepActive) {
|
|
|
+ m_bKeepActive = keepActive;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setEnabled(bool enabled) {
|
|
|
+ if(enabled != m_bEnabled) {
|
|
|
+ m_bEnabled = enabled;
|
|
|
+ if(m_bEnabled) {
|
|
|
+ onEnabled();
|
|
|
+ } else {
|
|
|
+ onDisabled();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setBusy(bool busy) {
|
|
|
+ m_bBusy = busy;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ virtual CBaseUIElement *setName(UString name) {
|
|
|
+ m_sName = name;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
|
|
|
// actions
|
|
|
void stealFocus() {
|
|
@@ -416,9 +149,6 @@ class CBaseUIElement : public KeyboardListener {
|
|
|
m_bActive = false;
|
|
|
onFocusStolen();
|
|
|
}
|
|
|
- void updateLayout() {
|
|
|
- if(m_parent != NULL) m_parent->updateLayout();
|
|
|
- }
|
|
|
|
|
|
protected:
|
|
|
// events
|
|
@@ -438,30 +168,23 @@ class CBaseUIElement : public KeyboardListener {
|
|
|
|
|
|
// vars
|
|
|
UString m_sName;
|
|
|
- CBaseUIElement *m_parent;
|
|
|
|
|
|
// attributes
|
|
|
- bool m_bVisible;
|
|
|
- bool m_bActive; // we are doing something, e.g. textbox is blinking and ready to receive input
|
|
|
- bool m_bBusy; // we demand the focus to be kept on us, e.g. click-drag scrolling in a scrollview
|
|
|
- bool m_bEnabled;
|
|
|
-
|
|
|
- bool m_bKeepActive; // once clicked, don't lose m_bActive, we have to manually release it (e.g. textbox)
|
|
|
- bool m_bDrawManually;
|
|
|
- bool m_bPositionManually;
|
|
|
- bool m_bMouseInside;
|
|
|
+ bool m_bVisible = true;
|
|
|
+ bool m_bActive = false; // we are doing something, e.g. textbox is blinking and ready to receive input
|
|
|
+ bool m_bBusy = false; // we demand the focus to be kept on us, e.g. click-drag scrolling in a scrollview
|
|
|
+ bool m_bEnabled = true;
|
|
|
|
|
|
- // container options
|
|
|
- bool m_bScaleByHeightOnly;
|
|
|
+ bool m_bKeepActive = false; // once clicked, don't lose m_bActive, we have to manually release it (e.g. textbox)
|
|
|
+ bool m_bMouseInside = false;
|
|
|
|
|
|
// position and size
|
|
|
Vector2 m_vPos;
|
|
|
Vector2 m_vmPos;
|
|
|
Vector2 m_vSize;
|
|
|
Vector2 m_vmSize;
|
|
|
- Vector2 m_vAnchor; // the point of transformation
|
|
|
|
|
|
private:
|
|
|
- bool m_bMouseInsideCheck;
|
|
|
- bool m_bMouseUpCheck;
|
|
|
+ bool m_bMouseInsideCheck = false;
|
|
|
+ bool m_bMouseUpCheck = false;
|
|
|
};
|