add ui padding

This commit is contained in:
Eduardo Bart 2012-01-09 16:45:28 -02:00
parent ada5c031d6
commit 3230095cea
17 changed files with 126 additions and 59 deletions

View File

@ -3,3 +3,8 @@ function dumpWidgets()
print(rootWidget:getChildByIndex(i):getId()) print(rootWidget:getChildByIndex(i):getId())
end end
end end
function drawDebugBoxes(enable)
if enable == nil then enable = true end
g_ui.setDebugBoxesDrawing(enable)
end

View File

@ -82,29 +82,11 @@ local function completeCommand()
end end
end end
local function onCommandLineKeyPress(widget, keyCode, keyText, keyboardModifiers) local function doCommand()
if keyboardModifiers == KeyboardNoModifier then
-- execute current command
if keyCode == KeyReturn or keyCode == KeyEnter then
local currentCommand = commandLineEdit:getText() local currentCommand = commandLineEdit:getText()
Terminal.executeCommand(currentCommand) Terminal.executeCommand(currentCommand)
commandLineEdit:clearText() commandLineEdit:clearText()
return true return true
-- navigate history up
elseif keyCode == KeyUp then
navigateCommand(1)
return true
-- navigate history down
elseif keyCode == KeyDown then
navigateCommand(-1)
return true
-- complete command
elseif keyCode == KeyTab then
completeCommand()
return true
end
end
return false
end end
local function onLog(level, message, time) local function onLog(level, message, time)
@ -128,7 +110,11 @@ function Terminal.init()
Hotkeys.bind('Ctrl+T', Terminal.toggle) Hotkeys.bind('Ctrl+T', Terminal.toggle)
commandLineEdit = terminalWidget:getChildById('commandLineEdit') commandLineEdit = terminalWidget:getChildById('commandLineEdit')
connect(commandLineEdit, { onKeyPress = onCommandLineKeyPress }) Hotkeys.bind('Up', function() navigateCommand(1) end, commandLineEdit)
Hotkeys.bind('Down', function() navigateCommand(-1) end, commandLineEdit)
Hotkeys.bind('Tab', completeCommand, commandLineEdit)
Hotkeys.bind('Enter', doCommand, commandLineEdit)
Hotkeys.bind('Return', doCommand, commandLineEdit)
terminalBuffer = terminalWidget:getChildById('terminalBuffer') terminalBuffer = terminalWidget:getChildById('terminalBuffer')
Logger.setOnLog(onLog) Logger.setOnLog(onLog)
@ -171,7 +157,7 @@ function Terminal.addLine(text, color)
local label = createWidget('TerminalLabel', terminalBuffer) local label = createWidget('TerminalLabel', terminalBuffer)
label:setId('terminalLabel' .. numLines) label:setId('terminalLabel' .. numLines)
label:setText(text) label:setText(text)
label:setForegroundColor(color) label:setColor(color)
-- delete old lines if needed -- delete old lines if needed
if numLines > MaxLogLines then if numLines > MaxLogLines then
@ -182,6 +168,7 @@ function Terminal.addLine(text, color)
end end
function Terminal.executeCommand(command) function Terminal.executeCommand(command)
if command == nil or #command == 0 then return end
-- detect and convert commands with simple syntax -- detect and convert commands with simple syntax
local realCommand local realCommand
if commandEnv[command] then if commandEnv[command] then

View File

@ -41,7 +41,7 @@ function Console.addText(text, color)
local label = createWidget('ConsoleLabel', consoleBuffer) local label = createWidget('ConsoleLabel', consoleBuffer)
label:setText(text) label:setText(text)
label:setForegroundColor(color) label:setColor(color)
end end
-- hooked events -- hooked events

View File

@ -17,10 +17,10 @@ SkillValueLabel < GameLabel
id: value id: value
font: verdana-11px-monochrome font: verdana-11px-monochrome
text-align: topright text-align: topright
width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: prev.left
SkillPercentPanel < UIProgressBar SkillPercentPanel < UIProgressBar
id: percent id: percent

View File

