new widgets

This commit is contained in:
IlyaShurupov 2024-06-19 22:17:18 +03:00 committed by Ilya Shurupov
parent 5cc982fa00
commit 285ca80b4b
18 changed files with 373 additions and 43 deletions

View file

@ -1,16 +1,15 @@
#include "ChatGUI.hpp"
#include "SimpleGUI.hpp"
#include "GraphicApplication.hpp"
using namespace tp;
class SimpleGUI : public Application {
public:
SimpleGUI() {
mGui.addWidget(&mButton);
mGui.addWidget(&mLabel);
mGui.addWidget(&mSlider);
}
void processFrame(EventHandler* eventHandler) override {
@ -22,17 +21,14 @@ public:
}
void drawFrame(Canvas* canvas) override {
canvas->rect(mGui.mArea, { 0, 0, 0, 1 });
canvas->rect(mGui.mArea, { 0.1f, 0.1f, 0.1f, 1.f });
mGui.drawWrapper(*canvas);
}
private:
WidgetManager mWidgetManager;
ScrollableWindow<EventHandler, Canvas> mGui;
ButtonWidget<EventHandler, Canvas> mButton;
LabelWidget<EventHandler, Canvas> mLabel;
NamedSliderWidget<EventHandler, Canvas> mSlider;
SimpleWidget2<EventHandler, Canvas> mGui;
};
int main() {

View file

@ -0,0 +1,45 @@
#include "Widgets.hpp"
namespace tp {
template <typename Events, typename Canvas>
class SimpleWidget : public ScrollableWindow<Events, Canvas> {
public:
SimpleWidget() {
this->addWidget(&mLabel);
this->addWidget(&mButton);
this->addWidget(&mSlider);
this->addWidget(&mCollapsableMenu);
mCollapsableMenu.addWidgetToMenu(&mInMenuButton1);
mCollapsableMenu.addWidgetToMenu(&mInMenuButton2);
mInMenuButton1.mLabel.mLabel = "Button1";
mInMenuButton2.mLabel.mLabel = "Button2";
this->mArea.size = { 500, 500 };
}
private:
CollapsableMenu<Events, Canvas> mCollapsableMenu;
ButtonWidget<EventHandler, Canvas> mInMenuButton1;
ButtonWidget<EventHandler, Canvas> mInMenuButton2;
ButtonWidget<EventHandler, Canvas> mButton;
LabelWidget<EventHandler, Canvas> mLabel;
NamedSliderWidget<EventHandler, Canvas> mSlider;
};
template <typename Events, typename Canvas>
class SimpleWidget2 : public Widget<Events, Canvas> {
public:
SimpleWidget2() {
this->mChildWidgets.pushBack(&mFloating);
mFloating.addWidgetToMenu(&mWidget);
}
private:
FloatingWidget<EventHandler, Canvas> mFloating;
SimpleWidget<EventHandler, Canvas> mWidget;
};
}