Initial color palette
This commit is contained in:
parent
947bf937fd
commit
3d37a7244b
8 changed files with 393 additions and 196 deletions
|
@ -18,10 +18,7 @@
|
|||
#include <iostream>
|
||||
|
||||
Widget::Widget()
|
||||
: mLocation(DiscretePoint(0, 0)),
|
||||
mSize({100, 0, 0, 100, 0, 0}),
|
||||
mPadding(),
|
||||
mMargin(),
|
||||
: BoxGeometry(),
|
||||
mRootNode(std::make_unique<TransformNode>()),
|
||||
mChildren(),
|
||||
mBorderThickness(0),
|
||||
|
@ -50,77 +47,23 @@ void Widget::addWidget(WidgetUPtr widget)
|
|||
mChildren.push_back(std::move(widget));
|
||||
}
|
||||
|
||||
Widget::BoundedSize Widget::getSize() const
|
||||
void Widget::setName(const std::string& name)
|
||||
{
|
||||
return mSize;
|
||||
mName = name;
|
||||
}
|
||||
|
||||
const DiscretePoint& Widget::getLocation() const
|
||||
const std::string& Widget::getName() const
|
||||
{
|
||||
return mLocation;
|
||||
return mName;
|
||||
}
|
||||
|
||||
|
||||
TransformNode* Widget::getRootNode() const
|
||||
{
|
||||
return mRootNode.get();
|
||||
}
|
||||
|
||||
void Widget::setSize(const BoundedSize& size)
|
||||
{
|
||||
if (size != mSize)
|
||||
{
|
||||
mSize = size;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setMargin(unsigned margin)
|
||||
{
|
||||
setMargin({margin, margin, margin, margin});
|
||||
}
|
||||
|
||||
void Widget::setMargin(const BoundaryOffset& margin)
|
||||
{
|
||||
if (margin != mMargin)
|
||||
{
|
||||
mMargin = margin;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setPadding(unsigned padding)
|
||||
{
|
||||
setPadding({padding, padding, padding, padding});
|
||||
}
|
||||
|
||||
void Widget::setPadding(const BoundaryOffset& padding)
|
||||
{
|
||||
if (padding != mPadding)
|
||||
{
|
||||
mPadding = padding;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
mSize.mWidth = width;
|
||||
mSize.mHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setBackgroundColor(const Color& color)
|
||||
{
|
||||
|
@ -131,15 +74,6 @@ void Widget::setBackgroundColor(const Color& color)
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::setLocation(const DiscretePoint& loc)
|
||||
{
|
||||
if (mLocation != loc)
|
||||
{
|
||||
mLocation = loc;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setVisible(bool visible)
|
||||
{
|
||||
if (mVisible != visible)
|
||||
|
@ -176,15 +110,6 @@ 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);
|
||||
|
@ -236,27 +161,6 @@ void Widget::updateChildLocations()
|
|||
}
|
||||
}
|
||||
|
||||
bool Widget::contains(const DiscretePoint& loc) const
|
||||
{
|
||||
if(loc.getX() < mLocation.getX())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(loc.getX() > mLocation.getX() + mSize.mWidth)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(loc.getY() > mLocation.getY() + mSize.mHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(loc.getY() < mLocation.getY())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Widget::onKeyboardEvent(const KeyboardEvent* event)
|
||||
{
|
||||
bool inChild = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue