First opengl/x11/window integration.
This commit is contained in:
parent
7c6a92f4ec
commit
cea3d2c39f
30 changed files with 254 additions and 72 deletions
|
@ -22,9 +22,9 @@ Window::Window()
|
|||
: DrawingSurface(),
|
||||
mWidget(Widget::Create())
|
||||
{
|
||||
mWidget->setBounds(mWidth, mHeight);
|
||||
mWidth = 800;
|
||||
mHeight = 600;
|
||||
mWidget->setBounds(mWidth, mHeight);
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
|
@ -104,7 +104,7 @@ void Window::doPaint(mt::Screen* screen)
|
|||
{
|
||||
mPlatformWindow->beforePaint(screen);
|
||||
|
||||
mDrawingContext->getScene()->setLayers(mWidget->getLayers());
|
||||
mDrawingContext->getScene()->syncLayers(mWidget->getLayers());
|
||||
|
||||
mDrawingContext->paint();
|
||||
|
||||
|
|
|
@ -74,10 +74,11 @@ void Button::onPaintEvent(const PaintEvent* event)
|
|||
{
|
||||
unsigned fontOffset = unsigned(mLabel.size()) * 4;
|
||||
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4);
|
||||
|
||||
auto textLayer = VisualLayer::Create();
|
||||
auto textElement = TextNode::Create(mLabel, middle);
|
||||
textElement->setFillColor(mBackgroundColor);
|
||||
textLayer->setText(std::move(textElement));
|
||||
auto node = TextNode::Create(mLabel, middle);
|
||||
node->setFillColor(mBackgroundColor);
|
||||
textLayer->setTextNode(std::move(node));
|
||||
mMyLayers.push_back(std::move(textLayer));
|
||||
}
|
||||
mDirty = false;
|
||||
|
|
|
@ -48,7 +48,7 @@ void Label::onPaintEvent(const PaintEvent* event)
|
|||
auto textLayer = VisualLayer::Create();
|
||||
auto textElement = TextNode::Create(mLabel, middle);
|
||||
textElement->setFillColor(mBackgroundColor);
|
||||
textLayer->setText(std::move(textElement));
|
||||
textLayer->setTextNode(std::move(textElement));
|
||||
mMyLayers.push_back(std::move(textLayer));
|
||||
}
|
||||
addMyLayers();
|
||||
|
|
|
@ -94,7 +94,7 @@ void TextBox::onPaintEvent(const PaintEvent* event)
|
|||
auto textLayer = VisualLayer::Create();
|
||||
auto textElement = TextNode::Create(line, loc);
|
||||
textElement->setFillColor(mBackgroundColor);
|
||||
textLayer->setText(std::move(textElement));
|
||||
textLayer->setTextNode(std::move(textElement));
|
||||
mMyLayers.push_back(std::move(textLayer));
|
||||
offset += 20;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
|
||||
Widget::Widget()
|
||||
: mLocation(DiscretePoint(0, 0)),
|
||||
|
@ -99,9 +100,9 @@ void Widget::setBounds(unsigned width, unsigned height)
|
|||
if (width != mSize.mWidth || height != mSize.mHeight)
|
||||
{
|
||||
mDirty = true;
|
||||
mSize.mWidth = width;
|
||||
mSize.mHeight = height;
|
||||
}
|
||||
mSize.mWidth = width;
|
||||
mSize.mHeight = height;
|
||||
}
|
||||
|
||||
void Widget::setBackgroundColor(const Color& color)
|
||||
|
@ -273,9 +274,9 @@ void Widget::addBackground(const PaintEvent* event)
|
|||
unsigned deltaX = mSize.mWidth - mMargin.mLeft - mMargin.mRight;
|
||||
unsigned deltaY = mSize.mHeight - mMargin.mTop - mMargin.mBottom;
|
||||
|
||||
auto shape = RectangleNode::Create(DiscretePoint(locX, locY), deltaX, deltaY);
|
||||
shape->setFillColor(mBackgroundColor);
|
||||
auto shapeLayer = VisualLayer::Create();
|
||||
shapeLayer->setShape(std::move(shape));
|
||||
mMyLayers.push_back(std::move(shapeLayer));
|
||||
auto node = RectangleNode::Create(DiscretePoint(locX, locY), deltaX, deltaY);
|
||||
node->setFillColor(mBackgroundColor);
|
||||
auto layer = VisualLayer::Create();
|
||||
layer->setShapeNode(std::move(node));
|
||||
mMyLayers.push_back(std::move(layer));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue