The PaintColorGrid now contains a ScrollContainer.

This commit is contained in:
Relintai 2022-11-15 22:24:00 +01:00
parent ff701c35ad
commit 73e7d7f8ce
2 changed files with 16 additions and 11 deletions

View File

@ -1318,17 +1318,17 @@ PaintWindow::PaintWindow() {
left_main_margin_container->add_child(left_main_vbox_container); left_main_margin_container->add_child(left_main_vbox_container);
//Main Content Mid (App) -- Left Panel -- Margin container -- VBoxContainer -- Colors //Main Content Mid (App) -- Left Panel -- Margin container -- VBoxContainer -- Colors
ScrollContainer *left_color_scroll_container = memnew(ScrollContainer); //ScrollContainer *left_color_scroll_container = memnew(ScrollContainer);
left_color_scroll_container->set_custom_minimum_size(Size2(0, 145)); //left_color_scroll_container->set_custom_minimum_size(Size2(0, 145));
left_main_vbox_container->add_child(left_color_scroll_container); //left_main_vbox_container->add_child(left_color_scroll_container);
color_grid = memnew(PaintColorGrid); 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_custom_minimum_size(Size2(0, 145));
color_grid->set_h_size_flags(SIZE_EXPAND_FILL); //color_grid->set_h_size_flags(SIZE_EXPAND_FILL);
color_grid->set_v_size_flags(SIZE_EXPAND_FILL); //color_grid->set_v_size_flags(SIZE_EXPAND_FILL);
color_grid->connect("color_change_request", this, "change_color"); color_grid->connect("color_change_request", this, "change_color");
left_color_scroll_container->add_child(color_grid); left_main_vbox_container->add_child(color_grid);
//Main Content Mid (App) -- Left Panel -- Margin container -- VBoxContainer -- Lock Alpha Button //Main Content Mid (App) -- Left Panel -- Margin container -- VBoxContainer -- Lock Alpha Button
lock_alpha_button = memnew(CheckButton); lock_alpha_button = memnew(CheckButton);

View File

@ -26,6 +26,7 @@ SOFTWARE.
#include "scene/gui/button.h" #include "scene/gui/button.h"
#include "scene/gui/grid_container.h" #include "scene/gui/grid_container.h"
#include "scene/gui/scroll_container.h"
#include "scene/resources/style_box.h" #include "scene/resources/style_box.h"
void PaintColorGrid::change_color_to(const Color &color) { void PaintColorGrid::change_color_to(const Color &color) {
@ -54,18 +55,22 @@ void PaintColorGrid::add_color_prefab(const Color &color) {
} }
PaintColorGrid::PaintColorGrid() { PaintColorGrid::PaintColorGrid() {
ScrollContainer *scroll_container = memnew(ScrollContainer);
scroll_container->set_custom_minimum_size(Size2(0, 145));
scroll_container->set_enable_h_scroll(false);
add_child(scroll_container);
_grid = memnew(GridContainer); _grid = memnew(GridContainer);
add_child(_grid); scroll_container->add_child(_grid);
_grid->set_columns(4); _grid->set_columns(4);
//color_grid->set_custom_minimum_size(Size2(0, 145)); //_grid->set_custom_minimum_size(Size2(0, 145));
//color_grid->set_h_size_flags(SIZE_EXPAND_FILL); _grid->set_h_size_flags(SIZE_EXPAND_FILL);
//color_grid->set_v_size_flags(SIZE_EXPAND_FILL); _grid->set_v_size_flags(SIZE_EXPAND_FILL);
for (int i = 0; i < 24; ++i) { for (int i = 0; i < 24; ++i) {
add_color_prefab(Color(Math::randf(), Math::randf(), Math::randf())); add_color_prefab(Color(Math::randf(), Math::randf(), Math::randf()));
} }
} }
PaintColorGrid::~PaintColorGrid() { PaintColorGrid::~PaintColorGrid() {