Skip to content

Commit

Permalink
Fix subwidget position of BlendishSubWidgetSharedContext stuff
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Oct 16, 2021
1 parent 27b70b1 commit 881027f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions opengl/Blendish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ void BlendishSubWidgetSharedContext::onDisplay()
pData->nvg.endFrame();
}

void BlendishSubWidgetSharedContext::onPositionChanged(const PositionChangedEvent& ev)
{
const int xOffset = ev.oldPos.getX() - ev.pos.getX();
const int yOffset = ev.oldPos.getY() - ev.pos.getY();

for (std::list<BlendishSubWidget*>::iterator it = pData->widgets.begin(); it != pData->widgets.end(); ++it)
{
BlendishSubWidget* const widget(*it);

Point<int> pos(widget->getMargin());
pos.moveBy(xOffset, yOffset);
widget->setMargin(pos);
}
}

// --------------------------------------------------------------------------------------------------------------------

struct BlendishSubWidget::ProtectedData {
Expand Down
1 change: 1 addition & 0 deletions opengl/Blendish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class BlendishSubWidgetSharedContext : public SubWidget

protected:
void onDisplay() override;
void onPositionChanged(const PositionChangedEvent& ev) override;

private:
struct PrivateData;
Expand Down

0 comments on commit 881027f

Please sign in to comment.