Fix linux compilation.
This commit is contained in:
parent
ec57e3b534
commit
990cde402b
28 changed files with 245 additions and 161 deletions
|
@ -23,6 +23,11 @@ ImageEditorView::ImageEditorView()
|
|||
addWidget(std::move(hSpacer));
|
||||
}
|
||||
|
||||
ImageEditorView::~ImageEditorView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageEditorView> ImageEditorView::Create()
|
||||
{
|
||||
return std::make_unique<ImageEditorView>();
|
||||
|
|
|
@ -8,6 +8,8 @@ public:
|
|||
|
||||
ImageEditorView();
|
||||
|
||||
virtual ~ImageEditorView();
|
||||
|
||||
static std::unique_ptr<ImageEditorView> Create();
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@ ImageViewWidget::ImageViewWidget()
|
|||
mName = "ImageViewWidget";
|
||||
}
|
||||
|
||||
ImageViewWidget::~ImageViewWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImageViewWidget::doPaint(const PaintEvent* event)
|
||||
{
|
||||
if (!mVisible)
|
||||
|
|
|
@ -9,6 +9,8 @@ class ImageViewWidget : public Widget
|
|||
public:
|
||||
ImageViewWidget();
|
||||
|
||||
virtual ~ImageViewWidget();
|
||||
|
||||
private:
|
||||
void doPaint(const PaintEvent* event) override;
|
||||
unsigned mNumX{5};
|
||||
|
|
|
@ -5,68 +5,73 @@
|
|||
#include "LogicGateNode.h"
|
||||
|
||||
ElectronicCircuitNode::ElectronicCircuitNode(const Transform& transform)
|
||||
: AbstractVisualNode(transform)
|
||||
: AbstractVisualNode(transform)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ElectronicCircuitNode::~ElectronicCircuitNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::setContent(ElectronicCircuit* content)
|
||||
{
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
mInputTerminalNodes.clear();
|
||||
mWireNodes.clear();
|
||||
mLogicGateNodes.clear();
|
||||
mInputTerminalNodes.clear();
|
||||
mWireNodes.clear();
|
||||
mLogicGateNodes.clear();
|
||||
|
||||
// Layout terminals
|
||||
double terminal_vertical_spacing = 100;
|
||||
double terminal_left_margin = 10;
|
||||
// Layout terminals
|
||||
double terminal_vertical_spacing = 100;
|
||||
double terminal_left_margin = 10;
|
||||
|
||||
double terminal_y = 0;
|
||||
for (auto terminal : mContent->getInputTerminals())
|
||||
{
|
||||
Point loc{ terminal_left_margin, terminal_y };
|
||||
auto terminal_node = std::make_unique<TerminalNode>(Transform(loc));
|
||||
double terminal_y = 0;
|
||||
for (auto terminal : mContent->getInputTerminals())
|
||||
{
|
||||
Point loc{ terminal_left_margin, terminal_y };
|
||||
auto terminal_node = std::make_unique<TerminalNode>(Transform(loc));
|
||||
|
||||
terminal_node->setContent(terminal);
|
||||
terminal_node->setContent(terminal);
|
||||
|
||||
addChild(terminal_node.get());
|
||||
mInputTerminalNodes.push_back(std::move(terminal_node));
|
||||
addChild(terminal_node.get());
|
||||
mInputTerminalNodes.push_back(std::move(terminal_node));
|
||||
|
||||
terminal_y += terminal_vertical_spacing;
|
||||
}
|
||||
terminal_y += terminal_vertical_spacing;
|
||||
}
|
||||
|
||||
// Layout logic gates
|
||||
double logic_gate_vertical_spacing = 100;
|
||||
double logic_gate_horizontal_spacing = 100;
|
||||
// Layout logic gates
|
||||
double logic_gate_vertical_spacing = 100;
|
||||
double logic_gate_horizontal_spacing = 100;
|
||||
|
||||
double gate_x = logic_gate_vertical_spacing;
|
||||
double gate_y = 0;
|
||||
for (auto gate : mContent->getLogicGates())
|
||||
{
|
||||
Point loc{ gate_x, gate_y };
|
||||
auto gate_node = std::make_unique<LogicGateNode>(Transform(loc));
|
||||
double gate_x = logic_gate_vertical_spacing;
|
||||
double gate_y = 0;
|
||||
for (auto gate : mContent->getLogicGates())
|
||||
{
|
||||
Point loc{ gate_x, gate_y };
|
||||
auto gate_node = std::make_unique<LogicGateNode>(Transform(loc));
|
||||
|
||||
gate_node->setContent(gate);
|
||||
gate_node->setContent(gate);
|
||||
|
||||
addChild(gate_node.get());
|
||||
mLogicGateNodes.push_back(std::move(gate_node));
|
||||
addChild(gate_node.get());
|
||||
mLogicGateNodes.push_back(std::move(gate_node));
|
||||
|
||||
gate_x += logic_gate_vertical_spacing;
|
||||
gate_y += logic_gate_horizontal_spacing;
|
||||
}
|
||||
gate_x += logic_gate_vertical_spacing;
|
||||
gate_y += logic_gate_horizontal_spacing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ElectronicCircuitNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,21 @@ class LogicGateNode;
|
|||
class ElectronicCircuitNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
ElectronicCircuitNode(const Transform& transform);
|
||||
ElectronicCircuitNode(const Transform& transform);
|
||||
|
||||
void setContent(ElectronicCircuit* content);
|
||||
virtual ~ElectronicCircuitNode();
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
void setContent(ElectronicCircuit* content);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
|
||||
ElectronicCircuit* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
ElectronicCircuit* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::vector<std::unique_ptr<TerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<WireNode> > mWireNodes;
|
||||
std::vector<std::unique_ptr<LogicGateNode> > mLogicGateNodes;
|
||||
};
|
||||
std::vector<std::unique_ptr<TerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<WireNode> > mWireNodes;
|
||||
std::vector<std::unique_ptr<LogicGateNode> > mLogicGateNodes;
|
||||
};
|
||||
|
|
|
@ -8,42 +8,47 @@
|
|||
#include "LogicGatePrimitiveShapes.h"
|
||||
|
||||
LogicGateNode::LogicGateNode(const Transform& transform)
|
||||
: AbstractVisualNode(transform)
|
||||
: AbstractVisualNode(transform)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LogicGateNode::~LogicGateNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LogicGateNode::setContent(LogicGate* content)
|
||||
{
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void LogicGateNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
if (mContentDirty)
|
||||
{
|
||||
createOrUpdateGeometry(sceneInfo);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LogicGateNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (!mPrimaryPath)
|
||||
{
|
||||
if (mContent->getGateType() == LogicGate::GateType::AND)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getAndGateShape());
|
||||
}
|
||||
else if (mContent->getGateType() == LogicGate::GateType::OR)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getOrGateShape());
|
||||
}
|
||||
|
||||
if (mPrimaryPath)
|
||||
{
|
||||
addChild(mPrimaryPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mPrimaryPath)
|
||||
{
|
||||
if (mContent->getGateType() == LogicGate::GateType::AND)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getAndGateShape());
|
||||
}
|
||||
else if (mContent->getGateType() == LogicGate::GateType::OR)
|
||||
{
|
||||
mPrimaryPath = std::make_unique<PathNode>(Transform(), LogicGatePrimitiveShapes::getOrGateShape());
|
||||
}
|
||||
|
||||
if (mPrimaryPath)
|
||||
{
|
||||
addChild(mPrimaryPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,24 +2,27 @@
|
|||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include "CircleNode.h"
|
||||
|
||||
class LogicGate;
|
||||
class PathNode;
|
||||
class CircleNode;
|
||||
|
||||
class LogicGateNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
LogicGateNode(const Transform& transform);
|
||||
LogicGateNode(const Transform& transform);
|
||||
|
||||
void setContent(LogicGate* content);
|
||||
virtual ~LogicGateNode();
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
void setContent(LogicGate* content);
|
||||
|
||||
void update(SceneInfo* sceneInfo);
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo);
|
||||
|
||||
LogicGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
LogicGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::unique_ptr<PathNode> mPrimaryPath;
|
||||
std::unique_ptr<CircleNode> mNegationGlyph;
|
||||
};
|
||||
std::unique_ptr<PathNode> mPrimaryPath;
|
||||
std::unique_ptr<CircleNode> mNegationGlyph;
|
||||
};
|
||||
|
|
|
@ -5,6 +5,11 @@ void AbstractMesh::addConstantNodeVectorAttribute(const std::string& tag, const
|
|||
|
||||
}
|
||||
|
||||
AbstractMesh::~AbstractMesh()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::vector<double> > AbstractMesh::getNodeVectorAttributes(const std::string& tag)
|
||||
{
|
||||
std::vector<std::vector<double> > attribs(mNodes.size());
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
QUAD
|
||||
};
|
||||
|
||||
virtual ~AbstractMesh() = default;
|
||||
virtual ~AbstractMesh();
|
||||
|
||||
void addVectorAttribute(const std::string& tag, const std::vector<double>& values);
|
||||
|
||||
|
|
|
@ -14,6 +14,11 @@ CircleNode::CircleNode(const Transform& transform, double radius)
|
|||
mMinorRadius = mRadius;
|
||||
}
|
||||
|
||||
CircleNode::~CircleNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CircleNode::Type CircleNode::getType()
|
||||
{
|
||||
return Type::Circle;
|
||||
|
|
|
@ -10,6 +10,8 @@ class CircleNode : public GeometryNode
|
|||
public:
|
||||
CircleNode(const Transform& transform, double radius);
|
||||
|
||||
virtual ~CircleNode();
|
||||
|
||||
Type getType() override;
|
||||
double getRadius() const;
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ GridNode::GridNode(const Transform& transform)
|
|||
|
||||
}
|
||||
|
||||
GridNode::~GridNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GridNode::setNumX(std::size_t numX)
|
||||
{
|
||||
if (mNumberX != numX)
|
||||
|
|
|
@ -10,6 +10,8 @@ class GridNode : public MaterialNode
|
|||
public:
|
||||
GridNode(const Transform& transform);
|
||||
|
||||
virtual ~GridNode();
|
||||
|
||||
void setNumX(std::size_t numX);
|
||||
|
||||
void setNumY(std::size_t numY);
|
||||
|
|
|
@ -8,6 +8,11 @@ MaterialNode::MaterialNode(const Transform& transform)
|
|||
|
||||
}
|
||||
|
||||
MaterialNode::~MaterialNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Color& MaterialNode::getFillColor() const
|
||||
{
|
||||
return mFillColor;
|
||||
|
|
|
@ -8,6 +8,7 @@ class MaterialNode : public AbstractVisualNode
|
|||
{
|
||||
public:
|
||||
MaterialNode(const Transform& transform);
|
||||
virtual ~MaterialNode();
|
||||
|
||||
const Color& getFillColor() const;
|
||||
const Color& getStrokeColor() const;
|
||||
|
|
|
@ -9,6 +9,28 @@ MeshNode::MeshNode(const Transform& transform)
|
|||
|
||||
}
|
||||
|
||||
MeshNode::~MeshNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SceneItem* MeshNode::getSceneItem(std::size_t idx) const
|
||||
{
|
||||
return mModel.get();
|
||||
}
|
||||
|
||||
std::size_t MeshNode::getNumSceneItems() const
|
||||
{
|
||||
if (mWorkingMesh)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MeshNode::setWidth(double width)
|
||||
{
|
||||
if (mWidth != width)
|
||||
|
@ -33,23 +55,6 @@ void MeshNode::setMesh(AbstractMesh* mesh)
|
|||
mMeshIsDirty = true;
|
||||
}
|
||||
|
||||
SceneItem* MeshNode::getSceneItem(std::size_t idx) const
|
||||
{
|
||||
return mModel.get();
|
||||
}
|
||||
|
||||
std::size_t MeshNode::getNumSceneItems() const
|
||||
{
|
||||
if (mWorkingMesh)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MeshNode::update(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (!mModel || mMeshIsDirty)
|
||||
|
|
|
@ -9,6 +9,8 @@ class MeshNode : public MaterialNode
|
|||
{
|
||||
public:
|
||||
MeshNode(const Transform& transform);
|
||||
virtual ~MeshNode();
|
||||
|
||||
void setMesh(AbstractMesh* mesh);
|
||||
|
||||
SceneItem* getSceneItem(std::size_t idx) const override;
|
||||
|
|
|
@ -5,6 +5,11 @@ SceneItem::SceneItem()
|
|||
|
||||
}
|
||||
|
||||
SceneItem::~SceneItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Color& SceneItem::getFillColor() const
|
||||
{
|
||||
return mFillColor;
|
||||
|
@ -20,6 +25,11 @@ const Transform& SceneItem::getTransform() const
|
|||
return mTransform;
|
||||
}
|
||||
|
||||
const std::string& SceneItem::getName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
double SceneItem::getOutlineThickness() const
|
||||
{
|
||||
return mOutlineThickness;
|
||||
|
@ -78,3 +88,8 @@ void SceneItem::updateTransform(const Transform& transform)
|
|||
mTransform = transform;
|
||||
}
|
||||
}
|
||||
|
||||
void SceneItem::setName(const std::string& name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
|
||||
SceneItem();
|
||||
|
||||
virtual ~SceneItem() = default;
|
||||
virtual ~SceneItem();
|
||||
|
||||
const Color& getFillColor() const;
|
||||
|
||||
|
@ -30,6 +30,8 @@ public:
|
|||
|
||||
double getOutlineThickness() const;
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
bool hasFillColor() const;
|
||||
|
||||
bool hasOutlineColor() const;
|
||||
|
@ -44,18 +46,10 @@ public:
|
|||
|
||||
void setFillColor(const Color& color);
|
||||
|
||||
void setName(const std::string& name);
|
||||
|
||||
void updateTransform(const Transform& transform);
|
||||
|
||||
void setName(const std::string& name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
const std::string& getName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
protected:
|
||||
Transform mTransform;
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ SceneModel::SceneModel(std::unique_ptr<AbstractMesh> mesh)
|
|||
|
||||
}
|
||||
|
||||
SceneModel::~SceneModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SceneModel::SceneModel(std::unique_ptr<AbstractGeometricItem> geometry)
|
||||
: SceneItem(),
|
||||
mGeometry(std::move(geometry))
|
||||
|
|
|
@ -15,6 +15,8 @@ class SceneModel : public SceneItem
|
|||
{
|
||||
public:
|
||||
SceneModel() = default;
|
||||
virtual ~SceneModel();
|
||||
|
||||
explicit SceneModel(std::unique_ptr<AbstractMesh> mesh);
|
||||
explicit SceneModel(std::unique_ptr<AbstractGeometricItem> geometry);
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#include "BoxGeometry.h"
|
||||
|
||||
BoxGeometry::BoxGeometry()
|
||||
: mLocation(DiscretePoint(0, 0)),
|
||||
mSize({ 100, 0, 0, 100, 0, 0 }),
|
||||
mPadding(),
|
||||
mMargin()
|
||||
: mLocation(DiscretePoint(0, 0)),
|
||||
mSize({ 100, 0, 0, 100, 0, 0 }),
|
||||
mPadding(),
|
||||
mMargin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BoxGeometry::~BoxGeometry()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -12,40 +17,40 @@ BoxGeometry::BoxGeometry()
|
|||
|
||||
BoundedSize BoxGeometry::getSize() const
|
||||
{
|
||||
return mSize;
|
||||
return mSize;
|
||||
}
|
||||
|
||||
const DiscretePoint& BoxGeometry::getLocation() const
|
||||
{
|
||||
return mLocation;
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
void BoxGeometry::setSize(const BoundedSize& size)
|
||||
{
|
||||
if (size != mSize)
|
||||
{
|
||||
mSize = size;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
if (size != mSize)
|
||||
{
|
||||
mSize = size;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BoxGeometry::setMargin(unsigned margin)
|
||||
{
|
||||
setMargin({ margin, margin, margin, margin });
|
||||
setMargin({ margin, margin, margin, margin });
|
||||
}
|
||||
|
||||
void BoxGeometry::setMargin(const BoundaryOffset& margin)
|
||||
{
|
||||
if (margin != mMargin)
|
||||
{
|
||||
mMargin = margin;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
if (margin != mMargin)
|
||||
{
|
||||
mMargin = margin;
|
||||
mTransformDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BoxGeometry::setPadding(unsigned padding)
|
||||
{
|
||||
setPadding({ padding, padding, padding, padding });
|
||||
setPadding({ padding, padding, padding, padding });
|
||||
}
|
||||
|
||||
void BoxGeometry::setPadding(const BoundaryOffset& padding)
|
||||
|
|
|
@ -51,7 +51,7 @@ class BoxGeometry
|
|||
public:
|
||||
BoxGeometry();
|
||||
|
||||
virtual ~BoxGeometry() = default;
|
||||
virtual ~BoxGeometry();
|
||||
|
||||
bool contains(const DiscretePoint& loc) const;
|
||||
|
||||
|
@ -88,4 +88,4 @@ protected:
|
|||
BoundaryOffset mMargin;
|
||||
|
||||
bool mTransformDirty{ true };
|
||||
};
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ std::unique_ptr<XcbEventInterface> XcbEventInterface::Create()
|
|||
return std::make_unique<XcbEventInterface>();
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::convertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
{
|
||||
auto ui_event = KeyboardEvent::Create();
|
||||
ui_event->setAction(KeyboardEvent::Action::Pressed);
|
||||
|
@ -29,7 +29,7 @@ std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyPress(xcb_key_press_
|
|||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::convertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
{
|
||||
auto ui_event = KeyboardEvent::Create();
|
||||
ui_event->setAction(KeyboardEvent::Action::Released);
|
||||
|
@ -45,31 +45,31 @@ std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyRelease(xcb_key_pres
|
|||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::ConvertButtonPress(xcb_button_press_event_t* event) const
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::convertButtonPress(xcb_button_press_event_t* event) const
|
||||
{
|
||||
auto ui_event = MouseEvent::Create();
|
||||
auto x = static_cast<unsigned>(event->event_x);
|
||||
auto y = static_cast<unsigned>(event->event_y);
|
||||
ui_event->SetClientLocation(DiscretePoint(x, y));
|
||||
ui_event->setClientLocation(DiscretePoint(x, y));
|
||||
|
||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||
ui_event->SetScreenLocation(DiscretePoint(x, y));
|
||||
ui_event->SetAction(MouseEvent::Action::Pressed);
|
||||
ui_event->setScreenLocation(DiscretePoint(x, y));
|
||||
ui_event->setAction(MouseEvent::Action::Pressed);
|
||||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::ConvertButtonRelease(xcb_button_press_event_t* event) const
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::convertButtonRelease(xcb_button_press_event_t* event) const
|
||||
{
|
||||
auto ui_event = MouseEvent::Create();
|
||||
auto x = static_cast<unsigned>(event->event_x);
|
||||
auto y = static_cast<unsigned>(event->event_y);
|
||||
ui_event->SetClientLocation(DiscretePoint(x, y));
|
||||
ui_event->setClientLocation(DiscretePoint(x, y));
|
||||
|
||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||
ui_event->SetScreenLocation(DiscretePoint(x, y));
|
||||
ui_event->setScreenLocation(DiscretePoint(x, y));
|
||||
|
||||
ui_event->SetAction(MouseEvent::Action::Released);
|
||||
ui_event->setAction(MouseEvent::Action::Released);
|
||||
return ui_event;
|
||||
}
|
||||
|
|
|
@ -13,16 +13,15 @@ struct xcb_button_press_event_t;
|
|||
class XcbEventInterface
|
||||
{
|
||||
public:
|
||||
|
||||
static std::unique_ptr<XcbEventInterface> Create();
|
||||
|
||||
std::unique_ptr<KeyboardEvent> ConvertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const;
|
||||
std::unique_ptr<KeyboardEvent> convertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const;
|
||||
|
||||
std::unique_ptr<KeyboardEvent> ConvertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const;
|
||||
std::unique_ptr<KeyboardEvent> convertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const;
|
||||
|
||||
std::unique_ptr<MouseEvent> ConvertButtonPress(xcb_button_press_event_t* event) const;
|
||||
std::unique_ptr<MouseEvent> convertButtonPress(xcb_button_press_event_t* event) const;
|
||||
|
||||
std::unique_ptr<MouseEvent> ConvertButtonRelease(xcb_button_press_event_t* event) const;
|
||||
std::unique_ptr<MouseEvent> convertButtonRelease(xcb_button_press_event_t* event) const;
|
||||
};
|
||||
|
||||
using XcbEventInterfacePtr = std::unique_ptr<XcbEventInterface>;
|
||||
|
|
|
@ -182,7 +182,7 @@ void XcbInterface::addWindow(mt::Window* window)
|
|||
|
||||
void XcbInterface::onPaint()
|
||||
{
|
||||
mDesktopManager->onUiEvent(PaintEvent::Create());
|
||||
mDesktopManager->onUiEvent(PaintEvent::Create(mDesktopManager->getThemeManager(), mDesktopManager->getFontsManager()));
|
||||
|
||||
auto mainWindow = mDesktopManager->getWindowManager()->getMainWindow();
|
||||
auto defaultScreen = mDesktopManager->getDefaultScreen();
|
||||
|
@ -215,25 +215,25 @@ void XcbInterface::loop()
|
|||
}
|
||||
case XCB_KEY_PRESS: {
|
||||
auto kp = reinterpret_cast<xcb_key_press_event_t*>(event);
|
||||
auto ui_event = mEventInterface->ConvertKeyPress(kp, mDesktopManager->getKeyboard());
|
||||
auto ui_event = mEventInterface->convertKeyPress(kp, mDesktopManager->getKeyboard());
|
||||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
case XCB_KEY_RELEASE: {
|
||||
auto kr = reinterpret_cast<xcb_key_release_event_t*>(event);
|
||||
auto ui_event = mEventInterface->ConvertKeyRelease(kr, mDesktopManager->getKeyboard());
|
||||
auto ui_event = mEventInterface->convertKeyRelease(kr, mDesktopManager->getKeyboard());
|
||||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_PRESS: {
|
||||
auto press = reinterpret_cast<xcb_button_press_event_t*>(event);
|
||||
auto ui_event = mEventInterface->ConvertButtonPress(press);
|
||||
auto ui_event = mEventInterface->convertButtonPress(press);
|
||||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_RELEASE: {
|
||||
auto release = reinterpret_cast<xcb_button_release_event_t*>(event);
|
||||
auto ui_event = mEventInterface->ConvertButtonRelease(release);
|
||||
auto ui_event = mEventInterface->convertButtonRelease(release);
|
||||
mDesktopManager->onUiEvent(std::move(ui_event));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -38,20 +38,23 @@ public:
|
|||
void showWindow(mt::Window* window) override;
|
||||
|
||||
private:
|
||||
void initialize() override;
|
||||
void onPaint();
|
||||
void onExposeEvent(xcb_expose_event_t* event);
|
||||
|
||||
void initializeHardwareRendering() override;
|
||||
void createGraphicsContext();
|
||||
|
||||
void connect();
|
||||
void updateScreen();
|
||||
|
||||
uint32_t getEventMask();
|
||||
|
||||
void initialize() override;
|
||||
void initializeHardwareRendering() override;
|
||||
|
||||
void onPaint();
|
||||
void onExposeEvent(xcb_expose_event_t* event);
|
||||
|
||||
void mapWindow(mt::Window* window);
|
||||
|
||||
void shutDown() override;
|
||||
uint32_t getEventMask();
|
||||
|
||||
void updateScreen();
|
||||
private:
|
||||
xcb_connection_t* mConnection{nullptr};
|
||||
_XDisplay* mX11Display{nullptr};
|
||||
|
|
Loading…
Reference in a new issue