added bucket options tool
This commit is contained in:
@@ -360,6 +360,7 @@
|
|||||||
<ClCompile Include="src\node_stroke_preview.cpp" />
|
<ClCompile Include="src\node_stroke_preview.cpp" />
|
||||||
<ClCompile Include="src\node_text.cpp" />
|
<ClCompile Include="src\node_text.cpp" />
|
||||||
<ClCompile Include="src\node_text_input.cpp" />
|
<ClCompile Include="src\node_text_input.cpp" />
|
||||||
|
<ClCompile Include="src\node_tool_bucket.cpp" />
|
||||||
<ClCompile Include="src\node_usermanual.cpp" />
|
<ClCompile Include="src\node_usermanual.cpp" />
|
||||||
<ClCompile Include="src\node_viewport.cpp" />
|
<ClCompile Include="src\node_viewport.cpp" />
|
||||||
<ClCompile Include="src\pch.cpp">
|
<ClCompile Include="src\pch.cpp">
|
||||||
@@ -485,6 +486,7 @@
|
|||||||
<ClInclude Include="src\node_stroke_preview.h" />
|
<ClInclude Include="src\node_stroke_preview.h" />
|
||||||
<ClInclude Include="src\node_text.h" />
|
<ClInclude Include="src\node_text.h" />
|
||||||
<ClInclude Include="src\node_text_input.h" />
|
<ClInclude Include="src\node_text_input.h" />
|
||||||
|
<ClInclude Include="src\node_tool_bucket.h" />
|
||||||
<ClInclude Include="src\node_usermanual.h" />
|
<ClInclude Include="src\node_usermanual.h" />
|
||||||
<ClInclude Include="src\node_viewport.h" />
|
<ClInclude Include="src\node_viewport.h" />
|
||||||
<ClInclude Include="src\pch.h" />
|
<ClInclude Include="src\pch.h" />
|
||||||
|
|||||||
@@ -354,6 +354,9 @@
|
|||||||
<ClCompile Include="src\canvas_layer.cpp">
|
<ClCompile Include="src\canvas_layer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\node_tool_bucket.cpp">
|
||||||
|
<Filter>Source Files\ui</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\app.h">
|
<ClInclude Include="src\app.h">
|
||||||
@@ -593,6 +596,9 @@
|
|||||||
<ClInclude Include="src\canvas_layer.h">
|
<ClInclude Include="src\canvas_layer.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\node_tool_bucket.h">
|
||||||
|
<Filter>Header Files\ui</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="PanoPainter.rc">
|
<ResourceCompile Include="PanoPainter.rc">
|
||||||
|
|||||||
@@ -1619,6 +1619,16 @@ Here's a list of what's available in this release.
|
|||||||
</border>
|
</border>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
|
<layout id="tpl-tool-bucket">
|
||||||
|
<node dir="row">
|
||||||
|
<image path="data/ui/bucket.png" width="46" height="46"/>
|
||||||
|
<border color=".3 .3 .3 1" pad="5 10 5 10" dir="row" align="center">
|
||||||
|
<text text="Threshold" margin="0 10 0 0"/>
|
||||||
|
<slider-h id="threshold" width="100" height="30"/>
|
||||||
|
</border>
|
||||||
|
</node>
|
||||||
|
</layout>
|
||||||
|
|
||||||
<!--main-->
|
<!--main-->
|
||||||
<layout id="main">
|
<layout id="main">
|
||||||
<canvas id="paint-canvas" positioning="absolute" width="100%" height="100%" grow="1"/>
|
<canvas id="paint-canvas" positioning="absolute" width="100%" height="100%" grow="1"/>
|
||||||
@@ -1758,6 +1768,11 @@ Here's a list of what's available in this release.
|
|||||||
</node>
|
</node>
|
||||||
</border>
|
</border>
|
||||||
</node>
|
</node>
|
||||||
|
|
||||||
|
<!--tools options-->
|
||||||
|
<border id="tools-container" color="0 0 0 0.3" dir="row" justify="center" mouse-capture="true">
|
||||||
|
</border>
|
||||||
|
|
||||||
<node dir="row" height="200" grow="1">
|
<node dir="row" height="200" grow="1">
|
||||||
<!--quick bar-->
|
<!--quick bar-->
|
||||||
<node justify="center" align="center" dir="col" rtl="ltr">
|
<node justify="center" align="center" dir="col" rtl="ltr">
|
||||||
|
|||||||
@@ -1577,7 +1577,7 @@ void CanvasModeFloodFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
|
|||||||
std::map<int, std::unique_ptr<bool[]>> plane_mask;
|
std::map<int, std::unique_ptr<bool[]>> plane_mask;
|
||||||
std::unique_ptr<glm::vec4> color;
|
std::unique_ptr<glm::vec4> color;
|
||||||
Canvas::I->flood_fill(Canvas::I->m_current_layer_idx, plane, { (glm::ivec2)pos },
|
Canvas::I->flood_fill(Canvas::I->m_current_layer_idx, plane, { (glm::ivec2)pos },
|
||||||
plane_mask, 200, Canvas::I->m_current_brush->m_tip_color, color);
|
plane_mask, m_tool->get_threshold(), Canvas::I->m_current_brush->m_tip_color, color);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1607,3 +1607,15 @@ void CanvasModeFloodFill::on_Draw(const glm::mat4& ortho, const glm::mat4& proj,
|
|||||||
t.unbind();
|
t.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasModeFloodFill::enter(kCanvasMode prev)
|
||||||
|
{
|
||||||
|
auto tools = App::I.layout[App::I.main_id]->find("tools-container");
|
||||||
|
m_tool = tools->add_child<NodeToolBucket>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanvasModeFloodFill::leave(kCanvasMode next)
|
||||||
|
{
|
||||||
|
m_tool->destroy();
|
||||||
|
m_tool = nullptr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include <poly2tri.h>
|
#include <poly2tri.h>
|
||||||
|
#include "node_tool_bucket.h"
|
||||||
|
|
||||||
enum class kCanvasMode
|
enum class kCanvasMode
|
||||||
{
|
{
|
||||||
@@ -112,12 +113,15 @@ class CanvasModeFloodFill : public CanvasMode
|
|||||||
{
|
{
|
||||||
const std::string m_cursor_path = "data/cursor/bucket-fill.png";
|
const std::string m_cursor_path = "data/cursor/bucket-fill.png";
|
||||||
const uint16_t m_cursor_id = const_hash(m_cursor_path.c_str());
|
const uint16_t m_cursor_id = const_hash(m_cursor_path.c_str());
|
||||||
|
glm::vec2 m_cur_pos;
|
||||||
|
NodeToolBucket* m_tool;
|
||||||
public:
|
public:
|
||||||
CanvasModeFloodFill() { hide_curor = true; }
|
CanvasModeFloodFill() { hide_curor = true; }
|
||||||
glm::vec2 m_cur_pos;
|
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual void on_MouseEvent(MouseEvent* me, glm::vec2& loc) override;
|
virtual void on_MouseEvent(MouseEvent* me, glm::vec2& loc) override;
|
||||||
virtual void on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera) override;
|
virtual void on_Draw(const glm::mat4& ortho, const glm::mat4& proj, const glm::mat4& camera) override;
|
||||||
|
virtual void enter(kCanvasMode prev) override;
|
||||||
|
virtual void leave(kCanvasMode next) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "node_changelog.h"
|
#include "node_changelog.h"
|
||||||
#include "node_usermanual.h"
|
#include "node_usermanual.h"
|
||||||
#include "node_panel_quick.h"
|
#include "node_panel_quick.h"
|
||||||
|
#include "node_tool_bucket.h"
|
||||||
|
|
||||||
void Node::app_redraw()
|
void Node::app_redraw()
|
||||||
{
|
{
|
||||||
@@ -1248,6 +1249,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
|||||||
CASE(kWidget::About, NodeAbout);
|
CASE(kWidget::About, NodeAbout);
|
||||||
CASE(kWidget::Changelog, NodeChangelog);
|
CASE(kWidget::Changelog, NodeChangelog);
|
||||||
CASE(kWidget::UserManual, NodeUserManual);
|
CASE(kWidget::UserManual, NodeUserManual);
|
||||||
|
CASE(kWidget::ToolBucket, NodeToolBucket);
|
||||||
#undef CASE
|
#undef CASE
|
||||||
case kWidget::Ref:
|
case kWidget::Ref:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ enum class kWidget : uint16_t
|
|||||||
About = const_hash("about"),
|
About = const_hash("about"),
|
||||||
Changelog = const_hash("changelog"),
|
Changelog = const_hash("changelog"),
|
||||||
UserManual = const_hash("usermanual"),
|
UserManual = const_hash("usermanual"),
|
||||||
|
ToolBucket = const_hash("tool-bucket"),
|
||||||
};
|
};
|
||||||
|
|
||||||
class Node : public std::enable_shared_from_this<Node>
|
class Node : public std::enable_shared_from_this<Node>
|
||||||
|
|||||||
31
src/node_tool_bucket.cpp
Normal file
31
src/node_tool_bucket.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "node_tool_bucket.h"
|
||||||
|
|
||||||
|
Node* NodeToolBucket::clone_instantiate() const
|
||||||
|
{
|
||||||
|
return new this_class;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeToolBucket::clone_finalize(Node* dest) const
|
||||||
|
{
|
||||||
|
parent::clone_finalize(dest);
|
||||||
|
auto n = static_cast<this_class*>(dest);
|
||||||
|
n->init_controls();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeToolBucket::init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
init_template("tpl-tool-bucket");
|
||||||
|
init_controls();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeToolBucket::init_controls()
|
||||||
|
{
|
||||||
|
m_slider_threshold = find<NodeSliderH>("threshold");
|
||||||
|
}
|
||||||
|
|
||||||
|
float NodeToolBucket::get_threshold() const
|
||||||
|
{
|
||||||
|
return glm::max(1.f, m_slider_threshold->get_value() * 255.f);
|
||||||
|
}
|
||||||
16
src/node_tool_bucket.h
Normal file
16
src/node_tool_bucket.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "node.h"
|
||||||
|
#include "node_slider.h"
|
||||||
|
|
||||||
|
class NodeToolBucket : public Node
|
||||||
|
{
|
||||||
|
NodeSliderH* m_slider_threshold;
|
||||||
|
public:
|
||||||
|
using this_class = NodeToolBucket;
|
||||||
|
using parent = Node;
|
||||||
|
virtual Node* clone_instantiate() const override;
|
||||||
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
|
virtual void init() override;
|
||||||
|
void init_controls();
|
||||||
|
float get_threshold() const;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user