@ -46,7 +46,7 @@ local function displayMessage(msgtype, msg, time)
label:setVisible(true) label:setVisible(true)
label:setText(msg) label:setText(msg)
label:setStyle(style) label:setStyle(style)
label:setForegroundColor(msgtype.color) label:setColor(msgtype.color)
if not time then if not time then
time = math.max(#msg * 75, 3000) time = math.max(#msg * 75, 3000)

View File

@ -37,9 +37,9 @@ function Game.onAddVip(id, name, online)
label:setText(name) label:setText(name)
if online then if online then
label:setForegroundColor('#00ff00') label:setColor('#00ff00')
else else
label:setForegroundColor('#ff0000') label:setColor('#ff0000')
end end
label.vipOnline = online label.vipOnline = online
@ -50,9 +50,9 @@ function Game.onVipStateChange(id, online)
local label = vipList:getChildById('vip' .. id) local label = vipList:getChildById('vip' .. id)
if online then if online then
label:setForegroundColor('#00ff00') label:setColor('#00ff00')
else else
label:setForegroundColor('#ff0000') label:setColor('#ff0000')
end end
label.vipOnline = online label.vipOnline = online

View File

@ -67,7 +67,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIWidget>("setIcon", &UIWidget::setIcon); g_lua.bindClassMemberFunction<UIWidget>("setIcon", &UIWidget::setIcon);
g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity); g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity);
g_lua.bindClassMemberFunction<UIWidget>("setBackgroundColor", &UIWidget::setBackgroundColor); g_lua.bindClassMemberFunction<UIWidget>("setBackgroundColor", &UIWidget::setBackgroundColor);
g_lua.bindClassMemberFunction<UIWidget>("setForegroundColor", &UIWidget::setForegroundColor); g_lua.bindClassMemberFunction<UIWidget>("setColor", &UIWidget::setColor);
g_lua.bindClassMemberFunction<UIWidget>("setMarginTop", &UIWidget::setMarginTop); g_lua.bindClassMemberFunction<UIWidget>("setMarginTop", &UIWidget::setMarginTop);
g_lua.bindClassMemberFunction<UIWidget>("setMarginRight", &UIWidget::setMarginRight); g_lua.bindClassMemberFunction<UIWidget>("setMarginRight", &UIWidget::setMarginRight);
g_lua.bindClassMemberFunction<UIWidget>("setMarginBottom", &UIWidget::setMarginBottom); g_lua.bindClassMemberFunction<UIWidget>("setMarginBottom", &UIWidget::setMarginBottom);
@ -128,7 +128,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIWidget>("getY", &UIWidget::getY); g_lua.bindClassMemberFunction<UIWidget>("getY", &UIWidget::getY);
g_lua.bindClassMemberFunction<UIWidget>("getWidth", &UIWidget::getWidth); g_lua.bindClassMemberFunction<UIWidget>("getWidth", &UIWidget::getWidth);
g_lua.bindClassMemberFunction<UIWidget>("getHeight", &UIWidget::getHeight); g_lua.bindClassMemberFunction<UIWidget>("getHeight", &UIWidget::getHeight);
g_lua.bindClassMemberFunction<UIWidget>("getForegroundColor", &UIWidget::getForegroundColor); g_lua.bindClassMemberFunction<UIWidget>("getColor", &UIWidget::getColor);
g_lua.bindClassMemberFunction<UIWidget>("getBackgroundColor", &UIWidget::getBackgroundColor); g_lua.bindClassMemberFunction<UIWidget>("getBackgroundColor", &UIWidget::getBackgroundColor);
g_lua.bindClassMemberFunction<UIWidget>("getOpacity", &UIWidget::getOpacity); g_lua.bindClassMemberFunction<UIWidget>("getOpacity", &UIWidget::getOpacity);
g_lua.bindClassMemberFunction<UIWidget>("getMarginTop", &UIWidget::getMarginTop); g_lua.bindClassMemberFunction<UIWidget>("getMarginTop", &UIWidget::getMarginTop);
@ -297,6 +297,8 @@ void Application::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1));
g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2));
g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui));
g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1));
// FontManager // FontManager
g_lua.registerStaticClass("g_fonts"); g_lua.registerStaticClass("g_fonts");

View File

@ -87,6 +87,7 @@ public:
void addTop(T add) { y1 -= add; } void addTop(T add) { y1 -= add; }
void addRight(T add) { x2 += add; } void addRight(T add) { x2 += add; }
void addBottom(T add) { y2 += add; } void addBottom(T add) { y2 += add; }
void add(T top, T right, T bottom, T left) { x1 -= left; y1 -= top; x2 += right; y2 += bottom; }
void translate(T x, T y) { x1 += x; y1 += y; x2 += x; y2 += y; } void translate(T x, T y) { x1 += x; y1 += y; x2 += x; y2 += y; }
void translate(const TPoint<T> &p) { x1 += p.x; y1 += p.y; x2 += p.x; y2 += p.y; } void translate(const TPoint<T> &p) { x1 += p.x; y1 += p.y; x2 += p.x; y2 += p.y; }

