diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj
index e881a3e..c31c869 100644
--- a/PanoPainter.vcxproj
+++ b/PanoPainter.vcxproj
@@ -360,6 +360,7 @@
+
@@ -485,6 +486,7 @@
+
diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters
index 7a4e8a2..1f0304b 100644
--- a/PanoPainter.vcxproj.filters
+++ b/PanoPainter.vcxproj.filters
@@ -354,6 +354,9 @@
Source Files
+
+ Source Files\ui
+
@@ -593,6 +596,9 @@
Header Files
+
+ Header Files\ui
+
diff --git a/data/layout.xml b/data/layout.xml
index ec600f5..a8d3c83 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -1619,6 +1619,16 @@ Here's a list of what's available in this release.
+
+
+
+
+
+
+
+
+
+
@@ -1758,6 +1768,11 @@ Here's a list of what's available in this release.
+
+
+
+
+
diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp
index 39bb1b0..8cf997e 100644
--- a/src/canvas_modes.cpp
+++ b/src/canvas_modes.cpp
@@ -1577,7 +1577,7 @@ void CanvasModeFloodFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc)
std::map> plane_mask;
std::unique_ptr color;
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;
default:
@@ -1607,3 +1607,15 @@ void CanvasModeFloodFill::on_Draw(const glm::mat4& ortho, const glm::mat4& proj,
t.unbind();
}
}
+
+void CanvasModeFloodFill::enter(kCanvasMode prev)
+{
+ auto tools = App::I.layout[App::I.main_id]->find("tools-container");
+ m_tool = tools->add_child();
+}
+
+void CanvasModeFloodFill::leave(kCanvasMode next)
+{
+ m_tool->destroy();
+ m_tool = nullptr;
+}
diff --git a/src/canvas_modes.h b/src/canvas_modes.h
index 37fa537..8732fc0 100644
--- a/src/canvas_modes.h
+++ b/src/canvas_modes.h
@@ -5,6 +5,7 @@
#include "texture.h"
#include "action.h"
#include
+#include "node_tool_bucket.h"
enum class kCanvasMode
{
@@ -112,12 +113,15 @@ class CanvasModeFloodFill : public CanvasMode
{
const std::string m_cursor_path = "data/cursor/bucket-fill.png";
const uint16_t m_cursor_id = const_hash(m_cursor_path.c_str());
+ glm::vec2 m_cur_pos;
+ NodeToolBucket* m_tool;
public:
CanvasModeFloodFill() { hide_curor = true; }
- glm::vec2 m_cur_pos;
virtual void init() 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 enter(kCanvasMode prev) override;
+ virtual void leave(kCanvasMode next) override;
};
diff --git a/src/node.cpp b/src/node.cpp
index cb0afad..e9bb2c4 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -35,6 +35,7 @@
#include "node_changelog.h"
#include "node_usermanual.h"
#include "node_panel_quick.h"
+#include "node_tool_bucket.h"
void Node::app_redraw()
{
@@ -1248,6 +1249,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
CASE(kWidget::About, NodeAbout);
CASE(kWidget::Changelog, NodeChangelog);
CASE(kWidget::UserManual, NodeUserManual);
+ CASE(kWidget::ToolBucket, NodeToolBucket);
#undef CASE
case kWidget::Ref:
{
diff --git a/src/node.h b/src/node.h
index f3b94e5..30472a0 100644
--- a/src/node.h
+++ b/src/node.h
@@ -90,6 +90,7 @@ enum class kWidget : uint16_t
About = const_hash("about"),
Changelog = const_hash("changelog"),
UserManual = const_hash("usermanual"),
+ ToolBucket = const_hash("tool-bucket"),
};
class Node : public std::enable_shared_from_this
diff --git a/src/node_tool_bucket.cpp b/src/node_tool_bucket.cpp
new file mode 100644
index 0000000..9e137e7
--- /dev/null
+++ b/src/node_tool_bucket.cpp
@@ -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(dest);
+ n->init_controls();
+}
+
+void NodeToolBucket::init()
+{
+ parent::init();
+ init_template("tpl-tool-bucket");
+ init_controls();
+}
+
+void NodeToolBucket::init_controls()
+{
+ m_slider_threshold = find("threshold");
+}
+
+float NodeToolBucket::get_threshold() const
+{
+ return glm::max(1.f, m_slider_threshold->get_value() * 255.f);
+}
diff --git a/src/node_tool_bucket.h b/src/node_tool_bucket.h
new file mode 100644
index 0000000..e86bf80
--- /dev/null
+++ b/src/node_tool_bucket.h
@@ -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;
+};