Update text rendering.
This commit is contained in:
parent
8536908eab
commit
8130308f7f
27 changed files with 503 additions and 77 deletions
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
|
||||
Widget::Widget()
|
||||
: BoxGeometry(),
|
||||
|
@ -73,6 +72,24 @@ void Widget::setBackground(Theme::Sys::Color token)
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::setBackgroundTone(Theme::Sys::Color token)
|
||||
{
|
||||
if (mBackgroundTone != token)
|
||||
{
|
||||
mBackgroundTone = token;
|
||||
mMaterialDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setElevation(Theme::Sys::Elevation elevation)
|
||||
{
|
||||
if (mElevation != elevation)
|
||||
{
|
||||
mElevation = elevation;
|
||||
mMaterialDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setBackgroundOpacity(float opacity)
|
||||
{
|
||||
if (mBackgroundOpacity != opacity)
|
||||
|
@ -173,6 +190,9 @@ void Widget::onPaintEvent(const PaintEvent* event)
|
|||
}
|
||||
|
||||
doPaint(event);
|
||||
mGeometryDirty = false;
|
||||
mMaterialDirty = false;
|
||||
mTransformDirty = false;
|
||||
|
||||
if (mVisibilityDirty)
|
||||
{
|
||||
|
@ -293,32 +313,30 @@ void Widget::onMyMouseEvent(const MouseEvent* event)
|
|||
|
||||
void Widget::createOrUpdateGeometry()
|
||||
{
|
||||
const auto deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
|
||||
const auto deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;
|
||||
if (!mBackgroundNode)
|
||||
{
|
||||
unsigned locX = mLocation.getX() + mMargin.mLeft;
|
||||
unsigned locY = mLocation.getY() + mMargin.mTop;
|
||||
unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
|
||||
unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;
|
||||
|
||||
const auto locX = mLocation.getX() + mMargin.mLeft;
|
||||
const auto locY = mLocation.getY() + mMargin.mTop;
|
||||
mBackgroundNode = std::make_unique<RectangleNode>(DiscretePoint(locX, locY), deltaX, deltaY);
|
||||
mBackgroundNode->setRadius(mRadius);
|
||||
|
||||
mBackgroundNode->setName(mName + "_BackgroundNode");
|
||||
mRootNode->addChild(mBackgroundNode.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
mBackgroundNode->setWidth(deltaX);
|
||||
mBackgroundNode->setHeight(deltaY);
|
||||
mBackgroundNode->setRadius(mRadius);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::updateTransform()
|
||||
{
|
||||
unsigned locX = mLocation.getX() + mMargin.mLeft;
|
||||
unsigned locY = mLocation.getY() + mMargin.mTop;
|
||||
unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
|
||||
unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;
|
||||
|
||||
mBackgroundNode->setWidth(deltaX);
|
||||
mBackgroundNode->setHeight(deltaY);
|
||||
const auto locX = mLocation.getX() + mMargin.mLeft;
|
||||
const auto locY = mLocation.getY() + mMargin.mTop;
|
||||
mBackgroundNode->setLocation(DiscretePoint(locX, locY));
|
||||
}
|
||||
|
||||
|
@ -326,9 +344,16 @@ void Widget::updateMaterial(const PaintEvent* event)
|
|||
{
|
||||
if (mBackground != Theme::Sys::Color::None)
|
||||
{
|
||||
auto background_color = event->getThemesManager()->getColor(mBackground);
|
||||
background_color.setAlpha(mBackgroundOpacity);
|
||||
mBackgroundNode->setFillColor(background_color);
|
||||
//if (mBackgroundTone == Theme::Sys::Color::None || mElevation == Theme::Sys::Elevation::Level_0)
|
||||
//{
|
||||
auto background_color = event->getThemesManager()->getColor(mBackground);
|
||||
background_color.setAlpha(mBackgroundOpacity);
|
||||
mBackgroundNode->setFillColor(background_color);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//event->getThemesManager()->getColor(mBackground);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -348,22 +373,14 @@ void Widget::updateMaterial(const PaintEvent* event)
|
|||
|
||||
void Widget::updateBackground(const PaintEvent* event)
|
||||
{
|
||||
unsigned locX = mLocation.getX() + mMargin.mLeft;
|
||||
unsigned locY = mLocation.getY() + mMargin.mTop;
|
||||
unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
|
||||
unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;
|
||||
|
||||
if (!mBackgroundNode)
|
||||
if (mGeometryDirty)
|
||||
{
|
||||
mBackgroundNode = std::make_unique<RectangleNode>(DiscretePoint(locX, locY), deltaX, deltaY);
|
||||
mBackgroundNode->setName(mName + "_BackgroundNode");
|
||||
mRootNode->addChild(mBackgroundNode.get());
|
||||
createOrUpdateGeometry();
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
updateTransform();
|
||||
mTransformDirty = false;
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue