UI tweaks

This commit is contained in:
Eduardo Bart
2012-04-30 13:40:12 -03:00
parent 3f689e0edf
commit beaba25af1
19 changed files with 154 additions and 80 deletions

View File

@@ -72,6 +72,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
g_lua.bindClassMemberFunction<UIWidget>("unlockChild", &UIWidget::unlockChild);
g_lua.bindClassMemberFunction<UIWidget>("mergeStyle", &UIWidget::mergeStyle);
g_lua.bindClassMemberFunction<UIWidget>("applyStyle", &UIWidget::applyStyle);
g_lua.bindClassMemberFunction<UIWidget>("addAnchor", &UIWidget::addAnchor);
g_lua.bindClassMemberFunction<UIWidget>("removeAnchor", &UIWidget::removeAnchor);

View File

@@ -101,8 +101,10 @@ bool UIGridLayout::internalUpdate()
Point virtualPos = Point(column * (m_cellSize.width() + cellSpacing), line * (m_cellSize.height() + cellSpacing));
preferredHeight = virtualPos.y + m_cellSize.height();
Point pos = topLeft + virtualPos - parentWidget->getVirtualOffset();
Rect dest = Rect(pos, m_cellSize);
dest.expand(-widget->getMarginTop(), -widget->getMarginRight(), -widget->getMarginBottom(), -widget->getMarginLeft());
if(widget->setRect(Rect(pos, m_cellSize)))
if(widget->setRect(dest))
changed = true;
index++;

View File

@@ -458,6 +458,13 @@ void UIWidget::unlockChild(const UIWidgetPtr& child)
}
}
void UIWidget::mergeStyle(const OTMLNodePtr& styleNode)
{
applyStyle(styleNode);
m_style->merge(styleNode);
updateStyle();
}
void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
{
if(m_destroyed)

View File

@@ -90,6 +90,7 @@ public:
void moveChildToIndex(const UIWidgetPtr& child, int index);
void lockChild(const UIWidgetPtr& child);
void unlockChild(const UIWidgetPtr& child);
void mergeStyle(const OTMLNodePtr& styleNode);
void applyStyle(const OTMLNodePtr& styleNode);
void addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
void removeAnchor(Fw::AnchorEdge anchoredEdge);

View File

@@ -43,7 +43,7 @@ void UIWidget::updateText()
// update rect size
if(!m_rect.isValid() || m_textAutoResize) {
Size textBoxSize = getTextSize();
textBoxSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.left);
textBoxSize += Size(m_padding.left + m_padding.right, m_padding.top + m_padding.bottom);
Size size = getSize();
if(size.width() <= 0 || (m_textAutoResize && !m_textWrap))
size.setWidth(textBoxSize.width());

View File

@@ -38,7 +38,6 @@ void UIItem::drawSelf()
Rect drawRect = getClippingRect();
Point dest = drawRect.topLeft();
float scaleFactor = std::min(drawRect.width() / (float)m_item->getExactSize(), drawRect.height() / (float)m_item->getExactSize());
dest += (1 - scaleFactor)*32;
dest += m_item->getDisplacement() * scaleFactor;
g_painter->setColor(Color::white);