Initial popup window.
This commit is contained in:
parent
f16dd7c0d9
commit
70220fc6e9
22 changed files with 253 additions and 15 deletions
|
@ -10,6 +10,8 @@
|
|||
#include "TransformNode.h"
|
||||
#include "RootNode.h"
|
||||
|
||||
#include "Window.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
|
@ -41,6 +43,8 @@ std::unique_ptr<Widget> Widget::Create()
|
|||
|
||||
void Widget::addWidget(WidgetUPtr widget)
|
||||
{
|
||||
widget->setParent(this);
|
||||
|
||||
mPendingChildNodes.push_back(widget->getRootNode());
|
||||
mChildren.push_back(std::move(widget));
|
||||
}
|
||||
|
@ -99,6 +103,16 @@ void Widget::setPadding(const BoundaryOffset& padding)
|
|||
|
||||
void Widget::setBounds(unsigned width, unsigned height)
|
||||
{
|
||||
if (mSize.mMaxWidth > 0 && width > mSize.mMaxWidth)
|
||||
{
|
||||
width = mSize.mMaxWidth;
|
||||
}
|
||||
|
||||
if (mSize.mMaxHeight > 0 && height > mSize.mMaxHeight)
|
||||
{
|
||||
height = mSize.mMaxHeight;
|
||||
}
|
||||
|
||||
if (width != mSize.mWidth || height != mSize.mHeight)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
|
@ -161,6 +175,15 @@ bool Widget::needsUpdate() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Widget::setMaxWidth(unsigned maxWidth)
|
||||
{
|
||||
if (mSize.mMaxWidth != maxWidth)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mSize.mMaxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::doPaint(const PaintEvent* event)
|
||||
{
|
||||
updateBackground(event);
|
||||
|
@ -319,3 +342,51 @@ void Widget::updateBackground(const PaintEvent* event)
|
|||
mBackgroundNode->setIsVisible(mVisible);
|
||||
}
|
||||
}
|
||||
|
||||
mt::Window* Widget::getTopLevelWindow() const
|
||||
{
|
||||
if(mWindow)
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
std::cout << "I am " << getName() << std::endl;
|
||||
|
||||
auto lastParent = mParent;
|
||||
auto nextParent = mParent;
|
||||
while(nextParent)
|
||||
{
|
||||
lastParent = nextParent;
|
||||
nextParent = lastParent->getParent();
|
||||
std::cout << "Checking if " << lastParent->getName() << std::endl;
|
||||
if (nextParent)
|
||||
{
|
||||
std::cout << "Next is " << nextParent->getName() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "no next" << std::endl;
|
||||
}
|
||||
}
|
||||
return lastParent->getTopLevelWindow();
|
||||
}
|
||||
|
||||
Widget* Widget::getParent() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
mt::Window* Widget::getWindow() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
|
||||
void Widget::setParent(Widget* parent)
|
||||
{
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
void Widget::setWindow(mt::Window* window)
|
||||
{
|
||||
mWindow = window;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue