enable timeline option

This commit is contained in:
2019-09-21 00:02:48 +02:00
parent dc8f2f5742
commit 1d1aef4095
8 changed files with 75 additions and 17 deletions

View File

@@ -1632,6 +1632,9 @@ Here's a list of what's available in this release.
<button-custom id="file-submenu-export-depth" height="40" align="center" color=".2" pad="0 0 0 10" dir="row"> <button-custom id="file-submenu-export-depth" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="3D View + Depth" grow="1" margin="0 0 0 5"/> <text text="3D View + Depth" grow="1" margin="0 0 0 5"/>
</button-custom> </button-custom>
<button-custom id="file-submenu-export-anim" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Animation Frames" grow="1" margin="0 0 0 5"/>
</button-custom>
</popup-menu> </popup-menu>
</layout> </layout>
@@ -1694,6 +1697,10 @@ Here's a list of what's available in this release.
<checkbox id="tools-vr-check" width="20" height="20"/> <checkbox id="tools-vr-check" width="20" height="20"/>
<text text="Enable VR" margin="0 0 0 5"/> <text text="Enable VR" margin="0 0 0 5"/>
</button-custom> </button-custom>
<button-custom id="tools-timeline" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<checkbox id="tools-timeline-check" width="20" height="20"/>
<text text="Show Timeline" margin="0 0 0 5"/>
</button-custom>
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row"> <button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="bin" width="20"/> <icon icon="bin" width="20"/>
<text text="Clear Guides" margin="0 0 0 5"/> <text text="Clear Guides" margin="0 0 0 5"/>
@@ -1963,9 +1970,12 @@ Here's a list of what's available in this release.
<border color=".3 .3 .3 .4" height="50" width="100%" pad="10" dir="row" mouse-capture="true"> <border color=".3 .3 .3 .4" height="50" width="100%" pad="10" dir="row" mouse-capture="true">
<text text="Timeline: " margin="8 10 0 0"/> <text text="Timeline: " margin="8 10 0 0"/>
<slider-h id="frames-slider" width="1" grow="1" margin="0 10 0 0"></slider-h> <slider-h id="frames-slider" width="1" grow="1" margin="0 10 0 0"></slider-h>
<node width="30" margin="5 10 0 10"> <node width="30" margin="0 10 0 10">
<text id="timeline-frame" text="00" font-size="30"/> <text id="timeline-frame" text="00" font-size="30"/>
</node> </node>
<button-custom id="btn-add" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 2 0 5">
<icon width="30" icon="add"/>
</button-custom>
</border> </border>
</node> </node>

View File

@@ -104,6 +104,7 @@ public:
std::shared_ptr<NodePanelStroke> stroke; std::shared_ptr<NodePanelStroke> stroke;
std::shared_ptr<NodePanelGrid> grid; std::shared_ptr<NodePanelGrid> grid;
std::shared_ptr<NodePanelBrushPreset> presets; std::shared_ptr<NodePanelBrushPreset> presets;
std::shared_ptr<Node> timeline;
NodePanelQuick* quick; NodePanelQuick* quick;
std::map<kCanvasMode, NodePanelQuick::MiniState> quick_mode_state; std::map<kCanvasMode, NodePanelQuick::MiniState> quick_mode_state;
Node* floatings_container; Node* floatings_container;

View File

@@ -466,17 +466,24 @@ void App::dialog_export_layers()
if (canvas) if (canvas)
{ {
// TODO: use picker
canvas->m_canvas->export_layers(doc_name, [this] {
#if defined(__IOS__) #if defined(__IOS__)
auto dir = work_path + "/" + doc_name + "_layers";
if (Asset::create_dir(dir))
{
auto p = dir + "/" + doc_name;
canvas->m_canvas->export_layers(p, [this, p] {
message_box("Export Layers", "Image layers exported to Files/PanoPainter"); message_box("Export Layers", "Image layers exported to Files/PanoPainter");
#elif defined(__OSX__)
message_box("Export Layers", "Image layers exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
message_box("Export Layers", "Image layers exported to " + work_path);
#endif
}); });
} }
#else
pick_dir([this](std::string path) {
auto p = path + "/" + doc_name;
canvas->m_canvas->export_layers(p, [this, p] {
message_box("Export Layers", "Layers exported to: " + p);
});
});
#endif
}
} }
void App::dialog_export_depth() void App::dialog_export_depth()

View File

