mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
graphics fixes and improvements
This commit is contained in:
@@ -52,9 +52,9 @@ void UIManager::terminate()
|
||||
m_pressedWidget = nullptr;
|
||||
}
|
||||
|
||||
void UIManager::render(bool foregroundPane)
|
||||
void UIManager::render(Fw::DrawPane drawPane)
|
||||
{
|
||||
m_rootWidget->draw(m_rootWidget->getRect(), foregroundPane);
|
||||
m_rootWidget->draw(m_rootWidget->getRect(), drawPane);
|
||||
}
|
||||
|
||||
void UIManager::resize(const Size& size)
|
||||
|
@@ -33,7 +33,7 @@ public:
|
||||
void init();
|
||||
void terminate();
|
||||
|
||||
void render(bool foregroundPane);
|
||||
void render(Fw::DrawPane drawPane);
|
||||
void resize(const Size& size);
|
||||
void inputEvent(const InputEvent& event);
|
||||
|
||||
|
@@ -41,9 +41,9 @@ UITextEdit::UITextEdit()
|
||||
blinkCursor();
|
||||
}
|
||||
|
||||
void UITextEdit::drawSelf(bool foregroundPane)
|
||||
void UITextEdit::drawSelf(Fw::DrawPane drawPane)
|
||||
{
|
||||
if(!foregroundPane)
|
||||
if((drawPane & Fw::ForegroundPane) == 0)
|
||||
return;
|
||||
|
||||
drawBackground(m_rect);
|
||||
|
@@ -30,7 +30,7 @@ class UITextEdit : public UIWidget
|
||||
public:
|
||||
UITextEdit();
|
||||
|
||||
void drawSelf(bool foregroundPane);
|
||||
void drawSelf(Fw::DrawPane drawPane);
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
@@ -52,27 +52,27 @@ UIWidget::~UIWidget()
|
||||
#endif
|
||||
}
|
||||
|
||||
void UIWidget::draw(const Rect& visibleRect, bool foregroundPane)
|
||||
void UIWidget::draw(const Rect& visibleRect, Fw::DrawPane drawPane)
|
||||
{
|
||||
if(m_clipping)
|
||||
g_painter->setClipRect(visibleRect);
|
||||
|
||||
drawSelf(foregroundPane);
|
||||
drawSelf(drawPane);
|
||||
|
||||
if(m_children.size() > 0) {
|
||||
if(m_clipping)
|
||||
g_painter->setClipRect(visibleRect.intersection(getPaddingRect()));
|
||||
|
||||
drawChildren(visibleRect, foregroundPane);
|
||||
drawChildren(visibleRect, drawPane);
|
||||
}
|
||||
|
||||
if(m_clipping)
|
||||
g_painter->resetClipRect();
|
||||
}
|
||||
|
||||
void UIWidget::drawSelf(bool foregroundPane)
|
||||
void UIWidget::drawSelf(Fw::DrawPane drawPane)
|
||||
{
|
||||
if(!foregroundPane)
|
||||
if((drawPane & Fw::ForegroundPane) == 0)
|
||||
return;
|
||||
|
||||
// draw style components in order
|
||||
@@ -88,7 +88,7 @@ void UIWidget::drawSelf(bool foregroundPane)
|
||||
drawText(m_rect);
|
||||
}
|
||||
|
||||
void UIWidget::drawChildren(const Rect& visibleRect, bool foregroundPane)
|
||||
void UIWidget::drawChildren(const Rect& visibleRect, Fw::DrawPane drawPane)
|
||||
{
|
||||
// draw children
|
||||
for(const UIWidgetPtr& child : m_children) {
|
||||
@@ -107,10 +107,10 @@ void UIWidget::drawChildren(const Rect& visibleRect, bool foregroundPane)
|
||||
if(child->getOpacity() < oldOpacity)
|
||||
g_painter->setOpacity(child->getOpacity());
|
||||
|
||||
child->draw(childVisibleRect, foregroundPane);
|
||||
child->draw(childVisibleRect, drawPane);
|
||||
|
||||
// debug draw box
|
||||
if(foregroundPane && g_ui.isDrawingDebugBoxes()) {
|
||||
if(g_ui.isDrawingDebugBoxes() && drawPane & Fw::ForegroundPane) {
|
||||
g_painter->setColor(Color::green);
|
||||
g_painter->drawBoundingRect(child->getRect());
|
||||
}
|
||||
@@ -497,7 +497,10 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||
callLuaField("onStyleApply", styleNode->tag(), styleNode);
|
||||
|
||||
if(m_firstOnStyle) {
|
||||
callLuaField("onSetup");
|
||||
auto self = asUIWidget();
|
||||
g_eventDispatcher.addEvent([self] {
|
||||
self->callLuaField("onSetup");
|
||||
});
|
||||
// always focus new child
|
||||
if(isFocusable() && isExplicitlyVisible() && isExplicitlyEnabled())
|
||||
focus();
|
||||
|
@@ -52,9 +52,9 @@ public:
|
||||
virtual ~UIWidget();
|
||||
|
||||
protected:
|
||||
virtual void draw(const Rect& visibleRect, bool foregroundPane);
|
||||
virtual void drawSelf(bool foregroundPane);
|
||||
virtual void drawChildren(const Rect& visibleRect, bool foregroundPane);
|
||||
virtual void draw(const Rect& visibleRect, Fw::DrawPane drawPane);
|
||||
virtual void drawSelf(Fw::DrawPane drawPane);
|
||||
virtual void drawChildren(const Rect& visibleRect, Fw::DrawPane drawPane);
|
||||
|
||||
friend class UIManager;
|
||||
|
||||
|
Reference in New Issue
Block a user