View File

@ -122,25 +122,29 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
} }
// determine hooked widget edge point // determine hooked widget edge point
Rect hookedWidgetRect = hookedWidget->getRect();
if(hookedWidget == parentWidget)
hookedWidgetRect = parentWidget->getChildrenRect();
int point = 0; int point = 0;
switch(anchor.getHookedEdge()) { switch(anchor.getHookedEdge()) {
case Fw::AnchorLeft: case Fw::AnchorLeft:
point = hookedWidget->getRect().left(); point = hookedWidgetRect.left();
break; break;
case Fw::AnchorRight: case Fw::AnchorRight:
point = hookedWidget->getRect().right(); point = hookedWidgetRect.right();
break; break;
case Fw::AnchorTop: case Fw::AnchorTop:
point = hookedWidget->getRect().top(); point = hookedWidgetRect.top();
break; break;
case Fw::AnchorBottom: case Fw::AnchorBottom:
point = hookedWidget->getRect().bottom(); point = hookedWidgetRect.bottom();
break; break;
case Fw::AnchorHorizontalCenter: case Fw::AnchorHorizontalCenter:
point = hookedWidget->getRect().horizontalCenter(); point = hookedWidgetRect.horizontalCenter();
break; break;
case Fw::AnchorVerticalCenter: case Fw::AnchorVerticalCenter:
point = hookedWidget->getRect().verticalCenter(); point = hookedWidgetRect.verticalCenter();
break; break;
default: default:
// must never happens // must never happens

View File

@ -48,7 +48,7 @@ void UICheckBox::render()
if(m_text.length()) { if(m_text.length()) {
Rect textRect(m_rect); Rect textRect(m_rect);
textRect.setTopLeft(textRect.topLeft() + m_textOffset); textRect.setTopLeft(textRect.topLeft() + m_textOffset);
m_font->renderText(m_text, textRect, m_textAlign, m_foregroundColor); m_font->renderText(m_text, textRect, m_textAlign, m_color);
} }
} }

View File

@ -50,7 +50,7 @@ void UILineEdit::renderSelf()
int textLength = m_text.length(); int textLength = m_text.length();
const TexturePtr& texture = m_font->getTexture(); const TexturePtr& texture = m_font->getTexture();
g_painter.setColor(m_foregroundColor); g_painter.setColor(m_color);
for(int i=0;i<textLength;++i) for(int i=0;i<textLength;++i)
g_painter.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); g_painter.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);

View File

@ -47,6 +47,7 @@ public:
void setMouseReceiver(const UIWidgetPtr& widget) { m_mouseReceiver = widget; } void setMouseReceiver(const UIWidgetPtr& widget) { m_mouseReceiver = widget; }
void setKeyboardReceiver(const UIWidgetPtr& widget) { m_keyboardReceiver = widget; } void setKeyboardReceiver(const UIWidgetPtr& widget) { m_keyboardReceiver = widget; }
void setDebugBoxesDrawing(bool enabled) { m_drawDebugBoxes = enabled; }
void resetMouseReceiver() { m_mouseReceiver = m_rootWidget; } void resetMouseReceiver() { m_mouseReceiver = m_rootWidget; }
void resetKeyboardReceiver() { m_keyboardReceiver = m_rootWidget; } void resetKeyboardReceiver() { m_keyboardReceiver = m_rootWidget; }
UIWidgetPtr getMouseReceiver() { return m_mouseReceiver; } UIWidgetPtr getMouseReceiver() { return m_mouseReceiver; }
@ -55,12 +56,14 @@ public:
UIWidgetPtr getRootWidget() { return m_rootWidget; } UIWidgetPtr getRootWidget() { return m_rootWidget; }
bool isOnInputEvent() { return m_isOnInputEvent; } bool isOnInputEvent() { return m_isOnInputEvent; }
bool isDrawingDebugBoxes() { return m_drawDebugBoxes; }
private: private:
UIWidgetPtr m_rootWidget; UIWidgetPtr m_rootWidget;
UIWidgetPtr m_mouseReceiver; UIWidgetPtr m_mouseReceiver;
UIWidgetPtr m_keyboardReceiver; UIWidgetPtr m_keyboardReceiver;
bool m_isOnInputEvent; bool m_isOnInputEvent;
Boolean<false> m_drawDebugBoxes;
std::map<std::string, OTMLNodePtr> m_styles; std::map<std::string, OTMLNodePtr> m_styles;
}; };

