Back with clickable button.
This commit is contained in:
parent
3e53bd9e00
commit
70891ce7b4
20 changed files with 107 additions and 50 deletions
|
@ -120,9 +120,10 @@ void Window::doPaint(mt::Screen* screen)
|
|||
{
|
||||
mPlatformWindow->beforePaint(screen);
|
||||
|
||||
if (mScene && mScene->getRootNode()->getNumChildren() == 0)
|
||||
auto scene = getScene();
|
||||
if (scene->getRootNode()->getNumChildren() == 0)
|
||||
{
|
||||
mScene->getRootNode()->addChild(mWidget->getRootNode());
|
||||
scene->getRootNode()->addChild(mWidget->getRootNode());
|
||||
}
|
||||
|
||||
mDrawingContext->paint();
|
||||
|
@ -139,4 +140,9 @@ void Window::clear()
|
|||
}
|
||||
}
|
||||
|
||||
bool Window::isDirty() const
|
||||
{
|
||||
return mWidget->needsUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
|
||||
void setSize(unsigned width, unsigned height) override;
|
||||
|
||||
bool isDirty() const;
|
||||
|
||||
private:
|
||||
WidgetPtr mWidget {nullptr};
|
||||
IPlatformWindowPtr mPlatformWindow {nullptr};
|
||||
|
|
|
@ -15,7 +15,7 @@ Button::Button()
|
|||
mClickedColor(Color(180, 180, 180)),
|
||||
mClickFunc()
|
||||
{
|
||||
|
||||
mName = "Button";
|
||||
}
|
||||
|
||||
std::unique_ptr<Button> Button::Create()
|
||||
|
@ -73,6 +73,8 @@ void Button::updateLabel(const PaintEvent* event)
|
|||
if (!mTextNode)
|
||||
{
|
||||
mTextNode = TextNode::Create(mLabel, middle);
|
||||
mTextNode->setName(mName + "_TextNode");
|
||||
mTextNode->setContent(mLabel);
|
||||
mRootNode->addChild(mTextNode.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ HorizontalSpacer::HorizontalSpacer()
|
|||
: Widget(),
|
||||
mScales()
|
||||
{
|
||||
|
||||
mName = "HorizontalSpacer";
|
||||
}
|
||||
|
||||
std::unique_ptr<HorizontalSpacer> HorizontalSpacer::Create()
|
||||
|
|
|
@ -26,7 +26,7 @@ Widget::Widget()
|
|||
mBorderColor(Color(0, 0, 0)),
|
||||
mVisible(true)
|
||||
{
|
||||
|
||||
mName = "Widget";
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
|
@ -111,7 +111,7 @@ void Widget::setBackgroundColor(const Color& color)
|
|||
{
|
||||
if (mBackgroundColor != color)
|
||||
{
|
||||
mBackgroundColor = std::move(color);
|
||||
mBackgroundColor = color;
|
||||
mMaterialDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,8 @@ void Widget::onPaintEvent(const PaintEvent* event)
|
|||
|
||||
if (isDirty())
|
||||
{
|
||||
mRootNode->setName(mName);
|
||||
|
||||
doPaint(event);
|
||||
|
||||
mTransformDirty = false;
|
||||
|
@ -284,6 +286,8 @@ void Widget::updateBackground(const PaintEvent* event)
|
|||
|
||||
if (!mBackgroundNode)
|
||||
{
|
||||
mBackgroundNode = std::make_unique<RectangleNode>(DiscretePoint(locX, locY), deltaX, deltaY);
|
||||
mBackgroundNode->setName(mName + "_BackgroundNode");
|
||||
mRootNode->addChild(mBackgroundNode.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class MouseEvent;
|
||||
class KeyboardEvent;
|
||||
|
@ -103,6 +104,13 @@ public:
|
|||
|
||||
void setVisible(bool visible);
|
||||
|
||||
void setName(const std::string& name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
bool needsUpdate() const;
|
||||
|
||||
protected:
|
||||
virtual bool onMyKeyboardEvent(const KeyboardEvent* event);
|
||||
|
||||
|
@ -114,11 +122,6 @@ protected:
|
|||
|
||||
virtual void updateChildLocations();
|
||||
|
||||
void addMyLayers();
|
||||
|
||||
bool needsUpdate() const;
|
||||
|
||||
protected:
|
||||
virtual bool isDirty() const;
|
||||
|
||||
DiscretePoint mLocation;
|
||||
|
@ -139,6 +142,7 @@ protected:
|
|||
bool mMaterialDirty{true};
|
||||
bool mVisibilityDirty{true};
|
||||
|
||||
std::string mName;
|
||||
std::vector<TransformNode*> mPendingChildNodes;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue