tmp
This commit is contained in:
parent
2160dfca34
commit
8171ba03da
7 changed files with 135 additions and 56 deletions
|
|
@ -12,8 +12,10 @@ public:
|
|||
EditorGUI() {
|
||||
Vec2F renderResolution = { 1000, 1000 };
|
||||
auto canvas = this->mGraphics->getCanvas();
|
||||
mGui = new EditorWidget<EventHandler, Canvas>(canvas, &geometry, renderResolution);
|
||||
// mGui = new EditorWidget<EventHandler, Canvas>(canvas, &geometry, renderResolution);
|
||||
|
||||
mGui = new ShortcutsTest<EventHandler, Canvas>();
|
||||
|
||||
loadMeshes(geometry, "rsc/scene.obj");
|
||||
|
||||
geometry.mCamera.lookAtPoint({ 0, 0, 0 }, { 3, 3, 2 }, { 0, 0, 1 });
|
||||
|
|
@ -30,15 +32,10 @@ public:
|
|||
|
||||
private:
|
||||
Scene geometry;
|
||||
EditorWidget<EventHandler, Canvas>* mGui;
|
||||
ShortcutsTest<EventHandler, Canvas>* mGui;
|
||||
};
|
||||
|
||||
int main() {
|
||||
GlobalGUIConfig mConfig;
|
||||
gGlobalGUIConfig = &mConfig;
|
||||
|
||||
{
|
||||
EditorGUI gui;
|
||||
gui.run();
|
||||
}
|
||||
EditorGUI gui;
|
||||
gui.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,48 @@
|
|||
#include "Render.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
template <typename Events, typename Canvas>
|
||||
class ShortcutsTest : public Widget<Events, Canvas> {
|
||||
public:
|
||||
ShortcutsTest() { this->createConfig("ShortcutsTest"); }
|
||||
|
||||
void action(const Events&) {
|
||||
//
|
||||
}
|
||||
|
||||
void proc(const Events& events, const RectF& areaParent, const RectF& aArea) override {
|
||||
this->mArea = aArea;
|
||||
this->mVisible = areaParent.isOverlap(aArea);
|
||||
if (!this->mVisible) return;
|
||||
}
|
||||
|
||||
void draw(Canvas& canvas) override {
|
||||
if (!this->mVisible) return;
|
||||
canvas.rect(this->mArea, this->getColor("Base"));
|
||||
}
|
||||
|
||||
void populateConfig() override {
|
||||
this->addColor("Base", "Base");
|
||||
|
||||
this->addOperator("OperatorName", { this, [](void* self, const Events& events) {
|
||||
((ShortcutsTest*) self)->action(events);
|
||||
} });
|
||||
|
||||
this->getShortcuts("OperatorName").append({ { "Alt", "Hold" }, { "Mouse1", "Hold" } });
|
||||
this->getShortcuts("OperatorName").append({ { "Alt", "Hold" }, { "Mouse1", "Hold" } });
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Events, typename Canvas>
|
||||
class ViewportWidget : public Widget<Events, Canvas> {
|
||||
public:
|
||||
explicit ViewportWidget(Canvas* canvas, Scene* geometry, Vec2F renderResolution) :
|
||||
mRender(renderResolution) {
|
||||
mGeometry = geometry;
|
||||
this->createConfig("ViewportWidget");
|
||||
|
||||
mImage = canvas->createImageFromTextId(mRender.getRenderBuffer(), mRender.getBufferSize());
|
||||
mGeometry = geometry;
|
||||
mCanvas = canvas;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue