refactor ui initialization each group in a function, new document dialog, fix parallax camera and drawing order clipping problem
This commit is contained in:
@@ -240,6 +240,27 @@
|
|||||||
</border>
|
</border>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
|
<!-- NewDoc Dialog Popup -->
|
||||||
|
<layout id="dialog-newdoc">
|
||||||
|
<border positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center">
|
||||||
|
<border thickness="1" border-color=".2" pad="3">
|
||||||
|
<border width="400" height="30" color=".2 .2 .2 .9" dir="row" align="center" justify="center">
|
||||||
|
<text text="Create New Pano Project" font-face="arial" font-size="11"></text>
|
||||||
|
</border>
|
||||||
|
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||||
|
<node dir="row">
|
||||||
|
<text text="Project name: " font-face="arial" font-size="11"/>
|
||||||
|
<text-input id="txt-input" width="100" height="20" color=".3"/>
|
||||||
|
</node>
|
||||||
|
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||||
|
<button id="btn-ok" text="Create Project" width="100" height="30" margin="0 10 0 0"/>
|
||||||
|
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||||
|
</node>
|
||||||
|
</border>
|
||||||
|
</border>
|
||||||
|
</border>
|
||||||
|
</layout>
|
||||||
|
|
||||||
<!--settings window-->
|
<!--settings window-->
|
||||||
<layout id="settings">
|
<layout id="settings">
|
||||||
<border positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center">
|
<border positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center">
|
||||||
@@ -307,6 +328,7 @@
|
|||||||
<!--file menu-->
|
<!--file menu-->
|
||||||
<layout id="file-menu">
|
<layout id="file-menu">
|
||||||
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
|
||||||
|
<!--
|
||||||
<button-custom height="30" align="center" color=".2" pad="0 20 0 10" dir="row">
|
<button-custom height="30" align="center" color=".2" pad="0 20 0 10" dir="row">
|
||||||
<checkbox width="20" height="20"/>
|
<checkbox width="20" height="20"/>
|
||||||
<node pad="5" width="100%">
|
<node pad="5" width="100%">
|
||||||
@@ -319,21 +341,22 @@
|
|||||||
<slider-h/>
|
<slider-h/>
|
||||||
</node>
|
</node>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
-->
|
||||||
|
<button-custom id="file-newdoc" text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="page_add" width="20"/>
|
<icon icon="page_add" width="20"/>
|
||||||
<text text="New Panodoc" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="New Panodoc" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-open" text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<icon icon="page_add" width="20"/>
|
||||||
|
<text text="Open" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
|
</button-custom>
|
||||||
|
<button-custom id="file-save" text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="disk" width="20"/>
|
<icon icon="disk" width="20"/>
|
||||||
<text text="Save" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="Save" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-export" text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="disk_multiple" width="20"/>
|
<icon icon="disk" width="20"/>
|
||||||
<text text="Save as.." margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="Export PNG" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
|
||||||
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
|
||||||
<icon icon="add" width="20"/>
|
|
||||||
<text text="Add reference" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom text="Menu" height="30" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon width="20"/>
|
<icon width="20"/>
|
||||||
@@ -397,6 +420,7 @@
|
|||||||
<text text="Layers" font-face="arial" font-size="11"/>
|
<text text="Layers" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<node height="100%" color="1" grow="1" align="center" justify="flex-end" dir="row">
|
<node height="100%" color="1" grow="1" align="center" justify="flex-end" dir="row">
|
||||||
|
<text id="txt-docname" text="Document: no-name" font-face="arial" font-size="11" margin="0 20 0 0" color=".6 .6 .6 1"/>
|
||||||
<text id="txt-memory" text="History memory: 0.00 Mb" font-face="arial" font-size="11" margin="0 5 0 0" color=".6 .6 .6 1"/>
|
<text id="txt-memory" text="History memory: 0.00 Mb" font-face="arial" font-size="11" margin="0 5 0 0" color=".6 .6 .6 1"/>
|
||||||
<button-custom id="btn-clean-memory" margin="0 20 0 0">
|
<button-custom id="btn-clean-memory" margin="0 20 0 0">
|
||||||
<icon icon="delete" width="20"/>
|
<icon icon="delete" width="20"/>
|
||||||
@@ -406,22 +430,30 @@
|
|||||||
</border>
|
</border>
|
||||||
<!-- toolbar -->
|
<!-- toolbar -->
|
||||||
<border id="toolbar" height="50" width="100%" pad="5" dir="row" color=".2 .2 .2 .6">
|
<border id="toolbar" height="50" width="100%" pad="5" dir="row" color=".2 .2 .2 .6">
|
||||||
|
<!--
|
||||||
<button id="btn-open" width="50" height="100%" margin="0 5 0 0" text="Open"/>
|
<button id="btn-open" width="50" height="100%" margin="0 5 0 0" text="Open"/>
|
||||||
<button id="btn-save" width="50" height="100%" margin="0 5 0 0" text="Save"/>
|
<button id="btn-save" width="50" height="100%" margin="0 5 0 0" text="Save"/>
|
||||||
<button id="btn-export" width="50" height="100%" margin="0 5 0 0" text="Export"/>
|
<button id="btn-export" width="50" height="100%" margin="0 5 0 0" text="Export"/>
|
||||||
<button id="btn-anim" width="50" height="100%" margin="0 5 0 0" text="Anim"/>
|
<button id="btn-anim" width="50" height="100%" margin="0 5 0 0" text="Anim"/>
|
||||||
<button id="btn-clear" width="50" height="100%" margin="0 5 0 15" text="Clear"/>
|
<button id="btn-clear" width="50" height="100%" margin="0 5 0 15" text="Clear"/>
|
||||||
<button-custom id="btn-bucket" width="50" height="100%" margin="0 20 0 0" thickness="1" border-color="0 0 0 1" pad="2">
|
-->
|
||||||
<image path="data/ui/bucket.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
|
||||||
</button-custom>
|
|
||||||
<button id="btn-undo" width="50" height="100%" margin="0 5 0 0" text="Undo"/>
|
<button id="btn-undo" width="50" height="100%" margin="0 5 0 0" text="Undo"/>
|
||||||
|
<node dir="row" justify="center" grow="1">
|
||||||
<button id="btn-pen" width="50" height="100%" margin="0 0 0 0" text="Pen"/>
|
<button id="btn-pen" width="50" height="100%" margin="0 0 0 0" text="Pen"/>
|
||||||
<button id="btn-pick" width="50" height="100%" margin="0 0 0 0" text="Pick"/>
|
<button id="btn-pick" width="50" height="100%" margin="0 0 0 0" text="Pick"/>
|
||||||
<button id="btn-erase" width="60" height="100%" margin="0 0 0 0" text="Erase"/>
|
|
||||||
<button id="btn-line" width="50" height="100%" margin="0 0 0 0" text="Line"/>
|
<button id="btn-erase" width="60" height="100%" margin="0 0 0 5" text="Erase"/>
|
||||||
<button id="btn-cam" width="70" height="100%" margin="0 0 0 0" text="Camera"/>
|
|
||||||
|
<button id="btn-cam" width="70" height="100%" margin="0 0 0 5" text="Camera"/>
|
||||||
|
|
||||||
|
<button id="btn-line" width="50" height="100%" margin="0 0 0 5" text="Line"/>
|
||||||
<button id="btn-grid" width="50" height="100%" margin="0 0 0 0" text="Grid"/>
|
<button id="btn-grid" width="50" height="100%" margin="0 0 0 0" text="Grid"/>
|
||||||
<button id="btn-fill" width="50" height="100%" margin="0 0 0 0" text="Fill"/>
|
<button id="btn-fill" width="50" height="100%" margin="0 0 0 0" text="Fill"/>
|
||||||
|
|
||||||
|
<button-custom id="btn-bucket" width="50" height="100%" margin="0 0 0 5" thickness="1" border-color="0 0 0 1" pad="2">
|
||||||
|
<image path="data/ui/bucket.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
|
</button-custom>
|
||||||
|
</node>
|
||||||
<!--
|
<!--
|
||||||
<button-custom id="btn-layer" width="50" height="100%" margin="0 5 0 0" thickness="1" border-color="0 0 0 1" pad="6" align="center" justify="center">
|
<button-custom id="btn-layer" width="50" height="100%" margin="0 5 0 0" thickness="1" border-color="0 0 0 1" pad="6" align="center" justify="center">
|
||||||
<icon width="100%" height="100%" icon="disk"/>
|
<icon width="100%" height="100%" icon="disk"/>
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="engine\action.cpp" />
|
<ClCompile Include="engine\action.cpp" />
|
||||||
<ClCompile Include="engine\app.cpp" />
|
<ClCompile Include="engine\app.cpp" />
|
||||||
|
<ClCompile Include="engine\app_dialogs.cpp" />
|
||||||
<ClCompile Include="engine\app_events.cpp" />
|
<ClCompile Include="engine\app_events.cpp" />
|
||||||
<ClCompile Include="engine\app_layout.cpp" />
|
<ClCompile Include="engine\app_layout.cpp" />
|
||||||
<ClCompile Include="engine\app_shaders.cpp" />
|
<ClCompile Include="engine\app_shaders.cpp" />
|
||||||
|
|||||||
@@ -198,6 +198,9 @@
|
|||||||
<ClCompile Include="engine\node_dialog_layer_rename.cpp">
|
<ClCompile Include="engine\node_dialog_layer_rename.cpp">
|
||||||
<Filter>Source Files\ui</Filter>
|
<Filter>Source Files\ui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\app_dialogs.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="engine\app.h">
|
<ClInclude Include="engine\app.h">
|
||||||
|
|||||||
11
engine/app.h
11
engine/app.h
@@ -88,4 +88,15 @@ public:
|
|||||||
bool key_down(kKey key);
|
bool key_down(kKey key);
|
||||||
bool key_up(kKey key);
|
bool key_up(kKey key);
|
||||||
bool key_char(char key);
|
bool key_char(char key);
|
||||||
|
|
||||||
|
void init_toolbar_main();
|
||||||
|
void init_toolbar_draw();
|
||||||
|
void init_sidebar();
|
||||||
|
void init_menu_file();
|
||||||
|
void init_menu_edit();
|
||||||
|
void init_menu_layer();
|
||||||
|
void dialog_newdoc();
|
||||||
|
void dialog_save();
|
||||||
|
void dialog_open();
|
||||||
|
void dialog_export();
|
||||||
};
|
};
|
||||||
|
|||||||
85
engine/app_dialogs.cpp
Normal file
85
engine/app_dialogs.cpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "app.h"
|
||||||
|
#include "node_dialog_open.h"
|
||||||
|
|
||||||
|
void App::dialog_newdoc()
|
||||||
|
{
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
auto dialog = std::make_shared<NodeDialogNewDoc>();
|
||||||
|
dialog->m_manager = &layout;
|
||||||
|
dialog->init();
|
||||||
|
dialog->create();
|
||||||
|
dialog->loaded();
|
||||||
|
|
||||||
|
layout[main_id]->add_child(dialog);
|
||||||
|
layout[main_id]->update();
|
||||||
|
|
||||||
|
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||||
|
{
|
||||||
|
layers->clear();
|
||||||
|
canvas->m_canvas->m_layers.clear();
|
||||||
|
canvas->m_canvas->m_order.clear();
|
||||||
|
ActionManager::clear();
|
||||||
|
dialog->destroy();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::dialog_open()
|
||||||
|
{
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
// load thumbnail test
|
||||||
|
auto dialog = std::make_shared<NodeDialogOpen>();
|
||||||
|
dialog->m_manager = &layout;
|
||||||
|
dialog->data_path = data_path;
|
||||||
|
dialog->init();
|
||||||
|
dialog->create();
|
||||||
|
dialog->loaded();
|
||||||
|
|
||||||
|
layout[main_id]->add_child(dialog);
|
||||||
|
layout[main_id]->update();
|
||||||
|
|
||||||
|
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||||
|
{
|
||||||
|
layers->clear();
|
||||||
|
canvas->m_canvas->project_open(dialog->selected_path);
|
||||||
|
if (auto docname = layout[main_id]->find<NodeText>("txt-docname"))
|
||||||
|
docname->set_text(("Document: " + dialog->selected_file).c_str());
|
||||||
|
for (auto& i : canvas->m_canvas->m_order)
|
||||||
|
layers->add_layer(canvas->m_canvas->m_layers[i].m_name.c_str());
|
||||||
|
dialog->destroy();
|
||||||
|
ActionManager::clear();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::dialog_save()
|
||||||
|
{
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
auto dialog = std::make_shared<NodeDialogSave>();
|
||||||
|
dialog->m_manager = &layout;
|
||||||
|
dialog->init();
|
||||||
|
dialog->create();
|
||||||
|
dialog->loaded();
|
||||||
|
|
||||||
|
layout[main_id]->add_child(dialog);
|
||||||
|
layout[main_id]->update();
|
||||||
|
|
||||||
|
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||||
|
{
|
||||||
|
canvas->m_canvas->project_save(data_path + "/" + dialog->input->m_string + ".pano");
|
||||||
|
dialog->destroy();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::dialog_export()
|
||||||
|
{
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
canvas->m_canvas->export_equirectangular(data_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,22 +2,88 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "node_icon.h"
|
#include "node_icon.h"
|
||||||
#include "node_dialog_open.h"
|
#include "node_dialog_open.h"
|
||||||
|
#include "node_text.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
void App::initLayout()
|
void App::init_toolbar_main()
|
||||||
{
|
{
|
||||||
LOG("initializing layout statics");
|
|
||||||
NodeBorder::static_init();
|
|
||||||
NodeImage::static_init();
|
|
||||||
NodeIcon::static_init();
|
|
||||||
NodeStrokePreview::static_init();
|
|
||||||
|
|
||||||
layout.on_loaded = [&] {
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-export"))
|
||||||
LOG("initializing layout updating after load");
|
{
|
||||||
layout[main_id]->update(width, height, zoom);
|
button->on_click = [this, button](Node*) {
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
canvas->m_canvas->export_equirectangular(data_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-anim"))
|
||||||
|
{
|
||||||
|
button->on_click = [this, button](Node*) {
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
canvas->m_canvas->export_anim(data_path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-open"))
|
||||||
|
{
|
||||||
|
button->on_click = [this, button](Node*) {
|
||||||
|
dialog_open();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-save"))
|
||||||
|
{
|
||||||
|
button->on_click = [this, button](Node*) {
|
||||||
|
dialog_save();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-undo"))
|
||||||
|
{
|
||||||
|
button->on_click = [this, button](Node*) {
|
||||||
|
if (!ActionManager::empty())
|
||||||
|
ActionManager::undo();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-clean-memory"))
|
||||||
|
{
|
||||||
|
button->on_click = [this](Node*) {
|
||||||
|
ActionManager::clear();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-clear"))
|
||||||
|
{
|
||||||
|
button->on_click = [this](Node*) {
|
||||||
|
//exit(0);
|
||||||
|
if (canvas)
|
||||||
|
canvas->m_canvas->clear({ 0, 0, 0, 0 });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-popup"))
|
||||||
|
{
|
||||||
|
button->on_click = [this](Node*) {
|
||||||
|
msgbox = new NodeMessageBox();
|
||||||
|
msgbox->m_manager = &layout;
|
||||||
|
msgbox->init();
|
||||||
|
layout[main_id]->add_child(msgbox);
|
||||||
|
layout[main_id]->update();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-settings"))
|
||||||
|
{
|
||||||
|
button->on_click = [this](Node*) {
|
||||||
|
settings = new NodeSettings();
|
||||||
|
settings->m_manager = &layout;
|
||||||
|
settings->init();
|
||||||
|
layout[main_id]->add_child(settings);
|
||||||
|
layout[main_id]->update();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOG("initializing layout components");
|
void App::init_sidebar()
|
||||||
|
{
|
||||||
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
|
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
|
||||||
panels = layout[main_id]->find<Node>("panels");
|
panels = layout[main_id]->find<Node>("panels");
|
||||||
canvas = layout[main_id]->find<NodeCanvas>("paint-canvas");
|
canvas = layout[main_id]->find<NodeCanvas>("paint-canvas");
|
||||||
@@ -70,7 +136,7 @@ void App::initLayout()
|
|||||||
|
|
||||||
color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||||
stroke->m_canvas->m_brush.m_tip_color = color;
|
stroke->m_canvas->m_brush.m_tip_color = color;
|
||||||
// stroke->m_canvas->draw_stroke();
|
// stroke->m_canvas->draw_stroke();
|
||||||
if (canvas)
|
if (canvas)
|
||||||
canvas->m_brush = stroke->m_canvas->m_brush;
|
canvas->m_brush = stroke->m_canvas->m_brush;
|
||||||
if (on_color_change)
|
if (on_color_change)
|
||||||
@@ -111,12 +177,13 @@ void App::initLayout()
|
|||||||
layers->on_layer_highlight_changed = [this](Node*, int idx, bool highlight) {
|
layers->on_layer_highlight_changed = [this](Node*, int idx, bool highlight) {
|
||||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_hightlight = highlight;
|
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_hightlight = highlight;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
canvas->m_canvas->layer_add("Default");
|
void App::init_toolbar_draw()
|
||||||
layers->add_layer("Default");
|
{
|
||||||
|
|
||||||
static glm::vec4 color_button_normal{.1, .1, .1, 1};
|
static glm::vec4 color_button_normal{ .1, .1, .1, 1 };
|
||||||
static glm::vec4 color_button_hlight{ 1, .0, .0, 1};
|
static glm::vec4 color_button_hlight{ 1, .0, .0, 1 };
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-pen"))
|
if (auto* button = layout[main_id]->find<NodeButton>("btn-pen"))
|
||||||
{
|
{
|
||||||
button->on_click = [this](Node*) {
|
button->on_click = [this](Node*) {
|
||||||
@@ -235,116 +302,10 @@ void App::initLayout()
|
|||||||
button->set_color(panels->get_child_index(layers.get()) == -1 ? color_button_normal : color_button_hlight);
|
button->set_color(panels->get_child_index(layers.get()) == -1 ? color_button_normal : color_button_hlight);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-export"))
|
void App::init_menu_file()
|
||||||
{
|
{
|
||||||
button->on_click = [this,button](Node*) {
|
|
||||||
if (canvas)
|
|
||||||
{
|
|
||||||
canvas->m_canvas->export_equirectangular(data_path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-anim"))
|
|
||||||
{
|
|
||||||
button->on_click = [this,button](Node*) {
|
|
||||||
if (canvas)
|
|
||||||
{
|
|
||||||
canvas->m_canvas->export_anim(data_path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-open"))
|
|
||||||
{
|
|
||||||
button->on_click = [this,button](Node*) {
|
|
||||||
if (canvas)
|
|
||||||
{
|
|
||||||
// load thumbnail test
|
|
||||||
auto open_dialog = std::make_shared<NodeDialogOpen>();
|
|
||||||
open_dialog->m_manager = &layout;
|
|
||||||
open_dialog->data_path = data_path;
|
|
||||||
open_dialog->init();
|
|
||||||
open_dialog->create();
|
|
||||||
open_dialog->loaded();
|
|
||||||
|
|
||||||
layout[main_id]->add_child(open_dialog);
|
|
||||||
layout[main_id]->update();
|
|
||||||
|
|
||||||
open_dialog->btn_ok->on_click = [this,open_dialog](Node*)
|
|
||||||
{
|
|
||||||
layers->clear();
|
|
||||||
canvas->m_canvas->project_open(open_dialog->selected_path);
|
|
||||||
for (auto& i : canvas->m_canvas->m_order)
|
|
||||||
layers->add_layer(canvas->m_canvas->m_layers[i].m_name.c_str());
|
|
||||||
open_dialog->destroy();
|
|
||||||
ActionManager::clear();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-save"))
|
|
||||||
{
|
|
||||||
button->on_click = [this,button](Node*) {
|
|
||||||
if (canvas)
|
|
||||||
{
|
|
||||||
auto dialog = std::make_shared<NodeDialogSave>();
|
|
||||||
dialog->m_manager = &layout;
|
|
||||||
dialog->init();
|
|
||||||
dialog->create();
|
|
||||||
dialog->loaded();
|
|
||||||
|
|
||||||
layout[main_id]->add_child(dialog);
|
|
||||||
layout[main_id]->update();
|
|
||||||
|
|
||||||
dialog->btn_ok->on_click = [this, dialog](Node*)
|
|
||||||
{
|
|
||||||
canvas->m_canvas->project_save(data_path + "/" + dialog->input->m_string + ".pano");
|
|
||||||
dialog->destroy();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-undo"))
|
|
||||||
{
|
|
||||||
button->on_click = [this,button](Node*) {
|
|
||||||
if (!ActionManager::empty())
|
|
||||||
ActionManager::undo();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-clean-memory"))
|
|
||||||
{
|
|
||||||
button->on_click = [this](Node*) {
|
|
||||||
ActionManager::clear();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-clear"))
|
|
||||||
{
|
|
||||||
button->on_click = [this](Node*) {
|
|
||||||
//exit(0);
|
|
||||||
if (canvas)
|
|
||||||
canvas->m_canvas->clear({ 0, 0, 0, 0 });
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-popup"))
|
|
||||||
{
|
|
||||||
button->on_click = [this](Node*) {
|
|
||||||
msgbox = new NodeMessageBox();
|
|
||||||
msgbox->m_manager = &layout;
|
|
||||||
msgbox->init();
|
|
||||||
layout[main_id]->add_child(msgbox);
|
|
||||||
layout[main_id]->update();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-settings"))
|
|
||||||
{
|
|
||||||
button->on_click = [this](Node*) {
|
|
||||||
settings = new NodeSettings();
|
|
||||||
settings->m_manager = &layout;
|
|
||||||
settings->init();
|
|
||||||
layout[main_id]->add_child(settings);
|
|
||||||
layout[main_id]->update();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-file"))
|
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-file"))
|
||||||
{
|
{
|
||||||
menu_file->on_click = [=](Node*) {
|
menu_file->on_click = [=](Node*) {
|
||||||
@@ -358,8 +319,33 @@ void App::initLayout()
|
|||||||
popup->m_mouse_ignore = false;
|
popup->m_mouse_ignore = false;
|
||||||
popup->m_flood_events = true;
|
popup->m_flood_events = true;
|
||||||
popup->m_capture_children = false;
|
popup->m_capture_children = false;
|
||||||
|
|
||||||
|
popup->find<NodeButtonCustom>("file-newdoc")->on_click = [this](Node*) {
|
||||||
|
dialog_newdoc();
|
||||||
|
popup->mouse_release();
|
||||||
|
popup->destroy();
|
||||||
|
};
|
||||||
|
popup->find<NodeButtonCustom>("file-open")->on_click = [this](Node*) {
|
||||||
|
dialog_open();
|
||||||
|
popup->mouse_release();
|
||||||
|
popup->destroy();
|
||||||
|
};
|
||||||
|
popup->find<NodeButtonCustom>("file-save")->on_click = [this](Node*) {
|
||||||
|
dialog_save();
|
||||||
|
popup->mouse_release();
|
||||||
|
popup->destroy();
|
||||||
|
};
|
||||||
|
popup->find<NodeButtonCustom>("file-export")->on_click = [this](Node*) {
|
||||||
|
dialog_export();
|
||||||
|
popup->mouse_release();
|
||||||
|
popup->destroy();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::init_menu_edit()
|
||||||
|
{
|
||||||
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-edit"))
|
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-edit"))
|
||||||
{
|
{
|
||||||
menu_file->on_click = [=](Node*) {
|
menu_file->on_click = [=](Node*) {
|
||||||
@@ -375,6 +361,10 @@ void App::initLayout()
|
|||||||
popup->m_capture_children = false;
|
popup->m_capture_children = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::init_menu_layer()
|
||||||
|
{
|
||||||
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-layers"))
|
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-layers"))
|
||||||
{
|
{
|
||||||
menu_file->on_click = [=](Node*) {
|
menu_file->on_click = [=](Node*) {
|
||||||
@@ -468,10 +458,37 @@ void App::initLayout()
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void App::initLayout()
|
||||||
|
{
|
||||||
|
LOG("initializing layout statics");
|
||||||
|
NodeBorder::static_init();
|
||||||
|
NodeImage::static_init();
|
||||||
|
NodeIcon::static_init();
|
||||||
|
NodeStrokePreview::static_init();
|
||||||
|
|
||||||
|
layout.on_loaded = [&] {
|
||||||
|
LOG("initializing layout updating after load");
|
||||||
|
layout[main_id]->update(width, height, zoom);
|
||||||
|
|
||||||
|
LOG("initializing layout components");
|
||||||
|
|
||||||
|
init_sidebar();
|
||||||
|
|
||||||
|
canvas->m_canvas->layer_add("Default");
|
||||||
|
layers->add_layer("Default");
|
||||||
|
init_toolbar_draw();
|
||||||
|
init_toolbar_main();
|
||||||
|
init_menu_file();
|
||||||
|
init_menu_edit();
|
||||||
|
init_menu_layer();
|
||||||
|
|
||||||
|
// hacky thing to make the toolbar buttons not steal events when moving cursor fast
|
||||||
if (auto* toolbar = layout[main_id]->find<Node>("toolbar"))
|
if (auto* toolbar = layout[main_id]->find<Node>("toolbar"))
|
||||||
{
|
|
||||||
toolbar->m_flood_events = true;
|
toolbar->m_flood_events = true;
|
||||||
}
|
|
||||||
|
/*
|
||||||
if (auto* slider = layout[main_id]->find<NodeSliderH>("frames-slider"))
|
if (auto* slider = layout[main_id]->find<NodeSliderH>("frames-slider"))
|
||||||
{
|
{
|
||||||
slider->on_value_changed = [this](Node*, float value)
|
slider->on_value_changed = [this](Node*, float value)
|
||||||
@@ -495,6 +512,7 @@ void App::initLayout()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
LOG("initializing layout xml");
|
LOG("initializing layout xml");
|
||||||
if (layout.m_loaded)
|
if (layout.m_loaded)
|
||||||
|
|||||||
@@ -79,24 +79,40 @@ void NodeCanvas::draw()
|
|||||||
m_sampler.bind(0);
|
m_sampler.bind(0);
|
||||||
m_sampler.bind(1);
|
m_sampler.bind(1);
|
||||||
auto blend = glIsEnabled(GL_BLEND);
|
auto blend = glIsEnabled(GL_BLEND);
|
||||||
|
auto depth = glIsEnabled(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
//glEnable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
for (int plane_index = 0; plane_index < 6; plane_index++)
|
for (int plane_index = 0; plane_index < 6; plane_index++)
|
||||||
{
|
{
|
||||||
auto plane_mvp = proj * camera * glm::scale(glm::vec3(m_canvas->m_order.size())) * m_canvas->m_plane_transform[plane_index] * glm::translate(glm::vec3(0, 0, -1));
|
auto plane_mvp = proj * camera *
|
||||||
|
glm::scale(glm::vec3(m_canvas->m_order.size() + 500)) *
|
||||||
|
m_canvas->m_plane_transform[plane_index] *
|
||||||
|
glm::translate(glm::vec3(0, 0, -1));
|
||||||
|
|
||||||
ui::ShaderManager::use(kShader::Checkerboard);
|
ui::ShaderManager::use(kShader::Checkerboard);
|
||||||
ui::ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp);
|
ui::ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp);
|
||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
for (auto layer_index : m_canvas->m_order)
|
for (auto layer_index : m_canvas->m_order)
|
||||||
|
{
|
||||||
|
for (int plane_index = 0; plane_index < 6; plane_index++)
|
||||||
{
|
{
|
||||||
if (m_canvas->m_layers[layer_index].m_opacity == .0f)
|
if (m_canvas->m_layers[layer_index].m_opacity == .0f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int z = (int)m_canvas->m_order.size() - layer_index;
|
int z = (int)m_canvas->m_order.size() - layer_index;
|
||||||
auto plane_mvp_z = proj * camera * glm::scale(glm::vec3(z)) * m_canvas->m_plane_transform[plane_index] * glm::translate(glm::vec3(0, 0, -1));
|
auto plane_mvp_z = proj * camera *
|
||||||
|
glm::scale(glm::vec3(z + 1)) *
|
||||||
|
m_canvas->m_plane_transform[plane_index] *
|
||||||
|
glm::translate(glm::vec3(0, 0, -1));
|
||||||
|
|
||||||
if (m_canvas->m_state == ui::Canvas::kCanvasMode::Erase && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index)
|
if (m_canvas->m_state == ui::Canvas::kCanvasMode::Erase && m_canvas->m_show_tmp && m_canvas->m_current_layer_idx == layer_index)
|
||||||
{
|
{
|
||||||
@@ -159,7 +175,6 @@ void NodeCanvas::draw()
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
for (auto& mode : *m_canvas->m_mode)
|
for (auto& mode : *m_canvas->m_mode)
|
||||||
mode->on_Draw(ortho_proj, proj, camera);
|
mode->on_Draw(ortho_proj, proj, camera);
|
||||||
@@ -184,6 +199,7 @@ void NodeCanvas::draw()
|
|||||||
// m_line.draw_stroke();
|
// m_line.draw_stroke();
|
||||||
|
|
||||||
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
||||||
|
depth ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
|
||||||
m_sampler.unbind();
|
m_sampler.unbind();
|
||||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ void NodeDialogOpen::init_controls()
|
|||||||
node->init();
|
node->init();
|
||||||
node->m_text->set_text(n.c_str());
|
node->m_text->set_text(n.c_str());
|
||||||
node->m_path = data_path + "/" + n;
|
node->m_path = data_path + "/" + n;
|
||||||
|
node->m_file_name = n;
|
||||||
node->on_selected = [&](NodeDialogOpenItem* target) {
|
node->on_selected = [&](NodeDialogOpenItem* target) {
|
||||||
static NodeDialogOpenItem* current = nullptr;
|
static NodeDialogOpenItem* current = nullptr;
|
||||||
if (target == current)
|
if (target == current)
|
||||||
@@ -50,6 +51,7 @@ void NodeDialogOpen::init_controls()
|
|||||||
image_tex->tex.destroy();
|
image_tex->tex.destroy();
|
||||||
image_tex->tex.create(thumb);
|
image_tex->tex.create(thumb);
|
||||||
selected_path = target->m_path;
|
selected_path = target->m_path;
|
||||||
|
selected_file = target->m_file_name;
|
||||||
if (current)
|
if (current)
|
||||||
current->m_selected = false;
|
current->m_selected = false;
|
||||||
current = target;
|
current = target;
|
||||||
@@ -157,3 +159,36 @@ void NodeDialogSave::loaded()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Node* NodeDialogNewDoc::clone_instantiate() const
|
||||||
|
{
|
||||||
|
return new NodeDialogNewDoc;
|
||||||
|
}
|
||||||
|
void NodeDialogNewDoc::clone_finalize(Node* dest) const
|
||||||
|
{
|
||||||
|
NodeDialogNewDoc* n = static_cast<NodeDialogNewDoc*>(dest);
|
||||||
|
n->init_controls();
|
||||||
|
}
|
||||||
|
void NodeDialogNewDoc::init()
|
||||||
|
{
|
||||||
|
auto tpl = static_cast<const NodeBorder*>(init_template("dialog-newdoc"));
|
||||||
|
m_color = tpl->m_color;
|
||||||
|
m_border_color = tpl->m_border_color;
|
||||||
|
m_thinkness = tpl->m_thinkness;
|
||||||
|
init_controls();
|
||||||
|
}
|
||||||
|
void NodeDialogNewDoc::init_controls()
|
||||||
|
{
|
||||||
|
btn_ok = find<NodeButton>("btn-ok");
|
||||||
|
btn_cancel = find<NodeButton>("btn-cancel");
|
||||||
|
btn_cancel->on_click = [this](Node*) {
|
||||||
|
destroy();
|
||||||
|
};
|
||||||
|
input = find<NodeTextInput>("txt-input");
|
||||||
|
}
|
||||||
|
void NodeDialogNewDoc::loaded()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
glm::vec4 m_color_hover = glm::vec4(.5, .5, .5, 1);
|
glm::vec4 m_color_hover = glm::vec4(.5, .5, .5, 1);
|
||||||
bool m_selected = false;
|
bool m_selected = false;
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
|
std::string m_file_name;
|
||||||
std::function<void(NodeDialogOpenItem* target)> on_selected;
|
std::function<void(NodeDialogOpenItem* target)> on_selected;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
@@ -32,6 +33,7 @@ public:
|
|||||||
NodeButton* btn_ok;
|
NodeButton* btn_ok;
|
||||||
Node* container;
|
Node* container;
|
||||||
std::string selected_path;
|
std::string selected_path;
|
||||||
|
std::string selected_file;
|
||||||
std::string data_path;
|
std::string data_path;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
@@ -53,3 +55,16 @@ public:
|
|||||||
void init_controls();
|
void init_controls();
|
||||||
virtual void loaded() override;
|
virtual void loaded() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NodeDialogNewDoc : public NodeBorder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NodeButton* btn_cancel;
|
||||||
|
NodeButton* btn_ok;
|
||||||
|
NodeTextInput* input;
|
||||||
|
virtual Node* clone_instantiate() const override;
|
||||||
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
|
virtual void init() override;
|
||||||
|
void init_controls();
|
||||||
|
virtual void loaded() override;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user