mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 12:26:59 +01:00
Now PaintEditorPlugin creates the paint sidebar.
This commit is contained in:
parent
229677acf5
commit
5baff6410f
@ -23,6 +23,14 @@ SOFTWARE.
|
||||
#include "paint_editor_plugin.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||
|
||||
#include "ui/paint_sidebar.h"
|
||||
|
||||
PaintSidebar *PaintEditorPlugin::get_sidebar() {
|
||||
return _sidebar;
|
||||
}
|
||||
|
||||
void PaintEditorPlugin::make_visible(const bool visible) {
|
||||
}
|
||||
@ -34,6 +42,19 @@ String PaintEditorPlugin::get_name() const {
|
||||
PaintEditorPlugin::PaintEditorPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
|
||||
EDITOR_DEF("editors/paint/editor_side", 0);
|
||||
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/paint/editor_side", PROPERTY_HINT_ENUM, "Left,Right"));
|
||||
|
||||
_sidebar = memnew(PaintSidebar);
|
||||
switch ((int)EditorSettings::get_singleton()->get("editors/paint/editor_side")) {
|
||||
case 0: { // Left.
|
||||
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_LEFT, _sidebar);
|
||||
} break;
|
||||
case 1: { // Right.
|
||||
add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, _sidebar);
|
||||
} break;
|
||||
}
|
||||
|
||||
make_visible(false);
|
||||
|
||||
Engine::get_singleton()->add_global("PaintEditorPlugin", this);
|
||||
@ -43,5 +64,19 @@ PaintEditorPlugin::~PaintEditorPlugin() {
|
||||
Engine::get_singleton()->remove_global("PaintEditorPlugin");
|
||||
}
|
||||
|
||||
void PaintEditorPlugin::_bind_methods() {
|
||||
void PaintEditorPlugin::_notification(int p_what) {
|
||||
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||
switch ((int)EditorSettings::get_singleton()->get("editors/paint/editor_side")) {
|
||||
case 0: { // Left.
|
||||
CanvasItemEditor::get_singleton()->move_control_to_left_panel(_sidebar);
|
||||
} break;
|
||||
case 1: { // Right.
|
||||
CanvasItemEditor::get_singleton()->move_control_to_right_panel(_sidebar);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaintEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_sidebar"), &PaintEditorPlugin::get_sidebar);
|
||||
}
|
||||
|
@ -28,11 +28,15 @@ SOFTWARE.
|
||||
|
||||
class PaintWindow;
|
||||
class Texture;
|
||||
class PaintSidebar;
|
||||
|
||||
class PaintEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(PaintEditorPlugin, EditorPlugin);
|
||||
|
||||
public:
|
||||
//maybe the plugin should have sidebars on both sides?
|
||||
PaintSidebar *get_sidebar();
|
||||
|
||||
void make_visible(const bool visible);
|
||||
String get_name() const;
|
||||
|
||||
@ -42,7 +46,11 @@ public:
|
||||
EditorNode *editor;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
PaintSidebar *_sidebar;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user