View File

@ -35,7 +35,7 @@ void UIProgressBar::render()
{ {
UIWidget::render(); UIWidget::render();
g_painter.setColor(m_foregroundColor); g_painter.setColor(m_color);
g_painter.drawBoundingRect(m_rect, 1); g_painter.drawBoundingRect(m_rect, 1);
Rect fillRect = m_rect.expanded(-1); Rect fillRect = m_rect.expanded(-1);

View File

@ -82,7 +82,8 @@ void UIVerticalLayout::internalUpdate()
if(m_alignBottom) if(m_alignBottom)
std::reverse(widgets.begin(), widgets.end()); std::reverse(widgets.begin(), widgets.end());
Point pos = (m_alignBottom) ? parentWidget->getRect().bottomLeft() : parentWidget->getPos(); Rect childrenRect = parentWidget->getChildrenRect();
Point pos = (m_alignBottom) ? childrenRect.bottomLeft() : childrenRect.topLeft();
int prefferedHeight = 0; int prefferedHeight = 0;
int gap; int gap;
@ -98,12 +99,12 @@ void UIVerticalLayout::internalUpdate()
if(widget->isSizeFixed()) { if(widget->isSizeFixed()) {
// center it // center it
pos.x = parentWidget->getX() + (parentWidget->getWidth() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2; pos.x = childrenRect.left() + (childrenRect.width() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
pos.x = std::max(pos.x, parentWidget->getX()); pos.x = std::max(pos.x, parentWidget->getX());
} else { } else {
// expand width // expand width
size.setWidth(parentWidget->getWidth() - (widget->getMarginLeft() + widget->getMarginRight())); size.setWidth(childrenRect.width() - (widget->getMarginLeft() + widget->getMarginRight()));
pos.x = parentWidget->getX() + (parentWidget->getWidth() - size.width())/2; pos.x = childrenRect.left() + (childrenRect.width() - size.width())/2;
} }
widget->setRect(Rect(pos, size)); widget->setRect(Rect(pos, size));
@ -115,6 +116,7 @@ void UIVerticalLayout::internalUpdate()
} }
prefferedHeight -= m_spacing; prefferedHeight -= m_spacing;
prefferedHeight += parentWidget->getPaddingTop() + parentWidget->getPaddingBottom();
if(m_fitParent && prefferedHeight != parentWidget->getHeight()) { if(m_fitParent && prefferedHeight != parentWidget->getHeight()) {
// must set the preffered width later // must set the preffered width later

View File

@ -42,9 +42,10 @@ UIWidget::UIWidget()
m_font = g_fonts.getDefaultFont(); m_font = g_fonts.getDefaultFont();
m_opacity = 255; m_opacity = 255;
m_marginTop = m_marginRight = m_marginBottom = m_marginLeft = 0; m_marginTop = m_marginRight = m_marginBottom = m_marginLeft = 0;
m_paddingTop = m_paddingRight = m_paddingBottom = m_paddingLeft = 0;
//m_backgroundColor = Fw::alpha; //m_backgroundColor = Fw::alpha;
m_backgroundColor = Fw::white; m_backgroundColor = Fw::white;
m_foregroundColor = Fw::white; m_color = Fw::white;
m_textAlign = Fw::AlignCenter; m_textAlign = Fw::AlignCenter;
// generate an unique id, this is need because anchored layouts find widgets by id // generate an unique id, this is need because anchored layouts find widgets by id
@ -113,8 +114,10 @@ void UIWidget::renderChildren()
child->render(); child->render();
// debug draw box // debug draw box
//g_painter.setColor(Fw::green); if(g_ui.isDrawingDebugBoxes()) {
//g_painter.drawBoundingRect(child->getRect()); g_painter.setColor(Fw::green);
g_painter.drawBoundingRect(child->getRect());
}
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPos() + Point(2, 0), Fw::red); //g_fonts.getDefaultFont()->renderText(child->getId(), child->getPos() + Point(2, 0), Fw::red);
g_painter.setOpacity(oldOpacity); g_painter.setOpacity(oldOpacity);
@ -164,11 +167,11 @@ void UIWidget::drawIcon(const Rect& screenCoords)
void UIWidget::drawText(const Rect& screenCoords) void UIWidget::drawText(const Rect& screenCoords)
{ {
g_painter.setColor(m_foregroundColor); g_painter.setColor(m_color);
if(m_text.length() > 0 && m_foregroundColor.a() > 0) { if(m_text.length() > 0 && m_color.a() > 0) {
Rect textRect = screenCoords; Rect textRect = screenCoords;
textRect.translate(m_textOffset); textRect.translate(m_textOffset);
m_font->renderText(m_text, textRect, m_textAlign, m_foregroundColor); m_font->renderText(m_text, textRect, m_textAlign, m_color);
} }
} }
@ -403,6 +406,13 @@ bool UIWidget::hasChild(const UIWidgetPtr& child)
return false; return false;
} }
Rect UIWidget::getChildrenRect()
{
Rect rect = m_rect;
rect.add(-m_paddingTop, -m_paddingRight, -m_paddingBottom, -m_paddingLeft);
return rect;
}
UIWidgetPtr UIWidget::getRootParent() UIWidgetPtr UIWidget::getRootParent()
{ {
if(UIWidgetPtr parent = getParent()) if(UIWidgetPtr parent = getParent())
@ -1031,7 +1041,7 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
else if(node->tag() == "font") else if(node->tag() == "font")
setFont(node->value()); setFont(node->value());
else if(node->tag() == "color") else if(node->tag() == "color")
setForegroundColor(node->value<Color>()); setColor(node->value<Color>());
else if(node->tag() == "background-color") else if(node->tag() == "background-color")
setBackgroundColor(node->value<Color>()); setBackgroundColor(node->value<Color>());
else if(node->tag() == "opacity") else if(node->tag() == "opacity")
@ -1102,6 +1112,46 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
setMarginLeft(margin); setMarginLeft(margin);
} }
} }
else if(node->tag() == "padding-top")
setPaddingTop(node->value<int>());
else if(node->tag() == "padding-right")
setPaddingRight(node->value<int>());
else if(node->tag() == "padding-bottom")
setPaddingBottom(node->value<int>());
else if(node->tag() == "padding-left")
setPaddingLeft(node->value<int>());
else if(node->tag() == "padding") {
std::string paddingDesc = node->value();
std::vector<std::string> split;
boost::split(split, paddingDesc, boost::is_any_of(std::string(" ")));
if(split.size() == 4) {
setPaddingTop(Fw::safeCast<int>(split[0]));
setPaddingRight(Fw::safeCast<int>(split[1]));
setPaddingBottom(Fw::safeCast<int>(split[2]));
setPaddingLeft(Fw::safeCast<int>(split[3]));
} else if(split.size() == 3) {
int paddingTop = Fw::safeCast<int>(split[0]);
int paddingHorizontal = Fw::safeCast<int>(split[1]);
int paddingBottom = Fw::safeCast<int>(split[2]);
setPaddingTop(paddingTop);
setPaddingRight(paddingHorizontal);
setPaddingBottom(paddingBottom);
setPaddingLeft(paddingHorizontal);
} else if(split.size() == 2) {
int paddingVertical = Fw::safeCast<int>(split[0]);
int paddingHorizontal = Fw::safeCast<int>(split[1]);
setPaddingTop(paddingVertical);
setPaddingRight(paddingHorizontal);
setPaddingBottom(paddingVertical);
setPaddingLeft(paddingHorizontal);
} else if(split.size() == 1) {
int padding = Fw::safeCast<int>(split[0]);
setPaddingTop(padding);
setPaddingRight(padding);
setPaddingBottom(padding);
setPaddingLeft(padding);
}
}
// layouts // layouts
else if(node->tag() == "layout") { else if(node->tag() == "layout") {
std::string layoutType; std::string layoutType;

View File

@ -72,11 +72,15 @@ public:
void setIcon(const std::string& iconFile); void setIcon(const std::string& iconFile);
void setOpacity(int opacity) { m_opacity = opacity; } void setOpacity(int opacity) { m_opacity = opacity; }
void setBackgroundColor(const Color& color) { m_backgroundColor = color; } void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
void setForegroundColor(const Color& color) { m_foregroundColor = color; } void setColor(const Color& color) { m_color = color; }
void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); } void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); }
void setMarginRight(int margin) { m_marginRight = margin; updateParentLayout(); } void setMarginRight(int margin) { m_marginRight = margin; updateParentLayout(); }
void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); } void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); }
void setMarginLeft(int margin) { m_marginLeft = margin; updateParentLayout(); } void setMarginLeft(int margin) { m_marginLeft = margin; updateParentLayout(); }
void setPaddingTop(int padding) { m_paddingTop = padding; updateLayout(); }
void setPaddingRight(int padding) { m_paddingRight = padding; updateLayout(); }
void setPaddingBottom(int padding) { m_paddingBottom = padding; updateLayout(); }
void setPaddingLeft(int padding) { m_paddingLeft = padding; updateLayout(); }
void setText(const std::string& text); void setText(const std::string& text);
void setTextAlign(Fw::AlignmentFlag align) { m_textAlign = align; } void setTextAlign(Fw::AlignmentFlag align) { m_textAlign = align; }
void setTextOffset(const Point& offset) { m_textOffset = offset; } void setTextOffset(const Point& offset) { m_textOffset = offset; }
@ -133,17 +137,22 @@ public:
Point getPos() { return m_rect.topLeft(); } Point getPos() { return m_rect.topLeft(); }
Size getSize() { return m_rect.size(); } Size getSize() { return m_rect.size(); }
Rect getRect() { return m_rect; } Rect getRect() { return m_rect; }
Rect getChildrenRect();
int getX() { return m_rect.x(); } int getX() { return m_rect.x(); }
int getY() { return m_rect.y(); } int getY() { return m_rect.y(); }
int getWidth() { return m_rect.width(); } int getWidth() { return m_rect.width(); }
int getHeight() { return m_rect.height(); } int getHeight() { return m_rect.height(); }
Color getForegroundColor() { return m_foregroundColor; } Color getColor() { return m_color; }
Color getBackgroundColor() { return m_backgroundColor; } Color getBackgroundColor() { return m_backgroundColor; }
int getOpacity() { return m_opacity; } int getOpacity() { return m_opacity; }
int getMarginTop() { return m_marginTop; } int getMarginTop() { return m_marginTop; }
int getMarginRight() { return m_marginRight; } int getMarginRight() { return m_marginRight; }
int getMarginBottom() { return m_marginBottom; } int getMarginBottom() { return m_marginBottom; }
int getMarginLeft() { return m_marginLeft; } int getMarginLeft() { return m_marginLeft; }
int getPaddingTop() { return m_paddingTop; }
int getPaddingRight() { return m_paddingRight; }
int getPaddingBottom() { return m_paddingBottom; }
int getPaddingLeft() { return m_paddingLeft; }
std::string getText() { return m_text; } std::string getText() { return m_text; }
Fw::AlignmentFlag getTextAlign() { return m_textAlign; } Fw::AlignmentFlag getTextAlign() { return m_textAlign; }
Point getTextOffset() { return m_textOffset; } Point getTextOffset() { return m_textOffset; }
@ -244,13 +253,17 @@ protected:
TexturePtr m_icon; TexturePtr m_icon;
FontPtr m_font; FontPtr m_font;
Color m_backgroundColor; Color m_backgroundColor;
Color m_foregroundColor; Color m_color;
int m_states; int m_states;
int m_opacity; int m_opacity;
int m_marginTop; int m_marginTop;
int m_marginRight; int m_marginRight;
int m_marginBottom; int m_marginBottom;
int m_marginLeft; int m_marginLeft;
int m_paddingTop;
int m_paddingRight;
int m_paddingBottom;
int m_paddingLeft;
std::string m_text; std::string m_text;
Point m_textOffset; Point m_textOffset;
Fw::AlignmentFlag m_textAlign; Fw::AlignmentFlag m_textAlign;

View File

@ -53,7 +53,7 @@ void UIWindow::render()
headTextRect.addLeft(-m_headTextOffset.x); headTextRect.addLeft(-m_headTextOffset.x);
headTextRect.addRight(-m_headTextOffset.x); headTextRect.addRight(-m_headTextOffset.x);
} }
m_font->renderText(m_title, headTextRect, m_titleAlign, m_foregroundColor); m_font->renderText(m_title, headTextRect, m_titleAlign, m_color);
} }
void UIWindow::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) void UIWindow::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)