PaintColorGrid now inherits from PaintSidebarModule. It is also added to the new sidebar by the paint plugin.

This commit is contained in:
Relintai 2022-11-15 21:59:04 +01:00
parent abe142b090
commit e044b007f6
6 changed files with 29 additions and 10 deletions

View File

@ -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")

View File

@ -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);

View File

@ -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);

View File

@ -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"

View File

@ -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<StyleBoxFlat> 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() {

View File

@ -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