enable Edit menu and add Clear Presets feature

This commit is contained in:
2019-05-20 15:06:47 +02:00
parent 574ce444cc
commit fe618bfef1
4 changed files with 48 additions and 32 deletions

View File

@@ -1429,17 +1429,17 @@ Here's a list of what's available in this release.
<!-- MENU EDIT -->
<layout id="edit-menu">
<popup-menu positioning="absolute" position="100 100" width="150" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="page_add" width="20"/>
<text text="New Panodoc" margin="0 0 0 5"/>
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="bin" width="20"/>
<text text="Clear Guides" margin="0 0 0 5"/>
</button-custom>
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="disk" width="20"/>
<text text="Save" margin="0 0 0 5"/>
<button-custom id="clear-presets" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="bin" width="20"/>
<text text="Clear Presets" margin="0 0 0 5"/>
</button-custom>
<button-custom height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="disk_multiple" width="20"/>
<text text="Save as.." margin="0 0 0 5"/>
<button-custom id="camera-reset" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="arrow_rotate_clockwise" width="20"/>
<text id="menu-label" text="Reset Camera" margin="0 0 0 5"/>
</button-custom>
</popup-menu>
</layout>
@@ -1451,10 +1451,6 @@ Here's a list of what's available in this release.
<icon icon="cancel" width="20"/>
<text id="menu-label" text="Clear layer" 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">
<icon icon="bin" width="20"/>
<text text="Clear grids" margin="0 0 0 5"/>
</button-custom>
<button-custom id="layer-rename" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="application_edit" width="20"/>
<text id="menu-label" text="Rename Layer" margin="0 0 0 5"/>
@@ -1463,10 +1459,6 @@ Here's a list of what's available in this release.
<icon icon="application_edit" width="20"/>
<text id="menu-label" text="Merge with" margin="0 0 0 5"/>
</button-custom>
<button-custom id="camera-reset" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<icon icon="arrow_rotate_clockwise" width="20"/>
<text id="menu-label" text="Reset Camera" margin="0 0 0 5"/>
</button-custom>
</popup-menu>
</layout>
@@ -1650,11 +1642,9 @@ Here's a list of what's available in this release.
<button-custom id="menu-file" width="50" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
<text text="File"/>
</button-custom>
<!--
<button-custom id="menu-edit" width="50" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
<text text="Edit"/>
</button-custom>
-->
<button-custom id="menu-layers" width="60" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
<text text="Layers"/>
</button-custom>
@@ -1734,7 +1724,7 @@ Here's a list of what's available in this release.
<!-- <button id="btn-fill" width="40" height="40" margin="0" text="Fill"/> -->
<button id="btn-cam" width="40" height="40" margin="2 0 2 5" text="Cam"/>
<button id="btn-grid" width="40" height="40" margin="2 0 2 5" text="Grid"/>
<button id="btn-grid" width="40" height="40" margin="2 0 2 5" text="Guide"/>
<button-custom id="btn-touchlock" width="40" height="40" margin="2 0 2 5" thickness="1" border-color="0 0 0 1" pad="2">
<image path="data/ui/notouch.png" width="100%" height="100%" align="center" justify="flex-end"/>
</button-custom>

View File

@@ -697,6 +697,32 @@ void App::init_menu_edit()
popup->m_mouse_ignore = false;
popup->m_flood_events = true;
popup->m_capture_children = false;
popup->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup](Node*) {
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
mode->clear();
popup->mouse_release();
popup->destroy();
};
popup->find<NodeButtonCustom>("camera-reset")->on_click = [this, popup](Node*) {
canvas->reset_camera();
popup->mouse_release();
popup->destroy();
};
popup->find<NodeButtonCustom>("clear-presets")->on_click = [this, popup](Node*) {
auto mb = message_box("Clear Presets", "Do you want to remove all the Brush Presets?", true);
mb->btn_ok->m_text->set_text("Yes");
mb->btn_cancel->m_text->set_text("No");
mb->btn_ok->on_click = mb->on_submit = [this,mb](Node*) {
presets->clear_brushes();
presets->save();
mb->destroy();
};
popup->mouse_release();
popup->destroy();
};
};
}
}
@@ -1107,18 +1133,6 @@ void App::init_menu_layer()
popup->m_mouse_ignore = false;
popup->m_flood_events = true;
popup->m_capture_children = false;
popup->find<NodeButtonCustom>("clear-grids")->on_click = [this, popup](Node*) {
CanvasModeGrid* mode = (CanvasModeGrid*)Canvas::modes[(int)kCanvasMode::Grid][0];
mode->clear();
popup->mouse_release();
popup->destroy();
};
popup->find<NodeButtonCustom>("camera-reset")->on_click = [this, popup](Node*) {
canvas->reset_camera();
popup->mouse_release();
popup->destroy();
};
popup->find<NodeButtonCustom>("layer-clear")->on_click = [this, popup](Node*) {
canvas->m_canvas->clear();

View File

@@ -361,6 +361,11 @@ bool NodePanelBrush::restore()
return false;
}
void NodePanelBrush::clear()
{
m_container->remove_all_children();
}
void NodePanelBrush::added(Node* parent)
{
m_interacted = false;
@@ -604,6 +609,11 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr<Brush> brush)
b->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1);
}
void NodePanelBrushPreset::clear_brushes()
{
m_container->remove_all_children();
}
void NodePanelBrushPreset::added(Node* parent)
{
m_interacted = false;

View File

@@ -52,6 +52,7 @@ public:
std::string get_thumb_path(int index) const;
bool save();
bool restore();
void clear();
};
// -----------------------------------------------------------------------
@@ -92,5 +93,6 @@ public:
bool save();
bool restore();
void add_brush(std::shared_ptr<Brush> brush);
void clear_brushes();
};