graphics fixes and improvements

This commit is contained in:
Eduardo Bart
2012-06-08 13:58:08 -03:00
parent 4f9ca15ef0
commit 1a7f2a44fc
39 changed files with 450 additions and 317 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -30,7 +30,7 @@ class UITextEdit : public UIWidget
public:
UITextEdit();
void drawSelf(bool foregroundPane);
void drawSelf(Fw::DrawPane drawPane);
private:
void update();

View File

@@ -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();

View File

@@ -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;