|
|
@@ -4,1172 +4,1203 @@
|
|
|
|
|
|
namespace gameplay
|
|
|
{
|
|
|
- Control::Control()
|
|
|
- : _id(""), _state(Control::NORMAL), _bounds(Rectangle::empty()), _clipBounds(Rectangle::empty()), _clip(Rectangle::empty()),
|
|
|
- _dirty(true), _consumeTouchEvents(true), _listeners(NULL), _styleOverridden(false)
|
|
|
- {
|
|
|
- }
|
|
|
|
|
|
- Control::Control(const Control& copy)
|
|
|
- {
|
|
|
- }
|
|
|
+Control::Control()
|
|
|
+ : _id(""), _state(Control::NORMAL), _bounds(Rectangle::empty()), _clipBounds(Rectangle::empty()), _viewportClipBounds(Rectangle::empty()),
|
|
|
+ _dirty(true), _consumeTouchEvents(true), _listeners(NULL), _styleOverridden(false)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+Control::Control(const Control& copy)
|
|
|
+{
|
|
|
+}
|
|
|
|
|
|
- Control::~Control()
|
|
|
+Control::~Control()
|
|
|
+{
|
|
|
+ if (_listeners)
|
|
|
{
|
|
|
- if (_listeners)
|
|
|
+ for (std::map<Listener::EventType, std::list<Listener*>*>::const_iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
|
|
|
{
|
|
|
- for (std::map<Listener::EventType, std::list<Listener*>*>::const_iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
|
|
|
- {
|
|
|
- std::list<Listener*>* list = itr->second;
|
|
|
- SAFE_DELETE(list);
|
|
|
- }
|
|
|
- SAFE_DELETE(_listeners);
|
|
|
+ std::list<Listener*>* list = itr->second;
|
|
|
+ SAFE_DELETE(list);
|
|
|
}
|
|
|
+ SAFE_DELETE(_listeners);
|
|
|
+ }
|
|
|
|
|
|
- if (_styleOverridden)
|
|
|
- {
|
|
|
- SAFE_DELETE(_style);
|
|
|
- }
|
|
|
+ if (_styleOverridden)
|
|
|
+ {
|
|
|
+ SAFE_DELETE(_style);
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+void Control::initialize(Theme::Style* style, Properties* properties)
|
|
|
+{
|
|
|
+ _style = style;
|
|
|
+
|
|
|
+ // Properties not defined by the style.
|
|
|
+ _alignment = getAlignment(properties->getString("alignment"));
|
|
|
+ _autoWidth = properties->getBool("autoWidth");
|
|
|
+ _autoHeight = properties->getBool("autoHeight");
|
|
|
|
|
|
- void Control::initialize(Theme::Style* style, Properties* properties)
|
|
|
+ Vector2 position;
|
|
|
+ Vector2 size;
|
|
|
+ if (properties->exists("position"))
|
|
|
+ {
|
|
|
+ properties->getVector2("position", &position);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ position.x = properties->getFloat("x");
|
|
|
+ position.y = properties->getFloat("y");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (properties->exists("size"))
|
|
|
+ {
|
|
|
+ properties->getVector2("size", &size);
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- _style = style;
|
|
|
+ size.x = properties->getFloat("width");
|
|
|
+ size.y = properties->getFloat("height");
|
|
|
+ }
|
|
|
+ _bounds.set(position.x, position.y, size.x, size.y);
|
|
|
|
|
|
- // Properties not defined by the style.
|
|
|
- _alignment = getAlignment(properties->getString("alignment"));
|
|
|
- _autoWidth = properties->getBool("autoWidth");
|
|
|
- _autoHeight = properties->getBool("autoHeight");
|
|
|
+ _state = Control::getState(properties->getString("state"));
|
|
|
|
|
|
- Vector2 position;
|
|
|
- Vector2 size;
|
|
|
- if (properties->exists("position"))
|
|
|
+ const char* id = properties->getId();
|
|
|
+ if (id)
|
|
|
+ _id = id;
|
|
|
+
|
|
|
+ // Potentially override themed properties for all states.
|
|
|
+ overrideThemedProperties(properties, STATE_ALL);
|
|
|
+
|
|
|
+ // Override themed properties on specific states.
|
|
|
+ Properties* innerSpace = properties->getNextNamespace();
|
|
|
+ while (innerSpace != NULL)
|
|
|
+ {
|
|
|
+ std::string spaceName(innerSpace->getNamespace());
|
|
|
+ std::transform(spaceName.begin(), spaceName.end(), spaceName.begin(), (int(*)(int))toupper);
|
|
|
+ if (spaceName == "STATENORMAL")
|
|
|
{
|
|
|
- properties->getVector2("position", &position);
|
|
|
+ overrideThemedProperties(innerSpace, NORMAL);
|
|
|
}
|
|
|
- else
|
|
|
+ else if (spaceName == "STATEFOCUS")
|
|
|
{
|
|
|
- position.x = properties->getFloat("x");
|
|
|
- position.y = properties->getFloat("y");
|
|
|
+ overrideThemedProperties(innerSpace, FOCUS);
|
|
|
}
|
|
|
-
|
|
|
- if (properties->exists("size"))
|
|
|
+ else if (spaceName == "STATEACTIVE")
|
|
|
{
|
|
|
- properties->getVector2("size", &size);
|
|
|
+ overrideThemedProperties(innerSpace, ACTIVE);
|
|
|
}
|
|
|
- else
|
|
|
+ else if (spaceName == "STATEDISABLED")
|
|
|
{
|
|
|
- size.x = properties->getFloat("width");
|
|
|
- size.y = properties->getFloat("height");
|
|
|
+ overrideThemedProperties(innerSpace, DISABLED);
|
|
|
}
|
|
|
- _bounds.set(position.x, position.y, size.x, size.y);
|
|
|
-
|
|
|
- _state = Control::getState(properties->getString("state"));
|
|
|
-
|
|
|
- const char* id = properties->getId();
|
|
|
- if (id)
|
|
|
- _id = id;
|
|
|
-
|
|
|
- // Potentially override themed properties for all states.
|
|
|
- overrideThemedProperties(properties, STATE_ALL);
|
|
|
-
|
|
|
- // Override themed properties on specific states.
|
|
|
- Properties* innerSpace = properties->getNextNamespace();
|
|
|
- while (innerSpace != NULL)
|
|
|
+ else if (spaceName == "MARGIN")
|
|
|
{
|
|
|
- std::string spaceName(innerSpace->getNamespace());
|
|
|
- std::transform(spaceName.begin(), spaceName.end(), spaceName.begin(), (int(*)(int))toupper);
|
|
|
- if (spaceName == "STATENORMAL")
|
|
|
- {
|
|
|
- overrideThemedProperties(innerSpace, NORMAL);
|
|
|
- }
|
|
|
- else if (spaceName == "STATEFOCUS")
|
|
|
- {
|
|
|
- overrideThemedProperties(innerSpace, FOCUS);
|
|
|
- }
|
|
|
- else if (spaceName == "STATEACTIVE")
|
|
|
- {
|
|
|
- overrideThemedProperties(innerSpace, ACTIVE);
|
|
|
- }
|
|
|
- else if (spaceName == "STATEDISABLED")
|
|
|
- {
|
|
|
- overrideThemedProperties(innerSpace, DISABLED);
|
|
|
- }
|
|
|
- else if (spaceName == "MARGIN")
|
|
|
- {
|
|
|
- setMargin(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
|
|
|
- innerSpace->getFloat("left"), innerSpace->getFloat("right"));
|
|
|
- }
|
|
|
- else if (spaceName == "PADDING")
|
|
|
- {
|
|
|
- setPadding(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
|
|
|
- innerSpace->getFloat("left"), innerSpace->getFloat("right"));
|
|
|
- }
|
|
|
-
|
|
|
- innerSpace = properties->getNextNamespace();
|
|
|
+ setMargin(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
|
|
|
+ innerSpace->getFloat("left"), innerSpace->getFloat("right"));
|
|
|
+ }
|
|
|
+ else if (spaceName == "PADDING")
|
|
|
+ {
|
|
|
+ setPadding(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
|
|
|
+ innerSpace->getFloat("left"), innerSpace->getFloat("right"));
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- const char* Control::getID() const
|
|
|
- {
|
|
|
- return _id.c_str();
|
|
|
+ innerSpace = properties->getNextNamespace();
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+const char* Control::getID() const
|
|
|
+{
|
|
|
+ return _id.c_str();
|
|
|
+}
|
|
|
|
|
|
- void Control::setPosition(float x, float y)
|
|
|
+void Control::setPosition(float x, float y)
|
|
|
+{
|
|
|
+ if (x != _bounds.x || y != _bounds.y)
|
|
|
{
|
|
|
_bounds.x = x;
|
|
|
_bounds.y = y;
|
|
|
_dirty = true;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- void Control::setSize(float width, float height)
|
|
|
+void Control::setSize(float width, float height)
|
|
|
+{
|
|
|
+ if (width != _bounds.width || height != _bounds.height)
|
|
|
{
|
|
|
_bounds.width = width;
|
|
|
_bounds.height = height;
|
|
|
_dirty = true;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- void Control::setBounds(const Rectangle& bounds)
|
|
|
- {
|
|
|
- _bounds.set(bounds);
|
|
|
- }
|
|
|
+void Control::setBounds(const Rectangle& bounds)
|
|
|
+{
|
|
|
+ _bounds.set(bounds);
|
|
|
+}
|
|
|
|
|
|
- const Rectangle& Control::getBounds() const
|
|
|
- {
|
|
|
- return _bounds;
|
|
|
- }
|
|
|
+const Rectangle& Control::getBounds() const
|
|
|
+{
|
|
|
+ return _bounds;
|
|
|
+}
|
|
|
|
|
|
- float Control::getX() const
|
|
|
- {
|
|
|
- return _bounds.x;
|
|
|
- }
|
|
|
+float Control::getX() const
|
|
|
+{
|
|
|
+ return _bounds.x;
|
|
|
+}
|
|
|
|
|
|
- float Control::getY() const
|
|
|
- {
|
|
|
- return _bounds.y;
|
|
|
- }
|
|
|
+float Control::getY() const
|
|
|
+{
|
|
|
+ return _bounds.y;
|
|
|
+}
|
|
|
|
|
|
- float Control::getWidth() const
|
|
|
- {
|
|
|
- return _bounds.width;
|
|
|
- }
|
|
|
+float Control::getWidth() const
|
|
|
+{
|
|
|
+ return _bounds.width;
|
|
|
+}
|
|
|
|
|
|
- float Control::getHeight() const
|
|
|
- {
|
|
|
- return _bounds.height;
|
|
|
- }
|
|
|
+float Control::getHeight() const
|
|
|
+{
|
|
|
+ return _bounds.height;
|
|
|
+}
|
|
|
|
|
|
- void Control::setAlignment(Alignment alignment)
|
|
|
- {
|
|
|
- _alignment = alignment;
|
|
|
- }
|
|
|
+void Control::setAlignment(Alignment alignment)
|
|
|
+{
|
|
|
+ _alignment = alignment;
|
|
|
+}
|
|
|
|
|
|
- Control::Alignment Control::getAlignment() const
|
|
|
- {
|
|
|
- return _alignment;
|
|
|
- }
|
|
|
+Control::Alignment Control::getAlignment() const
|
|
|
+{
|
|
|
+ return _alignment;
|
|
|
+}
|
|
|
|
|
|
- void Control::setAutoWidth(bool autoWidth)
|
|
|
- {
|
|
|
- _autoWidth = autoWidth;
|
|
|
- }
|
|
|
+void Control::setAutoWidth(bool autoWidth)
|
|
|
+{
|
|
|
+ _autoWidth = autoWidth;
|
|
|
+}
|
|
|
|
|
|
- bool Control::getAutoWidth() const
|
|
|
- {
|
|
|
- return _autoWidth;
|
|
|
- }
|
|
|
+bool Control::getAutoWidth() const
|
|
|
+{
|
|
|
+ return _autoWidth;
|
|
|
+}
|
|
|
+
|
|
|
+void Control::setAutoHeight(bool autoHeight)
|
|
|
+{
|
|
|
+ _autoHeight = autoHeight;
|
|
|
+}
|
|
|
|
|
|
- void Control::setAutoHeight(bool autoHeight)
|
|
|
+void Control::setOpacity(float opacity, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
+
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- _autoHeight = autoHeight;
|
|
|
+ overlays[i]->setOpacity(opacity);
|
|
|
}
|
|
|
+
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- void Control::setOpacity(float opacity, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+float Control::getOpacity(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getOpacity();
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setOpacity(opacity);
|
|
|
- }
|
|
|
-
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setBorder(float top, float bottom, float left, float right, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- float Control::getOpacity(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getOpacity();
|
|
|
+ overlays[i]->setBorder(top, bottom, left, right);
|
|
|
}
|
|
|
|
|
|
- void Control::setBorder(float top, float bottom, float left, float right, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setBorder(top, bottom, left, right);
|
|
|
- }
|
|
|
+const Theme::Border& Control::getBorder(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getBorder();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setSkinRegion(const Rectangle& region, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Theme::Border& Control::getBorder(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getBorder();
|
|
|
+ overlays[i]->setSkinRegion(region, _style->_tw, _style->_th);
|
|
|
}
|
|
|
|
|
|
- void Control::setSkinRegion(const Rectangle& region, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setSkinRegion(region, _style->_tw, _style->_th);
|
|
|
- }
|
|
|
+const Rectangle& Control::getSkinRegion(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getSkinRegion();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+const Theme::UVs& Control::getSkinUVs(Theme::Skin::SkinArea area, State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getSkinUVs(area);
|
|
|
+}
|
|
|
|
|
|
- const Rectangle& Control::getSkinRegion(State state) const
|
|
|
- {
|
|
|
- return getOverlay(state)->getSkinRegion();
|
|
|
- }
|
|
|
+void Control::setSkinColor(const Vector4& color, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Theme::UVs& Control::getSkinUVs(Theme::Skin::SkinArea area, State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getSkinUVs(area);
|
|
|
+ overlays[i]->setSkinColor(color);
|
|
|
}
|
|
|
|
|
|
- void Control::setSkinColor(const Vector4& color, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setSkinColor(color);
|
|
|
- }
|
|
|
+const Vector4& Control::getSkinColor(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getSkinColor();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setMargin(float top, float bottom, float left, float right)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ _style->setMargin(top, bottom, left, right);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- const Vector4& Control::getSkinColor(State state) const
|
|
|
- {
|
|
|
- return getOverlay(state)->getSkinColor();
|
|
|
- }
|
|
|
+const Theme::Margin& Control::getMargin() const
|
|
|
+{
|
|
|
+ return _style->getMargin();
|
|
|
+}
|
|
|
|
|
|
- void Control::setMargin(float top, float bottom, float left, float right)
|
|
|
- {
|
|
|
- _style->setMargin(top, bottom, left, right);
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setPadding(float top, float bottom, float left, float right)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ _style->setPadding(top, bottom, left, right);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
+
|
|
|
+const Theme::Padding& Control::getPadding() const
|
|
|
+{
|
|
|
+ return _style->getPadding();
|
|
|
+}
|
|
|
|
|
|
- const Theme::Margin& Control::getMargin() const
|
|
|
- {
|
|
|
- return _style->getMargin();
|
|
|
- }
|
|
|
+void Control::setImageRegion(const char* id, const Rectangle& region, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- void Control::setPadding(float top, float bottom, float left, float right)
|
|
|
- {
|
|
|
- _style->setPadding(top, bottom, left, right);
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
-
|
|
|
- const Theme::Padding& Control::getPadding() const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return _style->getPadding();
|
|
|
+ overlays[i]->setImageRegion(id, region, _style->_tw, _style->_th);
|
|
|
}
|
|
|
|
|
|
- void Control::setImageRegion(const char* id, const Rectangle& region, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setImageRegion(id, region, _style->_tw, _style->_th);
|
|
|
- }
|
|
|
+const Rectangle& Control::getImageRegion(const char* id, State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getImageRegion(id);
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setImageColor(const char* id, const Vector4& color, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Rectangle& Control::getImageRegion(const char* id, State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getImageRegion(id);
|
|
|
+ overlays[i]->setImageColor(id, color);
|
|
|
}
|
|
|
|
|
|
- void Control::setImageColor(const char* id, const Vector4& color, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setImageColor(id, color);
|
|
|
- }
|
|
|
+const Vector4& Control::getImageColor(const char* id, State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getImageColor(id);
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+const Theme::UVs& Control::getImageUVs(const char* id, State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getImageUVs(id);
|
|
|
+}
|
|
|
|
|
|
- const Vector4& Control::getImageColor(const char* id, State state) const
|
|
|
- {
|
|
|
- return getOverlay(state)->getImageColor(id);
|
|
|
- }
|
|
|
+void Control::setCursorRegion(const Rectangle& region, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Theme::UVs& Control::getImageUVs(const char* id, State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getImageUVs(id);
|
|
|
+ overlays[i]->setCursorRegion(region, _style->_tw, _style->_th);
|
|
|
}
|
|
|
|
|
|
- void Control::setCursorRegion(const Rectangle& region, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setCursorRegion(region, _style->_tw, _style->_th);
|
|
|
- }
|
|
|
+const Rectangle& Control::getCursorRegion(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getCursorRegion();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setCursorColor(const Vector4& color, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Rectangle& Control::getCursorRegion(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getCursorRegion();
|
|
|
+ overlays[i]->setCursorColor(color);
|
|
|
}
|
|
|
|
|
|
- void Control::setCursorColor(const Vector4& color, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setCursorColor(color);
|
|
|
- }
|
|
|
+const Vector4& Control::getCursorColor(State state)
|
|
|
+{
|
|
|
+ return getOverlay(state)->getCursorColor();
|
|
|
+}
|
|
|
+
|
|
|
+const Theme::UVs& Control::getCursorUVs(State state)
|
|
|
+{
|
|
|
+ return getOverlay(state)->getCursorUVs();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setFont(Font* font, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Vector4& Control::getCursorColor(State state)
|
|
|
- {
|
|
|
- return getOverlay(state)->getCursorColor();
|
|
|
- }
|
|
|
-
|
|
|
- const Theme::UVs& Control::getCursorUVs(State state)
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getCursorUVs();
|
|
|
+ overlays[i]->setFont(font);
|
|
|
}
|
|
|
|
|
|
- void Control::setFont(Font* font, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setFont(font);
|
|
|
- }
|
|
|
+Font* Control::getFont(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getFont();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setFontSize(unsigned int fontSize, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- Font* Control::getFont(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getFont();
|
|
|
+ overlays[i]->setFontSize(fontSize);
|
|
|
}
|
|
|
|
|
|
- void Control::setFontSize(unsigned int fontSize, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setFontSize(fontSize);
|
|
|
- }
|
|
|
+unsigned int Control::getFontSize(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getFontSize();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setTextColor(const Vector4& color, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- unsigned int Control::getFontSize(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getFontSize();
|
|
|
+ overlays[i]->setTextColor(color);
|
|
|
}
|
|
|
|
|
|
- void Control::setTextColor(const Vector4& color, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setTextColor(color);
|
|
|
- }
|
|
|
+const Vector4& Control::getTextColor(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getTextColor();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setTextAlignment(Font::Justify alignment, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- const Vector4& Control::getTextColor(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getTextColor();
|
|
|
+ overlays[i]->setTextAlignment(alignment);
|
|
|
}
|
|
|
|
|
|
- void Control::setTextAlignment(Font::Justify alignment, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setTextAlignment(alignment);
|
|
|
- }
|
|
|
+Font::Justify Control::getTextAlignment(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getTextAlignment();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+void Control::setTextRightToLeft(bool rightToLeft, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- Font::Justify Control::getTextAlignment(State state) const
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
{
|
|
|
- return getOverlay(state)->getTextAlignment();
|
|
|
+ overlays[i]->setTextRightToLeft(rightToLeft);
|
|
|
}
|
|
|
|
|
|
- void Control::setTextRightToLeft(bool rightToLeft, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setTextRightToLeft(rightToLeft);
|
|
|
- }
|
|
|
+bool Control::getTextRightToLeft(State state) const
|
|
|
+{
|
|
|
+ return getOverlay(state)->getTextRightToLeft();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+const Rectangle& Control::getClipBounds() const
|
|
|
+{
|
|
|
+ return _clipBounds;
|
|
|
+}
|
|
|
|
|
|
- bool Control::getTextRightToLeft(State state) const
|
|
|
- {
|
|
|
- return getOverlay(state)->getTextRightToLeft();
|
|
|
- }
|
|
|
+const Rectangle& Control::getClip() const
|
|
|
+{
|
|
|
+ return _viewportClipBounds;
|
|
|
+}
|
|
|
|
|
|
- const Rectangle& Control::getClipBounds() const
|
|
|
+void Control::setStyle(Theme::Style* style)
|
|
|
+{
|
|
|
+ if (style != _style)
|
|
|
{
|
|
|
- return _clipBounds;
|
|
|
+ _dirty = true;
|
|
|
}
|
|
|
|
|
|
- const Rectangle& Control::getClip() const
|
|
|
- {
|
|
|
- return _clip;
|
|
|
- }
|
|
|
+ _style = style;
|
|
|
+}
|
|
|
|
|
|
- void Control::setStyle(Theme::Style* style)
|
|
|
- {
|
|
|
- if (style != _style)
|
|
|
- {
|
|
|
- _dirty = true;
|
|
|
- }
|
|
|
+Theme::Style* Control::getStyle() const
|
|
|
+{
|
|
|
+ return _style;
|
|
|
+}
|
|
|
|
|
|
- _style = style;
|
|
|
- }
|
|
|
+void Control::setState(State state)
|
|
|
+{
|
|
|
+ if (getOverlay(_state) != getOverlay(state))
|
|
|
+ _dirty = true;
|
|
|
|
|
|
- Theme::Style* Control::getStyle() const
|
|
|
- {
|
|
|
- return _style;
|
|
|
+ _state = state;
|
|
|
+}
|
|
|
+
|
|
|
+Control::State Control::getState() const
|
|
|
+{
|
|
|
+ return _state;
|
|
|
+}
|
|
|
+
|
|
|
+void Control::disable()
|
|
|
+{
|
|
|
+ _state = DISABLED;
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
+
|
|
|
+void Control::enable()
|
|
|
+{
|
|
|
+ _state = NORMAL;
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
+
|
|
|
+bool Control::isEnabled()
|
|
|
+{
|
|
|
+ return _state != DISABLED;
|
|
|
+}
|
|
|
+
|
|
|
+Theme::Style::OverlayType Control::getOverlayType() const
|
|
|
+{
|
|
|
+ switch (_state)
|
|
|
+ {
|
|
|
+ case Control::NORMAL:
|
|
|
+ return Theme::Style::OVERLAY_NORMAL;
|
|
|
+ case Control::FOCUS:
|
|
|
+ return Theme::Style::OVERLAY_FOCUS;
|
|
|
+ case Control::ACTIVE:
|
|
|
+ return Theme::Style::OVERLAY_ACTIVE;
|
|
|
+ case Control::DISABLED:
|
|
|
+ return Theme::Style::OVERLAY_DISABLED;
|
|
|
+ default:
|
|
|
+ return Theme::Style::OVERLAY_NORMAL;
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+void Control::setConsumeTouchEvents(bool consume)
|
|
|
+{
|
|
|
+ _consumeTouchEvents = consume;
|
|
|
+}
|
|
|
+
|
|
|
+bool Control::getConsumeTouchEvents()
|
|
|
+{
|
|
|
+ return _consumeTouchEvents;
|
|
|
+}
|
|
|
|
|
|
- void Control::setState(State state)
|
|
|
+void Control::addListener(Control::Listener* listener, int eventFlags)
|
|
|
+{
|
|
|
+ if ((eventFlags & Listener::PRESS) == Listener::PRESS)
|
|
|
{
|
|
|
- _state = state;
|
|
|
- _dirty = true;
|
|
|
+ addSpecificListener(listener, Listener::PRESS);
|
|
|
}
|
|
|
|
|
|
- Control::State Control::getState() const
|
|
|
+ if ((eventFlags & Listener::RELEASE) == Listener::RELEASE)
|
|
|
{
|
|
|
- return _state;
|
|
|
+ addSpecificListener(listener, Listener::RELEASE);
|
|
|
}
|
|
|
|
|
|
- void Control::disable()
|
|
|
+ if ((eventFlags & Listener::CLICK) == Listener::CLICK)
|
|
|
{
|
|
|
- _state = DISABLED;
|
|
|
- _dirty = true;
|
|
|
+ addSpecificListener(listener, Listener::CLICK);
|
|
|
}
|
|
|
|
|
|
- void Control::enable()
|
|
|
+ if ((eventFlags & Listener::VALUE_CHANGED) == Listener::VALUE_CHANGED)
|
|
|
{
|
|
|
- _state = NORMAL;
|
|
|
- _dirty = true;
|
|
|
+ addSpecificListener(listener, Listener::VALUE_CHANGED);
|
|
|
}
|
|
|
|
|
|
- bool Control::isEnabled()
|
|
|
+ if ((eventFlags & Listener::TEXT_CHANGED) == Listener::TEXT_CHANGED)
|
|
|
{
|
|
|
- return _state != DISABLED;
|
|
|
+ addSpecificListener(listener, Listener::TEXT_CHANGED);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- Theme::Style::OverlayType Control::getOverlayType() const
|
|
|
+void Control::addSpecificListener(Control::Listener* listener, Listener::EventType eventType)
|
|
|
+{
|
|
|
+ if (!_listeners)
|
|
|
{
|
|
|
- switch (_state)
|
|
|
- {
|
|
|
- case Control::NORMAL:
|
|
|
- return Theme::Style::OVERLAY_NORMAL;
|
|
|
- case Control::FOCUS:
|
|
|
- return Theme::Style::OVERLAY_FOCUS;
|
|
|
- case Control::ACTIVE:
|
|
|
- return Theme::Style::OVERLAY_ACTIVE;
|
|
|
- case Control::DISABLED:
|
|
|
- return Theme::Style::OVERLAY_DISABLED;
|
|
|
- default:
|
|
|
- return Theme::Style::OVERLAY_NORMAL;
|
|
|
- }
|
|
|
+ _listeners = new std::map<Listener::EventType, std::list<Listener*>*>();
|
|
|
}
|
|
|
|
|
|
- void Control::setConsumeTouchEvents(bool consume)
|
|
|
+ std::map<Listener::EventType, std::list<Listener*>*>::const_iterator itr = _listeners->find(eventType);
|
|
|
+ if (itr == _listeners->end())
|
|
|
{
|
|
|
- _consumeTouchEvents = consume;
|
|
|
+ _listeners->insert(std::make_pair(eventType, new std::list<Listener*>()));
|
|
|
+ itr = _listeners->find(eventType);
|
|
|
}
|
|
|
-
|
|
|
- bool Control::getConsumeTouchEvents()
|
|
|
+
|
|
|
+ std::list<Listener*>* listenerList = itr->second;
|
|
|
+ listenerList->push_back(listener);
|
|
|
+}
|
|
|
+
|
|
|
+bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
|
|
|
+{
|
|
|
+ if (!isEnabled())
|
|
|
{
|
|
|
- return _consumeTouchEvents;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- void Control::addListener(Control::Listener* listener, int eventFlags)
|
|
|
+ switch (evt)
|
|
|
{
|
|
|
- if ((eventFlags & Listener::PRESS) == Listener::PRESS)
|
|
|
- {
|
|
|
- addSpecificListener(listener, Listener::PRESS);
|
|
|
- }
|
|
|
-
|
|
|
- if ((eventFlags & Listener::RELEASE) == Listener::RELEASE)
|
|
|
- {
|
|
|
- addSpecificListener(listener, Listener::RELEASE);
|
|
|
- }
|
|
|
+ case Touch::TOUCH_PRESS:
|
|
|
+ notifyListeners(Listener::PRESS);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Touch::TOUCH_RELEASE:
|
|
|
+ // Always trigger Listener::RELEASE
|
|
|
+ notifyListeners(Listener::RELEASE);
|
|
|
|
|
|
- if ((eventFlags & Listener::CLICK) == Listener::CLICK)
|
|
|
+ // Only trigger Listener::CLICK if both PRESS and RELEASE took place within the control's bounds.
|
|
|
+ if (x > 0 && x <= _bounds.width &&
|
|
|
+ y > 0 && y <= _bounds.height)
|
|
|
{
|
|
|
- addSpecificListener(listener, Listener::CLICK);
|
|
|
+ notifyListeners(Listener::CLICK);
|
|
|
}
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- if ((eventFlags & Listener::VALUE_CHANGED) == Listener::VALUE_CHANGED)
|
|
|
- {
|
|
|
- addSpecificListener(listener, Listener::VALUE_CHANGED);
|
|
|
- }
|
|
|
+ return _consumeTouchEvents;
|
|
|
+}
|
|
|
|
|
|
- if ((eventFlags & Listener::TEXT_CHANGED) == Listener::TEXT_CHANGED)
|
|
|
- {
|
|
|
- addSpecificListener(listener, Listener::TEXT_CHANGED);
|
|
|
- }
|
|
|
- }
|
|
|
+void Control::keyEvent(Keyboard::KeyEvent evt, int key)
|
|
|
+{
|
|
|
+}
|
|
|
|
|
|
- void Control::addSpecificListener(Control::Listener* listener, Listener::EventType eventType)
|
|
|
+void Control::notifyListeners(Listener::EventType eventType)
|
|
|
+{
|
|
|
+ if (_listeners)
|
|
|
{
|
|
|
- if (!_listeners)
|
|
|
- {
|
|
|
- _listeners = new std::map<Listener::EventType, std::list<Listener*>*>();
|
|
|
- }
|
|
|
-
|
|
|
std::map<Listener::EventType, std::list<Listener*>*>::const_iterator itr = _listeners->find(eventType);
|
|
|
- if (itr == _listeners->end())
|
|
|
+ if (itr != _listeners->end())
|
|
|
{
|
|
|
- _listeners->insert(std::make_pair(eventType, new std::list<Listener*>()));
|
|
|
- itr = _listeners->find(eventType);
|
|
|
+ std::list<Listener*>* listenerList = itr->second;
|
|
|
+ for (std::list<Listener*>::iterator listenerItr = listenerList->begin(); listenerItr != listenerList->end(); listenerItr++)
|
|
|
+ {
|
|
|
+ (*listenerItr)->controlEvent(this, eventType);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- std::list<Listener*>* listenerList = itr->second;
|
|
|
- listenerList->push_back(listener);
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
|
|
|
- {
|
|
|
- if (!isEnabled())
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+void Control::update(const Rectangle& clip, const Vector2& offset)
|
|
|
+{
|
|
|
+ _clearBounds.set(_absoluteClipBounds);
|
|
|
|
|
|
- switch (evt)
|
|
|
- {
|
|
|
- case Touch::TOUCH_PRESS:
|
|
|
- notifyListeners(Listener::PRESS);
|
|
|
- break;
|
|
|
-
|
|
|
- case Touch::TOUCH_RELEASE:
|
|
|
- // Always trigger Listener::RELEASE
|
|
|
- notifyListeners(Listener::RELEASE);
|
|
|
+ // Calculate the clipped bounds.
|
|
|
+ float x = _bounds.x + offset.x;
|
|
|
+ float y = _bounds.y + offset.y;
|
|
|
+ float width = _bounds.width;
|
|
|
+ float height = _bounds.height;
|
|
|
|
|
|
- // Only trigger Listener::CLICK if both PRESS and RELEASE took place within the control's bounds.
|
|
|
- if (x > 0 && x <= _bounds.width &&
|
|
|
- y > 0 && y <= _bounds.height)
|
|
|
- {
|
|
|
- notifyListeners(Listener::CLICK);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ float clipX2 = clip.x + clip.width;
|
|
|
+ float x2 = clip.x + x + width;
|
|
|
+ if (x2 > clipX2)
|
|
|
+ width -= x2 - clipX2;
|
|
|
|
|
|
- return _consumeTouchEvents;
|
|
|
- }
|
|
|
+ float clipY2 = clip.y + clip.height;
|
|
|
+ float y2 = clip.y + y + height;
|
|
|
+ if (y2 > clipY2)
|
|
|
+ height -= y2 - clipY2;
|
|
|
|
|
|
- void Control::keyEvent(Keyboard::KeyEvent evt, int key)
|
|
|
+ if (x < 0)
|
|
|
{
|
|
|
+ width += x;
|
|
|
+ x = -x;
|
|
|
}
|
|
|
-
|
|
|
- void Control::notifyListeners(Listener::EventType eventType)
|
|
|
+ else
|
|
|
{
|
|
|
- if (_listeners)
|
|
|
- {
|
|
|
- std::map<Listener::EventType, std::list<Listener*>*>::const_iterator itr = _listeners->find(eventType);
|
|
|
- if (itr != _listeners->end())
|
|
|
- {
|
|
|
- std::list<Listener*>* listenerList = itr->second;
|
|
|
- for (std::list<Listener*>::iterator listenerItr = listenerList->begin(); listenerItr != listenerList->end(); listenerItr++)
|
|
|
- {
|
|
|
- (*listenerItr)->controlEvent(this, eventType);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ x = 0;
|
|
|
}
|
|
|
|
|
|
- void Control::update(const Rectangle& clip, const Vector2& offset)
|
|
|
+ if (y < 0)
|
|
|
+ {
|
|
|
+ height += y;
|
|
|
+ y = -y;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- // Calculate the clipped bounds.
|
|
|
- float x = _bounds.x + offset.x;
|
|
|
- float y = _bounds.y + offset.y;
|
|
|
- float width = _bounds.width;
|
|
|
- float height = _bounds.height;
|
|
|
+ y = 0;
|
|
|
+ }
|
|
|
|
|
|
- float clipX2 = clip.x + clip.width;
|
|
|
- float x2 = clip.x + x + width;
|
|
|
- if (x2 > clipX2)
|
|
|
- width -= x2 - clipX2;
|
|
|
+ _clipBounds.set(x, y, width, height);
|
|
|
|
|
|
- float clipY2 = clip.y + clip.height;
|
|
|
- float y2 = clip.y + y + height;
|
|
|
- if (y2 > clipY2)
|
|
|
- height -= y2 - clipY2;
|
|
|
+ // Calculate the absolute bounds.
|
|
|
+ x = _bounds.x + offset.x + clip.x;
|
|
|
+ y = _bounds.y + offset.y + clip.y;
|
|
|
+ _absoluteBounds.set(x, y, _bounds.width, _bounds.height);
|
|
|
|
|
|
- if (x < 0)
|
|
|
- {
|
|
|
- width += x;
|
|
|
- x = -x;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- x = 0;
|
|
|
- }
|
|
|
+ // Calculate the absolute viewport bounds.
|
|
|
+ // Absolute bounds minus border and padding.
|
|
|
+ const Theme::Border& border = getBorder(_state);
|
|
|
+ const Theme::Padding& padding = getPadding();
|
|
|
|
|
|
- if (y < 0)
|
|
|
- {
|
|
|
- height += y;
|
|
|
- y = -y;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- y = 0;
|
|
|
- }
|
|
|
+ x += border.left + padding.left;
|
|
|
+ y += border.top + padding.top;
|
|
|
+ width = _bounds.width - border.left - padding.left - border.right - padding.right;
|
|
|
+ height = _bounds.height - border.top - padding.top - border.bottom - padding.bottom;
|
|
|
|
|
|
- _clipBounds.set(x, y, width, height);
|
|
|
+ _viewportBounds.set(x, y, width, height);
|
|
|
|
|
|
- // Calculate the absolute bounds.
|
|
|
- x = _bounds.x + offset.x + clip.x;
|
|
|
- y = _bounds.y + offset.y + clip.y;
|
|
|
+ // Calculate the clip area.
|
|
|
+ // Absolute bounds, minus border and padding,
|
|
|
+ // clipped to the parent container's clip area.
|
|
|
+ clipX2 = clip.x + clip.width;
|
|
|
+ x2 = x + width;
|
|
|
+ if (x2 > clipX2)
|
|
|
+ width = clipX2 - x;
|
|
|
|
|
|
- _absoluteBounds.set(x, y, _bounds.width, _bounds.height);
|
|
|
+ clipY2 = clip.y + clip.height;
|
|
|
+ y2 = y + height;
|
|
|
+ if (y2 > clipY2)
|
|
|
+ height = clipY2 - y;
|
|
|
|
|
|
- // Calculate the absolute viewport bounds.
|
|
|
- // Absolute bounds minus border and padding.
|
|
|
- const Theme::Border& border = getBorder(_state);
|
|
|
- const Theme::Padding& padding = getPadding();
|
|
|
+ if (x < clip.x)
|
|
|
+ {
|
|
|
+ float dx = clip.x - x;
|
|
|
+ width -= dx;
|
|
|
+ x = clip.x;
|
|
|
+ }
|
|
|
|
|
|
- x += border.left + padding.left;
|
|
|
- y += border.top + padding.top;
|
|
|
- width = _bounds.width - border.left - padding.left - border.right - padding.right;
|
|
|
- height = _bounds.height - border.top - padding.top - border.bottom - padding.bottom;
|
|
|
+ if (y < clip.y)
|
|
|
+ {
|
|
|
+ float dy = clip.y - y;
|
|
|
+ height -= dy;
|
|
|
+ y = clip.y;
|
|
|
+ }
|
|
|
+
|
|
|
+ _viewportClipBounds.set(x, y, width, height);
|
|
|
|
|
|
- _viewportBounds.set(x, y, width, height);
|
|
|
+ _absoluteClipBounds.set(x - border.left - padding.left, y - border.top - padding.top,
|
|
|
+ width + border.left + padding.left + border.right + padding.right,
|
|
|
+ height + border.top + padding.top + border.bottom + padding.bottom);
|
|
|
+ if (_clearBounds.isEmpty())
|
|
|
+ {
|
|
|
+ _clearBounds.set(_absoluteClipBounds);
|
|
|
+ }
|
|
|
|
|
|
- // Calculate the clip area.
|
|
|
- // Absolute bounds, minus border and padding,
|
|
|
- // clipped to the parent container's clip area.
|
|
|
- clipX2 = clip.x + clip.width;
|
|
|
- x2 = x + width;
|
|
|
- if (x2 > clipX2)
|
|
|
- width = clipX2 - x;
|
|
|
+ // Cache themed attributes for performance.
|
|
|
+ _skin = getSkin(_state);
|
|
|
+ _opacity = getOpacity(_state);
|
|
|
+}
|
|
|
|
|
|
- clipY2 = clip.y + clip.height;
|
|
|
- y2 = y + height;
|
|
|
- if (y2 > clipY2)
|
|
|
- height = clipY2 - y;
|
|
|
+void Control::drawBorder(SpriteBatch* spriteBatch, const Rectangle& clip)
|
|
|
+{
|
|
|
+ if (!_skin || _bounds.width <= 0 || _bounds.height <= 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ // Get the border and background images for this control's current state.
|
|
|
+ const Theme::UVs& topLeft = _skin->getUVs(Theme::Skin::TOP_LEFT);
|
|
|
+ const Theme::UVs& top = _skin->getUVs(Theme::Skin::TOP);
|
|
|
+ const Theme::UVs& topRight = _skin->getUVs(Theme::Skin::TOP_RIGHT);
|
|
|
+ const Theme::UVs& left = _skin->getUVs(Theme::Skin::LEFT);
|
|
|
+ const Theme::UVs& center = _skin->getUVs(Theme::Skin::CENTER);
|
|
|
+ const Theme::UVs& right = _skin->getUVs(Theme::Skin::RIGHT);
|
|
|
+ const Theme::UVs& bottomLeft = _skin->getUVs(Theme::Skin::BOTTOM_LEFT);
|
|
|
+ const Theme::UVs& bottom = _skin->getUVs(Theme::Skin::BOTTOM);
|
|
|
+ const Theme::UVs& bottomRight = _skin->getUVs(Theme::Skin::BOTTOM_RIGHT);
|
|
|
+
|
|
|
+ // Calculate screen-space positions.
|
|
|
+ const Theme::Border& border = getBorder(_state);
|
|
|
+ const Theme::Padding& padding = getPadding();
|
|
|
+ Vector4 skinColor = _skin->getColor();
|
|
|
+ skinColor.w *= _opacity;
|
|
|
+
|
|
|
+ float midWidth = _bounds.width - border.left - border.right;
|
|
|
+ float midHeight = _bounds.height - border.top - border.bottom;
|
|
|
+ float midX = _absoluteBounds.x + border.left;
|
|
|
+ float midY = _absoluteBounds.y + border.top;
|
|
|
+ float rightX = _absoluteBounds.x + _bounds.width - border.right;
|
|
|
+ float bottomY = _absoluteBounds.y + _bounds.height - border.bottom;
|
|
|
+
|
|
|
+ // Draw themed border sprites.
|
|
|
+ if (!border.left && !border.right && !border.top && !border.bottom)
|
|
|
+ {
|
|
|
+ // No border, just draw the image.
|
|
|
+ spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, _bounds.width, _bounds.height, center.u1, center.v1, center.u2, center.v2, skinColor, clip);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (border.left && border.top)
|
|
|
+ spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, border.left, border.top, topLeft.u1, topLeft.v1, topLeft.u2, topLeft.v2, skinColor, clip);
|
|
|
+ if (border.top)
|
|
|
+ spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y, midWidth, border.top, top.u1, top.v1, top.u2, top.v2, skinColor, clip);
|
|
|
+ if (border.right && border.top)
|
|
|
+ spriteBatch->draw(rightX, _absoluteBounds.y, border.right, border.top, topRight.u1, topRight.v1, topRight.u2, topRight.v2, skinColor, clip);
|
|
|
+ if (border.left)
|
|
|
+ spriteBatch->draw(_absoluteBounds.x, midY, border.left, midHeight, left.u1, left.v1, left.u2, left.v2, skinColor, clip);
|
|
|
+ if (border.left && border.right && border.top && border.bottom)
|
|
|
+ spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y + border.top, _bounds.width - border.left - border.right, _bounds.height - border.top - border.bottom,
|
|
|
+ center.u1, center.v1, center.u2, center.v2, skinColor, clip);
|
|
|
+ if (border.right)
|
|
|
+ spriteBatch->draw(rightX, midY, border.right, midHeight, right.u1, right.v1, right.u2, right.v2, skinColor, clip);
|
|
|
+ if (border.bottom && border.left)
|
|
|
+ spriteBatch->draw(_absoluteBounds.x, bottomY, border.left, border.bottom, bottomLeft.u1, bottomLeft.v1, bottomLeft.u2, bottomLeft.v2, skinColor, clip);
|
|
|
+ if (border.bottom)
|
|
|
+ spriteBatch->draw(midX, bottomY, midWidth, border.bottom, bottom.u1, bottom.v1, bottom.u2, bottom.v2, skinColor, clip);
|
|
|
+ if (border.bottom && border.right)
|
|
|
+ spriteBatch->draw(rightX, bottomY, border.right, border.bottom, bottomRight.u1, bottomRight.v1, bottomRight.u2, bottomRight.v2, skinColor, clip);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- if (x < clip.x)
|
|
|
- {
|
|
|
- float dx = clip.x - x;
|
|
|
- width -= dx;
|
|
|
- x = clip.x;
|
|
|
- }
|
|
|
+void Control::drawImages(SpriteBatch* spriteBatch, const Rectangle& position)
|
|
|
+{
|
|
|
+}
|
|
|
|
|
|
- if (y < clip.y)
|
|
|
- {
|
|
|
- float dy = clip.y - y;
|
|
|
- height -= dy;
|
|
|
- y = clip.y;
|
|
|
- }
|
|
|
-
|
|
|
- _clip.set(x, y, width, height);
|
|
|
-
|
|
|
- // Cache themed attributes for performance.
|
|
|
- _skin = getSkin(_state);
|
|
|
- _opacity = getOpacity(_state);
|
|
|
- }
|
|
|
-
|
|
|
- void Control::drawBorder(SpriteBatch* spriteBatch, const Rectangle& clip)
|
|
|
- {
|
|
|
- if (!_skin || _bounds.width <= 0 || _bounds.height <= 0)
|
|
|
- return;
|
|
|
-
|
|
|
- // Get the border and background images for this control's current state.
|
|
|
- const Theme::UVs& topLeft = _skin->getUVs(Theme::Skin::TOP_LEFT);
|
|
|
- const Theme::UVs& top = _skin->getUVs(Theme::Skin::TOP);
|
|
|
- const Theme::UVs& topRight = _skin->getUVs(Theme::Skin::TOP_RIGHT);
|
|
|
- const Theme::UVs& left = _skin->getUVs(Theme::Skin::LEFT);
|
|
|
- const Theme::UVs& center = _skin->getUVs(Theme::Skin::CENTER);
|
|
|
- const Theme::UVs& right = _skin->getUVs(Theme::Skin::RIGHT);
|
|
|
- const Theme::UVs& bottomLeft = _skin->getUVs(Theme::Skin::BOTTOM_LEFT);
|
|
|
- const Theme::UVs& bottom = _skin->getUVs(Theme::Skin::BOTTOM);
|
|
|
- const Theme::UVs& bottomRight = _skin->getUVs(Theme::Skin::BOTTOM_RIGHT);
|
|
|
-
|
|
|
- // Calculate screen-space positions.
|
|
|
- const Theme::Border& border = getBorder(_state);
|
|
|
- const Theme::Padding& padding = getPadding();
|
|
|
- Vector4 skinColor = _skin->getColor();
|
|
|
- skinColor.w *= _opacity;
|
|
|
-
|
|
|
- float midWidth = _bounds.width - border.left - border.right;
|
|
|
- float midHeight = _bounds.height - border.top - border.bottom;
|
|
|
- float midX = _absoluteBounds.x + border.left;
|
|
|
- float midY = _absoluteBounds.y + border.top;
|
|
|
- float rightX = _absoluteBounds.x + _bounds.width - border.right;
|
|
|
- float bottomY = _absoluteBounds.y + _bounds.height - border.bottom;
|
|
|
-
|
|
|
- // Draw themed border sprites.
|
|
|
- if (!border.left && !border.right && !border.top && !border.bottom)
|
|
|
- {
|
|
|
- // No border, just draw the image.
|
|
|
- spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, _bounds.width, _bounds.height, center.u1, center.v1, center.u2, center.v2, skinColor, clip);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (border.left && border.top)
|
|
|
- spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, border.left, border.top, topLeft.u1, topLeft.v1, topLeft.u2, topLeft.v2, skinColor, clip);
|
|
|
- if (border.top)
|
|
|
- spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y, midWidth, border.top, top.u1, top.v1, top.u2, top.v2, skinColor, clip);
|
|
|
- if (border.right && border.top)
|
|
|
- spriteBatch->draw(rightX, _absoluteBounds.y, border.right, border.top, topRight.u1, topRight.v1, topRight.u2, topRight.v2, skinColor, clip);
|
|
|
- if (border.left)
|
|
|
- spriteBatch->draw(_absoluteBounds.x, midY, border.left, midHeight, left.u1, left.v1, left.u2, left.v2, skinColor, clip);
|
|
|
- if (border.left && border.right && border.top && border.bottom)
|
|
|
- spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y + border.top, _bounds.width - border.left - border.right, _bounds.height - border.top - border.bottom,
|
|
|
- center.u1, center.v1, center.u2, center.v2, skinColor, clip);
|
|
|
- if (border.right)
|
|
|
- spriteBatch->draw(rightX, midY, border.right, midHeight, right.u1, right.v1, right.u2, right.v2, skinColor, clip);
|
|
|
- if (border.bottom && border.left)
|
|
|
- spriteBatch->draw(_absoluteBounds.x, bottomY, border.left, border.bottom, bottomLeft.u1, bottomLeft.v1, bottomLeft.u2, bottomLeft.v2, skinColor, clip);
|
|
|
- if (border.bottom)
|
|
|
- spriteBatch->draw(midX, bottomY, midWidth, border.bottom, bottom.u1, bottom.v1, bottom.u2, bottom.v2, skinColor, clip);
|
|
|
- if (border.bottom && border.right)
|
|
|
- spriteBatch->draw(rightX, bottomY, border.right, border.bottom, bottomRight.u1, bottomRight.v1, bottomRight.u2, bottomRight.v2, skinColor, clip);
|
|
|
- }
|
|
|
- }
|
|
|
+void Control::drawText(const Rectangle& position)
|
|
|
+{
|
|
|
+}
|
|
|
|
|
|
- void Control::drawImages(SpriteBatch* spriteBatch, const Rectangle& position)
|
|
|
+void Control::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, float targetHeight)
|
|
|
+{
|
|
|
+ if (needsClear)
|
|
|
{
|
|
|
+ GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
|
|
|
+ GL_ASSERT( glClearColor(0, 0, 0, 1) );
|
|
|
+ GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height,
|
|
|
+ _clearBounds.width, _clearBounds.height) );
|
|
|
+ GL_ASSERT( glClear(GL_COLOR_BUFFER_BIT) );
|
|
|
+ GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
|
|
|
}
|
|
|
|
|
|
- void Control::drawText(const Rectangle& position)
|
|
|
+ drawBorder(spriteBatch, clip);
|
|
|
+ drawImages(spriteBatch, clip);
|
|
|
+ drawText(clip);
|
|
|
+ _dirty = false;
|
|
|
+}
|
|
|
+
|
|
|
+bool Control::isDirty()
|
|
|
+{
|
|
|
+ return _dirty;
|
|
|
+}
|
|
|
+
|
|
|
+bool Control::isContainer()
|
|
|
+{
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+Control::State Control::getState(const char* state)
|
|
|
+{
|
|
|
+ if (!state)
|
|
|
{
|
|
|
+ return NORMAL;
|
|
|
}
|
|
|
|
|
|
- void Control::draw(SpriteBatch* spriteBatch, const Rectangle& clip)
|
|
|
+ if (strcmp(state, "NORMAL") == 0)
|
|
|
{
|
|
|
- drawBorder(spriteBatch, clip);
|
|
|
- drawImages(spriteBatch, clip);
|
|
|
- drawText(clip);
|
|
|
- _dirty = false;
|
|
|
+ return NORMAL;
|
|
|
}
|
|
|
-
|
|
|
- bool Control::isDirty()
|
|
|
+ else if (strcmp(state, "ACTIVE") == 0)
|
|
|
{
|
|
|
- return _dirty;
|
|
|
+ return ACTIVE;
|
|
|
}
|
|
|
-
|
|
|
- bool Control::isContainer()
|
|
|
+ else if (strcmp(state, "FOCUS") == 0)
|
|
|
{
|
|
|
- return false;
|
|
|
+ return FOCUS;
|
|
|
}
|
|
|
+ else if (strcmp(state, "DISABLED") == 0)
|
|
|
+ {
|
|
|
+ return DISABLED;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NORMAL;
|
|
|
+}
|
|
|
|
|
|
- Control::State Control::getState(const char* state)
|
|
|
+Theme::ThemeImage* Control::getImage(const char* id, State state)
|
|
|
+{
|
|
|
+ return getOverlay(state)->getImageList()->getImage(id);
|
|
|
+}
|
|
|
+
|
|
|
+// Implementation of AnimationHandler
|
|
|
+unsigned int Control::getAnimationPropertyComponentCount(int propertyId) const
|
|
|
+{
|
|
|
+ switch(propertyId)
|
|
|
{
|
|
|
- if (!state)
|
|
|
- {
|
|
|
- return NORMAL;
|
|
|
- }
|
|
|
+ case ANIMATE_POSITION:
|
|
|
+ case ANIMATE_SIZE:
|
|
|
+ return 2;
|
|
|
|
|
|
- if (strcmp(state, "NORMAL") == 0)
|
|
|
- {
|
|
|
- return NORMAL;
|
|
|
- }
|
|
|
- else if (strcmp(state, "ACTIVE") == 0)
|
|
|
- {
|
|
|
- return ACTIVE;
|
|
|
- }
|
|
|
- else if (strcmp(state, "FOCUS") == 0)
|
|
|
- {
|
|
|
- return FOCUS;
|
|
|
- }
|
|
|
- else if (strcmp(state, "DISABLED") == 0)
|
|
|
- {
|
|
|
- return DISABLED;
|
|
|
- }
|
|
|
+ case ANIMATE_POSITION_X:
|
|
|
+ case ANIMATE_POSITION_Y:
|
|
|
+ case ANIMATE_SIZE_WIDTH:
|
|
|
+ case ANIMATE_SIZE_HEIGHT:
|
|
|
+ case ANIMATE_OPACITY:
|
|
|
+ return 1;
|
|
|
|
|
|
- return NORMAL;
|
|
|
+ default:
|
|
|
+ return -1;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- Theme::ThemeImage* Control::getImage(const char* id, State state)
|
|
|
+void Control::getAnimationPropertyValue(int propertyId, AnimationValue* value)
|
|
|
+{
|
|
|
+ switch(propertyId)
|
|
|
+ {
|
|
|
+ case ANIMATE_POSITION:
|
|
|
+ value->setFloat(0, _bounds.x);
|
|
|
+ value->setFloat(1, _bounds.y);
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE:
|
|
|
+ value->setFloat(0, _bounds.width);
|
|
|
+ value->setFloat(1, _bounds.height);
|
|
|
+ break;
|
|
|
+ case ANIMATE_POSITION_X:
|
|
|
+ value->setFloat(0, _bounds.x);
|
|
|
+ break;
|
|
|
+ case ANIMATE_POSITION_Y:
|
|
|
+ value->setFloat(0, _bounds.y);
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE_WIDTH:
|
|
|
+ value->setFloat(0, _bounds.width);
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE_HEIGHT:
|
|
|
+ value->setFloat(0, _bounds.height);
|
|
|
+ break;
|
|
|
+ case ANIMATE_OPACITY:
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void Control::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
|
|
|
+{
|
|
|
+ switch(propertyId)
|
|
|
{
|
|
|
- return getOverlay(state)->getImageList()->getImage(id);
|
|
|
+ case ANIMATE_POSITION:
|
|
|
+ _bounds.x = Curve::lerp(blendWeight, _bounds.x, value->getFloat(0));
|
|
|
+ _bounds.y = Curve::lerp(blendWeight, _bounds.y, value->getFloat(1));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_POSITION_X:
|
|
|
+ _bounds.x = Curve::lerp(blendWeight, _bounds.x, value->getFloat(0));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_POSITION_Y:
|
|
|
+ _bounds.y = Curve::lerp(blendWeight, _bounds.y, value->getFloat(0));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE:
|
|
|
+ _bounds.width = Curve::lerp(blendWeight, _bounds.width, value->getFloat(0));
|
|
|
+ _bounds.height = Curve::lerp(blendWeight, _bounds.height, value->getFloat(1));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE_WIDTH:
|
|
|
+ _bounds.width = Curve::lerp(blendWeight, _bounds.width, value->getFloat(0));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_SIZE_HEIGHT:
|
|
|
+ _bounds.height = Curve::lerp(blendWeight, _bounds.height, value->getFloat(0));
|
|
|
+ _dirty = true;
|
|
|
+ break;
|
|
|
+ case ANIMATE_OPACITY:
|
|
|
+ _dirty = true;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- // Implementation of AnimationHandler
|
|
|
- unsigned int Control::getAnimationPropertyComponentCount(int propertyId) const
|
|
|
+Theme::Style::Overlay** Control::getOverlays(unsigned char overlayTypes, Theme::Style::Overlay** overlays)
|
|
|
+{
|
|
|
+ unsigned int index = 0;
|
|
|
+ if ((overlayTypes & NORMAL) == NORMAL)
|
|
|
{
|
|
|
- switch(propertyId)
|
|
|
- {
|
|
|
- case ANIMATE_POSITION:
|
|
|
- case ANIMATE_SIZE:
|
|
|
- return 2;
|
|
|
-
|
|
|
- case ANIMATE_POSITION_X:
|
|
|
- case ANIMATE_POSITION_Y:
|
|
|
- case ANIMATE_SIZE_WIDTH:
|
|
|
- case ANIMATE_SIZE_HEIGHT:
|
|
|
- case ANIMATE_OPACITY:
|
|
|
- return 1;
|
|
|
-
|
|
|
- default:
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_NORMAL);
|
|
|
}
|
|
|
|
|
|
- void Control::getAnimationPropertyValue(int propertyId, AnimationValue* value)
|
|
|
+ if ((overlayTypes & FOCUS) == FOCUS)
|
|
|
{
|
|
|
- switch(propertyId)
|
|
|
- {
|
|
|
- case ANIMATE_POSITION:
|
|
|
- value->setFloat(0, _bounds.x);
|
|
|
- value->setFloat(1, _bounds.y);
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE:
|
|
|
- value->setFloat(0, _bounds.width);
|
|
|
- value->setFloat(1, _bounds.height);
|
|
|
- break;
|
|
|
- case ANIMATE_POSITION_X:
|
|
|
- value->setFloat(0, _bounds.x);
|
|
|
- break;
|
|
|
- case ANIMATE_POSITION_Y:
|
|
|
- value->setFloat(0, _bounds.y);
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE_WIDTH:
|
|
|
- value->setFloat(0, _bounds.width);
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE_HEIGHT:
|
|
|
- value->setFloat(0, _bounds.height);
|
|
|
- break;
|
|
|
- case ANIMATE_OPACITY:
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_FOCUS);
|
|
|
}
|
|
|
|
|
|
- void Control::setAnimationPropertyValue(int propertyId, AnimationValue* value, float blendWeight)
|
|
|
+ if ((overlayTypes & ACTIVE) == ACTIVE)
|
|
|
{
|
|
|
- switch(propertyId)
|
|
|
- {
|
|
|
- case ANIMATE_POSITION:
|
|
|
- _bounds.x = Curve::lerp(blendWeight, _bounds.x, value->getFloat(0));
|
|
|
- _bounds.y = Curve::lerp(blendWeight, _bounds.y, value->getFloat(1));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_POSITION_X:
|
|
|
- _bounds.x = Curve::lerp(blendWeight, _bounds.x, value->getFloat(0));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_POSITION_Y:
|
|
|
- _bounds.y = Curve::lerp(blendWeight, _bounds.y, value->getFloat(0));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE:
|
|
|
- _bounds.width = Curve::lerp(blendWeight, _bounds.width, value->getFloat(0));
|
|
|
- _bounds.height = Curve::lerp(blendWeight, _bounds.height, value->getFloat(1));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE_WIDTH:
|
|
|
- _bounds.width = Curve::lerp(blendWeight, _bounds.width, value->getFloat(0));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_SIZE_HEIGHT:
|
|
|
- _bounds.height = Curve::lerp(blendWeight, _bounds.height, value->getFloat(0));
|
|
|
- _dirty = true;
|
|
|
- break;
|
|
|
- case ANIMATE_OPACITY:
|
|
|
- _dirty = true;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_ACTIVE);
|
|
|
}
|
|
|
-
|
|
|
|
|
|
- Theme::Style::Overlay** Control::getOverlays(unsigned char overlayTypes, Theme::Style::Overlay** overlays)
|
|
|
+ if ((overlayTypes & DISABLED) == DISABLED)
|
|
|
{
|
|
|
- unsigned int index = 0;
|
|
|
- if ((overlayTypes & NORMAL) == NORMAL)
|
|
|
- {
|
|
|
- overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_NORMAL);
|
|
|
- }
|
|
|
+ overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_DISABLED);
|
|
|
+ }
|
|
|
|
|
|
- if ((overlayTypes & FOCUS) == FOCUS)
|
|
|
- {
|
|
|
- overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_FOCUS);
|
|
|
- }
|
|
|
+ return overlays;
|
|
|
+}
|
|
|
|
|
|
- if ((overlayTypes & ACTIVE) == ACTIVE)
|
|
|
- {
|
|
|
- overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_ACTIVE);
|
|
|
- }
|
|
|
+Theme::Style::Overlay* Control::getOverlay(State state) const
|
|
|
+{
|
|
|
+ switch(state)
|
|
|
+ {
|
|
|
+ case Control::NORMAL:
|
|
|
+ return _style->getOverlay(Theme::Style::OVERLAY_NORMAL);
|
|
|
+ case Control::FOCUS:
|
|
|
+ return _style->getOverlay(Theme::Style::OVERLAY_FOCUS);
|
|
|
+ case Control::ACTIVE:
|
|
|
+ return _style->getOverlay(Theme::Style::OVERLAY_ACTIVE);
|
|
|
+ case Control::DISABLED:
|
|
|
+ return _style->getOverlay(Theme::Style::OVERLAY_DISABLED);
|
|
|
+ default:
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- if ((overlayTypes & DISABLED) == DISABLED)
|
|
|
- {
|
|
|
- overlays[index++] = _style->getOverlay(Theme::Style::OVERLAY_DISABLED);
|
|
|
- }
|
|
|
+void Control::overrideStyle()
|
|
|
+{
|
|
|
+ if (_styleOverridden)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- return overlays;
|
|
|
+ // Copy the style.
|
|
|
+ WARN_VARG("%d", sizeof(Theme::Style::Overlay));
|
|
|
+ _style = new Theme::Style(*_style);
|
|
|
+ _styleOverridden = true;
|
|
|
+}
|
|
|
+
|
|
|
+void Control::overrideThemedProperties(Properties* properties, unsigned char states)
|
|
|
+{
|
|
|
+ Theme::ImageList* imageList = NULL;
|
|
|
+ Theme::ThemeImage* cursor = NULL;
|
|
|
+ Theme::Skin* skin = NULL;
|
|
|
+ _style->_theme->lookUpSprites(properties, &imageList, &cursor, &skin);
|
|
|
+
|
|
|
+ if (imageList)
|
|
|
+ {
|
|
|
+ setImageList(imageList, states);
|
|
|
}
|
|
|
|
|
|
- Theme::Style::Overlay* Control::getOverlay(State state) const
|
|
|
+ if (cursor)
|
|
|
{
|
|
|
- switch(state)
|
|
|
- {
|
|
|
- case Control::NORMAL:
|
|
|
- return _style->getOverlay(Theme::Style::OVERLAY_NORMAL);
|
|
|
- case Control::FOCUS:
|
|
|
- return _style->getOverlay(Theme::Style::OVERLAY_FOCUS);
|
|
|
- case Control::ACTIVE:
|
|
|
- return _style->getOverlay(Theme::Style::OVERLAY_ACTIVE);
|
|
|
- case Control::DISABLED:
|
|
|
- return _style->getOverlay(Theme::Style::OVERLAY_DISABLED);
|
|
|
- default:
|
|
|
- return NULL;
|
|
|
- }
|
|
|
+ setCursor(cursor, states);
|
|
|
}
|
|
|
|
|
|
- void Control::overrideStyle()
|
|
|
+ if (skin)
|
|
|
{
|
|
|
- if (_styleOverridden)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ setSkin(skin, states);
|
|
|
+ }
|
|
|
|
|
|
- // Copy the style.
|
|
|
- WARN_VARG("%d", sizeof(Theme::Style::Overlay));
|
|
|
- _style = new Theme::Style(*_style);
|
|
|
- _styleOverridden = true;
|
|
|
+ if (properties->exists("font"))
|
|
|
+ {
|
|
|
+ Font* font = Font::create(properties->getString("font"));
|
|
|
+ setFont(font, states);
|
|
|
+ font->release();
|
|
|
}
|
|
|
|
|
|
- void Control::overrideThemedProperties(Properties* properties, unsigned char states)
|
|
|
+ if (properties->exists("fontSize"))
|
|
|
{
|
|
|
- Theme::ImageList* imageList = NULL;
|
|
|
- Theme::ThemeImage* cursor = NULL;
|
|
|
- Theme::Skin* skin = NULL;
|
|
|
- _style->_theme->lookUpSprites(properties, &imageList, &cursor, &skin);
|
|
|
+ setFontSize(properties->getInt("fontSize"), states);
|
|
|
+ }
|
|
|
|
|
|
- if (imageList)
|
|
|
- {
|
|
|
- setImageList(imageList, states);
|
|
|
- }
|
|
|
+ if (properties->exists("textColor"))
|
|
|
+ {
|
|
|
+ Vector4 textColor(0, 0, 0, 1);
|
|
|
+ properties->getColor("textColor", &textColor);
|
|
|
+ setTextColor(textColor, states);
|
|
|
+ }
|
|
|
|
|
|
- if (cursor)
|
|
|
- {
|
|
|
- setCursor(cursor, states);
|
|
|
- }
|
|
|
+ if (properties->exists("textAlignment"))
|
|
|
+ {
|
|
|
+ setTextAlignment(Font::getJustify(properties->getString("textAlignment")), states);
|
|
|
+ }
|
|
|
|
|
|
- if (skin)
|
|
|
- {
|
|
|
- setSkin(skin, states);
|
|
|
- }
|
|
|
+ if (properties->exists("rightToLeft"))
|
|
|
+ {
|
|
|
+ setTextRightToLeft(properties->getBool("rightToLeft"), states);
|
|
|
+ }
|
|
|
|
|
|
- if (properties->exists("font"))
|
|
|
- {
|
|
|
- Font* font = Font::create(properties->getString("font"));
|
|
|
- setFont(font, states);
|
|
|
- font->release();
|
|
|
- }
|
|
|
+ if (properties->exists("opacity"))
|
|
|
+ {
|
|
|
+ setOpacity(properties->getFloat("opacity"), states);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- if (properties->exists("fontSize"))
|
|
|
- {
|
|
|
- setFontSize(properties->getInt("fontSize"), states);
|
|
|
- }
|
|
|
+void Control::setImageList(Theme::ImageList* imageList, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- if (properties->exists("textColor"))
|
|
|
- {
|
|
|
- Vector4 textColor(0, 0, 0, 1);
|
|
|
- properties->getColor("textColor", &textColor);
|
|
|
- setTextColor(textColor, states);
|
|
|
- }
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
+ {
|
|
|
+ overlays[i]->setImageList(imageList);
|
|
|
+ }
|
|
|
|
|
|
- if (properties->exists("textAlignment"))
|
|
|
- {
|
|
|
- setTextAlignment(Font::getJustify(properties->getString("textAlignment")), states);
|
|
|
- }
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- if (properties->exists("rightToLeft"))
|
|
|
- {
|
|
|
- setTextRightToLeft(properties->getBool("rightToLeft"), states);
|
|
|
- }
|
|
|
+void Control::setCursor(Theme::ThemeImage* cursor, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- if (properties->exists("opacity"))
|
|
|
- {
|
|
|
- setOpacity(properties->getFloat("opacity"), states);
|
|
|
- }
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
+ {
|
|
|
+ overlays[i]->setCursor(cursor);
|
|
|
}
|
|
|
|
|
|
- void Control::setImageList(Theme::ImageList* imageList, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setImageList(imageList);
|
|
|
- }
|
|
|
+void Control::setSkin(Theme::Skin* skin, unsigned char states)
|
|
|
+{
|
|
|
+ overrideStyle();
|
|
|
+ Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
+ getOverlays(states, overlays);
|
|
|
|
|
|
- _dirty = true;
|
|
|
+ for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
+ {
|
|
|
+ overlays[i]->setSkin(skin);
|
|
|
}
|
|
|
|
|
|
- void Control::setCursor(Theme::ThemeImage* cursor, unsigned char states)
|
|
|
- {
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
+ _dirty = true;
|
|
|
+}
|
|
|
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setCursor(cursor);
|
|
|
- }
|
|
|
+Theme::Skin* Control::getSkin(State state)
|
|
|
+{
|
|
|
+ return getOverlay(state)->getSkin();
|
|
|
+}
|
|
|
|
|
|
- _dirty = true;
|
|
|
+Control::Alignment Control::getAlignment(const char* alignment)
|
|
|
+{
|
|
|
+ if (!alignment)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_TOP_LEFT;
|
|
|
}
|
|
|
|
|
|
- void Control::setSkin(Theme::Skin* skin, unsigned char states)
|
|
|
+ if (strcmp(alignment, "ALIGN_LEFT") == 0)
|
|
|
{
|
|
|
- overrideStyle();
|
|
|
- Theme::Style::Overlay* overlays[Theme::Style::OVERLAY_MAX] = { 0 };
|
|
|
- getOverlays(states, overlays);
|
|
|
-
|
|
|
- for (int i = 0; i < Theme::Style::OVERLAY_MAX - 1 && overlays[i]; ++i)
|
|
|
- {
|
|
|
- overlays[i]->setSkin(skin);
|
|
|
- }
|
|
|
-
|
|
|
- _dirty = true;
|
|
|
+ return Control::ALIGN_LEFT;
|
|
|
}
|
|
|
-
|
|
|
- Theme::Skin* Control::getSkin(State state)
|
|
|
+ else if (strcmp(alignment, "ALIGN_HCENTER") == 0)
|
|
|
{
|
|
|
- return getOverlay(state)->getSkin();
|
|
|
+ return Control::ALIGN_HCENTER;
|
|
|
}
|
|
|
-
|
|
|
- Control::Alignment Control::getAlignment(const char* alignment)
|
|
|
+ else if (strcmp(alignment, "ALIGN_RIGHT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_RIGHT;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_TOP") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_TOP;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_VCENTER") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_VCENTER;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_BOTTOM") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_BOTTOM;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_TOP_LEFT") == 0)
|
|
|
{
|
|
|
- if (!alignment)
|
|
|
- {
|
|
|
- return Control::ALIGN_TOP_LEFT;
|
|
|
- }
|
|
|
-
|
|
|
- if (strcmp(alignment, "ALIGN_LEFT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_LEFT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_HCENTER") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_HCENTER;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_RIGHT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_RIGHT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_TOP") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_TOP;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_VCENTER") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_VCENTER;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_BOTTOM") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_BOTTOM;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_TOP_LEFT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_TOP_LEFT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_VCENTER_LEFT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_VCENTER_LEFT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_BOTTOM_LEFT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_BOTTOM_LEFT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_TOP_HCENTER") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_TOP_HCENTER;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_VCENTER_HCENTER") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_VCENTER_HCENTER;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_BOTTOM_HCENTER") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_BOTTOM_HCENTER;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_TOP_RIGHT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_TOP_RIGHT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_VCENTER_RIGHT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_VCENTER_RIGHT;
|
|
|
- }
|
|
|
- else if (strcmp(alignment, "ALIGN_BOTTOM_RIGHT") == 0)
|
|
|
- {
|
|
|
- return Control::ALIGN_BOTTOM_RIGHT;
|
|
|
- }
|
|
|
-
|
|
|
- // Default.
|
|
|
return Control::ALIGN_TOP_LEFT;
|
|
|
}
|
|
|
+ else if (strcmp(alignment, "ALIGN_VCENTER_LEFT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_VCENTER_LEFT;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_BOTTOM_LEFT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_BOTTOM_LEFT;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_TOP_HCENTER") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_TOP_HCENTER;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_VCENTER_HCENTER") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_VCENTER_HCENTER;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_BOTTOM_HCENTER") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_BOTTOM_HCENTER;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_TOP_RIGHT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_TOP_RIGHT;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_VCENTER_RIGHT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_VCENTER_RIGHT;
|
|
|
+ }
|
|
|
+ else if (strcmp(alignment, "ALIGN_BOTTOM_RIGHT") == 0)
|
|
|
+ {
|
|
|
+ return Control::ALIGN_BOTTOM_RIGHT;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Default.
|
|
|
+ return Control::ALIGN_TOP_LEFT;
|
|
|
+}
|
|
|
+
|
|
|
}
|