@@ -638,6 +638,13 @@ void App::init_menu_file()
popup->mouse_release(); popup->mouse_release();
popup->destroy(); popup->destroy();
}; };
subpopup->find<NodeButtonCustom>("file-submenu-export-anim")->on_click = [this, subpopup, popup](Node*) {
dialog_export_layers();
subpopup->mouse_release();
subpopup->destroy();
popup->mouse_release();
popup->destroy();
};
}; };
if (auto b = popup->find<NodeButtonCustom>("file-share")) if (auto b = popup->find<NodeButtonCustom>("file-share"))
b->on_click = [this, popup](Node*) { b->on_click = [this, popup](Node*) {
@@ -987,6 +994,23 @@ void App::init_menu_tools()
}; };
} }
if (auto vr_btn = popup_exp->find<NodeButtonCustom>("tools-timeline"))
{
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-timeline-check");
cb->set_value(timeline->GetVisibility());
vr_btn->on_click = [this, popup_exp, vr_btn](Node* b)
{
NodeCheckBox* cb = vr_btn->find<NodeCheckBox>("tools-timeline-check");
cb->set_value(!cb->checked, true);
};
vr_btn->find<NodeCheckBox>("tools-timeline-check")->on_value_changed = [this, main](Node* target, bool checked)
{
timeline->SetVisibility(checked);
};
}
popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) { popup_exp->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup_exp](Node*) {
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0]; CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
mode->clear(); mode->clear();
@@ -1297,7 +1321,8 @@ void App::initLayout()
toggle_ui(); toggle_ui();
}; };
if (auto* timeline = layout[main_id]->find<NodeSliderH>("timeline")) timeline = layout[main_id]->find_ref("timeline");
if (timeline)
{ {
if (auto * slider = layout[main_id]->find<NodeSliderH>("frames-slider")) if (auto * slider = layout[main_id]->find<NodeSliderH>("frames-slider"))
{ {
@@ -1337,7 +1362,12 @@ void App::initLayout()
} }
}; };
} }
timeline->destroy(); if (auto btn_add = timeline->find<NodeButtonCustom>("btn-add"))
{
btn_add->on_click = [this] (Node*) {
layers->add_layer(true, true);
};
}
} }
/* /*
@@ -1459,6 +1489,7 @@ void App::ui_save()
Settings::set("ui", d); Settings::set("ui", d);
Settings::set("ui-rtl", Serializer::Boolean(ui_rtl)); Settings::set("ui-rtl", Serializer::Boolean(ui_rtl));
Settings::set("timeline-visible", Serializer::Boolean(timeline->GetVisibility()));
#if _WIN32 #if _WIN32
extern void win32_save_window_state(); extern void win32_save_window_state();
@@ -1477,6 +1508,9 @@ void App::ui_restore()
if (!Settings::has("ui")) if (!Settings::has("ui"))
return; return;
timeline->SetVisibility(Settings::value_or<Serializer::Boolean>("timeline-visible", false));
auto floatings = layout[main_id]->find_ref("floatings"); auto floatings = layout[main_id]->find_ref("floatings");
auto drop_left = layout[main_id]->find_ref("drop-left"); auto drop_left = layout[main_id]->find_ref("drop-left");
auto drop_right = layout[main_id]->find_ref("drop-right"); auto drop_right = layout[main_id]->find_ref("drop-right");

View File

@@ -1908,13 +1908,13 @@ void Canvas::export_depth_thread(std::string file_name)
rtt.destroy(); rtt.destroy();
} }
void Canvas::export_layers(std::string file_name, std::function<void()> on_complete) void Canvas::export_layers(std::string path, std::function<void()> on_complete)
{ {
if (App::I->check_license()) if (App::I->check_license())
{ {
std::thread t([=] { std::thread t([=] {
BT_SetTerminate(); BT_SetTerminate();
export_layers_thread(file_name); export_layers_thread(path);
if (on_complete) if (on_complete)
on_complete(); on_complete();
}); });
@@ -1922,14 +1922,14 @@ void Canvas::export_layers(std::string file_name, std::function<void()> on_compl
} }
} }
void Canvas::export_layers_thread(std::string file_name) void Canvas::export_layers_thread(std::string path)
{ {
auto pb = App::I->show_progress("Export Layers", m_layers.size()); auto pb = App::I->show_progress("Export Layers", m_layers.size());
for (int i = 0; i < m_layers.size(); i++) for (int i = 0; i < m_layers.size(); i++)
{ {
auto l = m_layers[i]; auto l = m_layers[i];
Image img = l->gen_equirect().get_image(); Image img = l->gen_equirect().get_image();
img.save_png(fmt::format("{}/{}-layer{:02d}-{}.png", App::I->work_path, file_name, i, l->m_name)); img.save_png(fmt::format("{}-layer{:02d}-{}.png", path, i, l->m_name));
pb->increment(); pb->increment();
} }
pb->destroy(); pb->destroy();

View File

@@ -203,8 +203,8 @@ public:
void import_equirectangular_thread(std::string file_path, std::shared_ptr<Layer> layer = nullptr); void import_equirectangular_thread(std::string file_path, std::shared_ptr<Layer> layer = nullptr);
void export_equirectangular(std::string file_path, std::function<void()> on_complete = nullptr); void export_equirectangular(std::string file_path, std::function<void()> on_complete = nullptr);
void export_equirectangular_thread(std::string file_path); void export_equirectangular_thread(std::string file_path);
void export_layers(std::string file_name, std::function<void()> on_complete = nullptr); void export_layers(std::string path, std::function<void()> on_complete = nullptr);
void export_layers_thread(std::string file_name); void export_layers_thread(std::string path);
void export_depth(std::string file_name, std::function<void()> on_complete = nullptr); void export_depth(std::string file_name, std::function<void()> on_complete = nullptr);
void export_depth_thread(std::string file_name); void export_depth_thread(std::string file_name);
void export_cube_faces(std::string file_name, std::function<void()> on_complete); void export_cube_faces(std::string file_name, std::function<void()> on_complete);

View File

@@ -907,6 +907,11 @@ void Node::SetRTL(YGDirection dir)
app_redraw(); app_redraw();
} }
bool Node::GetVisibility()
{
return m_display;
}
void Node::SetVisibility(bool visible) void Node::SetVisibility(bool visible)
{ {
App::I->ui_task([&] App::I->ui_task([&]

View File

@@ -181,6 +181,7 @@ public:
// used in visibility switch // used in visibility switch
YGNodeRef y_placeholder = nullptr; YGNodeRef y_placeholder = nullptr;
bool GetVisibility();
void SetVisibility(bool visible); void SetVisibility(bool visible);
void ToggleVisibility(); void ToggleVisibility();