mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
UI tweaks
This commit is contained in:
@@ -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);
|
||||
|
@@ -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++;
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user