diff --git a/modules/paint/SCsub b/modules/paint/SCsub index 5492bf7d6..2d9c2a0aa 100644 --- a/modules/paint/SCsub +++ b/modules/paint/SCsub @@ -25,7 +25,7 @@ module_env.add_source_files(env.modules_sources,"deprecated/dialogs/paint_load_f module_env.add_source_files(env.modules_sources,"deprecated/dialogs/paint_save_file_dialog.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_canvas_outline.cpp") -module_env.add_source_files(env.modules_sources,"ui/paint_color_grid.cpp") +module_env.add_source_files(env.modules_sources,"ui/sidebar_modules/paint_color_grid.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_canvas_background.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_selection_box.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_visual_grid.cpp") diff --git a/modules/paint/deprecated/paint_window.cpp b/modules/paint/deprecated/paint_window.cpp index d33670cb1..51e586f73 100644 --- a/modules/paint/deprecated/paint_window.cpp +++ b/modules/paint/deprecated/paint_window.cpp @@ -43,7 +43,7 @@ SOFTWARE. #include "paint_canvas.h" #include "../ui/paint_canvas_background.h" #include "paint_canvas_layer.h" -#include "../ui/paint_color_grid.h" +#include "../ui/sidebar_modules/paint_color_grid.h" #include "paint_layer_button.h" #include "paint_navbar.h" #include "../paint_utilities.h" @@ -60,6 +60,7 @@ SOFTWARE. #include "scene/gui/slider.h" #include "scene/gui/texture_button.h" #include "scene/gui/texture_rect.h" +#include "scene/gui/grid_container.h" #include "dialogs/paint_canvas_dialog.h" #include "dialogs/paint_change_grid_size_dialog.h" @@ -1322,7 +1323,7 @@ PaintWindow::PaintWindow() { left_main_vbox_container->add_child(left_color_scroll_container); color_grid = memnew(PaintColorGrid); - color_grid->set_columns(4); + //color_grid->set_columns(4); color_grid->set_custom_minimum_size(Size2(0, 145)); color_grid->set_h_size_flags(SIZE_EXPAND_FILL); color_grid->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/modules/paint/paint_editor_plugin.cpp b/modules/paint/paint_editor_plugin.cpp index 03833741a..32786500f 100644 --- a/modules/paint/paint_editor_plugin.cpp +++ b/modules/paint/paint_editor_plugin.cpp @@ -27,6 +27,7 @@ SOFTWARE. #include "editor/plugins/canvas_item_editor_plugin.h" #include "ui/paint_sidebar.h" +#include "ui/sidebar_modules/paint_color_grid.h" PaintSidebar *PaintEditorPlugin::get_sidebar() { return _sidebar; @@ -56,6 +57,9 @@ PaintEditorPlugin::PaintEditorPlugin(EditorNode *p_node) { } break; } + PaintColorGrid *paint_color_grid = memnew(PaintColorGrid); + _sidebar->add_module(paint_color_grid); + make_visible(false); Engine::get_singleton()->add_global("PaintEditorPlugin", this); diff --git a/modules/paint/register_types.cpp b/modules/paint/register_types.cpp index 72f469180..fa61acd90 100644 --- a/modules/paint/register_types.cpp +++ b/modules/paint/register_types.cpp @@ -40,7 +40,7 @@ SOFTWARE. #include "ui/paint_canvas_background.h" #include "ui/paint_canvas_outline.h" -#include "ui/paint_color_grid.h" +#include "ui/sidebar_modules/paint_color_grid.h" #include "ui/paint_selection_box.h" #include "ui/paint_visual_grid.h" diff --git a/modules/paint/ui/paint_color_grid.cpp b/modules/paint/ui/sidebar_modules/paint_color_grid.cpp similarity index 87% rename from modules/paint/ui/paint_color_grid.cpp rename to modules/paint/ui/sidebar_modules/paint_color_grid.cpp index d797fa691..b2cc6752b 100644 --- a/modules/paint/ui/paint_color_grid.cpp +++ b/modules/paint/ui/sidebar_modules/paint_color_grid.cpp @@ -25,6 +25,7 @@ SOFTWARE. #include "paint_color_grid.h" #include "scene/gui/button.h" +#include "scene/gui/grid_container.h" #include "scene/resources/style_box.h" void PaintColorGrid::change_color_to(const Color &color) { @@ -32,13 +33,13 @@ void PaintColorGrid::change_color_to(const Color &color) { } void PaintColorGrid::add_color_prefab(const Color &color) { Button *button = memnew(Button); - + button->set_custom_minimum_size(Size2(25, 25)); button->set_h_size_flags(SIZE_EXPAND_FILL); button->set_v_size_flags(SIZE_EXPAND_FILL); - add_child(button); - move_child(button, 0); + _grid->add_child(button); + _grid->move_child(button, 0); Ref style_box; style_box.instance(); @@ -53,9 +54,18 @@ void PaintColorGrid::add_color_prefab(const Color &color) { } PaintColorGrid::PaintColorGrid() { + _grid = memnew(GridContainer); + add_child(_grid); + + _grid->set_columns(4); + //color_grid->set_custom_minimum_size(Size2(0, 145)); + //color_grid->set_h_size_flags(SIZE_EXPAND_FILL); + //color_grid->set_v_size_flags(SIZE_EXPAND_FILL); + for (int i = 0; i < 24; ++i) { add_color_prefab(Color(Math::randf(), Math::randf(), Math::randf())); } + } PaintColorGrid::~PaintColorGrid() { diff --git a/modules/paint/ui/paint_color_grid.h b/modules/paint/ui/sidebar_modules/paint_color_grid.h similarity index 88% rename from modules/paint/ui/paint_color_grid.h rename to modules/paint/ui/sidebar_modules/paint_color_grid.h index bc78f1179..45ffa059b 100644 --- a/modules/paint/ui/paint_color_grid.h +++ b/modules/paint/ui/sidebar_modules/paint_color_grid.h @@ -25,10 +25,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "scene/gui/grid_container.h" +#include "../paint_sidebar_module.h" -class PaintColorGrid : public GridContainer { - GDCLASS(PaintColorGrid, GridContainer); +class GridContainer; + +class PaintColorGrid : public PaintSidebarModule { + GDCLASS(PaintColorGrid, PaintSidebarModule); public: void change_color_to(const Color &color); @@ -39,6 +41,8 @@ public: protected: static void _bind_methods(); + + GridContainer *_grid; }; #endif