Merge pull request #1074 from not-surt/master
Replace TileMapEditor floating tile palette with HSplitContainer.
This commit is contained in:
commit
ffe970daf6
|
@ -2683,6 +2683,11 @@ void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
|
||||||
hb->add_child(p_control);
|
hb->add_child(p_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HSplitContainer *CanvasItemEditor::get_palette_split() {
|
||||||
|
|
||||||
|
return palette_split;
|
||||||
|
}
|
||||||
|
|
||||||
CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
||||||
|
|
||||||
tool = TOOL_SELECT;
|
tool = TOOL_SELECT;
|
||||||
|
@ -2697,15 +2702,20 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
||||||
add_child( hb );
|
add_child( hb );
|
||||||
hb->set_area_as_parent_rect();
|
hb->set_area_as_parent_rect();
|
||||||
|
|
||||||
|
palette_split = memnew( HSplitContainer);
|
||||||
|
palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
add_child(palette_split);
|
||||||
|
|
||||||
Control *vp_base = memnew (Control);
|
Control *vp_base = memnew (Control);
|
||||||
add_child(vp_base);
|
|
||||||
vp_base->set_v_size_flags(SIZE_EXPAND_FILL);
|
vp_base->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
palette_split->add_child(vp_base);
|
||||||
|
|
||||||
Control *vp = memnew (Control);
|
Control *vp = memnew (Control);
|
||||||
vp_base->add_child(vp);
|
vp_base->add_child(vp);
|
||||||
vp->set_area_as_parent_rect();
|
vp->set_area_as_parent_rect();
|
||||||
vp->add_child(p_editor->get_scene_root());
|
vp->add_child(p_editor->get_scene_root());
|
||||||
|
|
||||||
|
|
||||||
viewport = memnew( Control );
|
viewport = memnew( Control );
|
||||||
vp_base->add_child(viewport);
|
vp_base->add_child(viewport);
|
||||||
viewport->set_area_as_parent_rect();
|
viewport->set_area_as_parent_rect();
|
||||||
|
|
|
@ -289,6 +289,10 @@ class CanvasItemEditor : public VBoxContainer {
|
||||||
|
|
||||||
void _viewport_input_event(const InputEvent& p_event);
|
void _viewport_input_event(const InputEvent& p_event);
|
||||||
void _viewport_draw();
|
void _viewport_draw();
|
||||||
|
|
||||||
|
private:
|
||||||
|
HSplitContainer *palette_split;
|
||||||
|
|
||||||
friend class CanvasItemEditorPlugin;
|
friend class CanvasItemEditorPlugin;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -341,6 +345,8 @@ public:
|
||||||
|
|
||||||
void add_control_to_menu_panel(Control *p_control);
|
void add_control_to_menu_panel(Control *p_control);
|
||||||
|
|
||||||
|
HSplitContainer *get_palette_split();
|
||||||
|
|
||||||
Control *get_viewport_control() { return viewport; }
|
Control *get_viewport_control() { return viewport; }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ void TileMapEditor::_notification(int p_what) {
|
||||||
|
|
||||||
case NOTIFICATION_READY: {
|
case NOTIFICATION_READY: {
|
||||||
|
|
||||||
pane_drag->connect("dragged", this,"_pane_drag");
|
|
||||||
mirror_x->set_icon( get_icon("MirrorX","EditorIcons"));
|
mirror_x->set_icon( get_icon("MirrorX","EditorIcons"));
|
||||||
mirror_y->set_icon( get_icon("MirrorY","EditorIcons"));
|
mirror_y->set_icon( get_icon("MirrorY","EditorIcons"));
|
||||||
|
|
||||||
|
@ -701,23 +700,10 @@ void TileMapEditor::_tileset_settings_changed() {
|
||||||
canvas_item_editor->update();
|
canvas_item_editor->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileMapEditor::_pane_drag(const Point2& p_to) {
|
|
||||||
|
|
||||||
int x = theme_panel->get_margin(MARGIN_RIGHT);
|
|
||||||
|
|
||||||
x+=p_to.x;
|
|
||||||
if (x<10)
|
|
||||||
x=10;
|
|
||||||
if (x>300)
|
|
||||||
x=300;
|
|
||||||
theme_panel->set_margin(MARGIN_RIGHT,x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TileMapEditor::_bind_methods() {
|
void TileMapEditor::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("_menu_option"),&TileMapEditor::_menu_option);
|
ObjectTypeDB::bind_method(_MD("_menu_option"),&TileMapEditor::_menu_option);
|
||||||
ObjectTypeDB::bind_method(_MD("_canvas_draw"),&TileMapEditor::_canvas_draw);
|
ObjectTypeDB::bind_method(_MD("_canvas_draw"),&TileMapEditor::_canvas_draw);
|
||||||
ObjectTypeDB::bind_method(_MD("_pane_drag"),&TileMapEditor::_pane_drag);
|
|
||||||
ObjectTypeDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
|
ObjectTypeDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
|
||||||
ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
|
ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
|
||||||
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
|
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
|
||||||
|
@ -731,36 +717,30 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
|
||||||
editor=p_editor;
|
editor=p_editor;
|
||||||
undo_redo = editor->get_undo_redo();
|
undo_redo = editor->get_undo_redo();
|
||||||
|
|
||||||
theme_panel = memnew( Panel );
|
int mw = EDITOR_DEF("tile_map/palette_min_width",80);
|
||||||
theme_panel->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
|
EmptyControl *ec = memnew( EmptyControl);
|
||||||
theme_panel->set_begin( Point2(0,26));
|
ec->set_minsize(Size2(mw,0));
|
||||||
theme_panel->set_end( Point2(100,0) );
|
add_child(ec);
|
||||||
p_editor->get_viewport()->add_child(theme_panel);
|
|
||||||
theme_panel->hide();
|
|
||||||
|
|
||||||
|
// Add tile palette
|
||||||
palette = memnew( Tree );
|
palette = memnew( Tree );
|
||||||
palette->set_area_as_parent_rect(4);
|
palette->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
palette->set_margin(MARGIN_TOP,25);;
|
add_child(palette);
|
||||||
theme_panel->add_child(palette);
|
|
||||||
|
|
||||||
pane_drag = memnew( PaneDrag ) ;
|
|
||||||
pane_drag->set_anchor(MARGIN_LEFT,ANCHOR_END);
|
|
||||||
pane_drag->set_begin(Point2(16,4));
|
|
||||||
theme_panel->add_child(pane_drag);
|
|
||||||
|
|
||||||
add_child( memnew( VSeparator ));
|
|
||||||
|
|
||||||
|
// Add menu items
|
||||||
|
HBoxContainer *canvas_item_editor_hb = memnew( HBoxContainer );
|
||||||
|
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb);
|
||||||
|
canvas_item_editor_hb->add_child( memnew( VSeparator ));
|
||||||
mirror_x = memnew( ToolButton );
|
mirror_x = memnew( ToolButton );
|
||||||
mirror_x->set_toggle_mode(true);
|
mirror_x->set_toggle_mode(true);
|
||||||
mirror_x->set_tooltip("Mirror X (A)");
|
mirror_x->set_tooltip("Mirror X (A)");
|
||||||
mirror_x->set_focus_mode(FOCUS_NONE);
|
mirror_x->set_focus_mode(FOCUS_NONE);
|
||||||
add_child(mirror_x);
|
canvas_item_editor_hb->add_child(mirror_x);
|
||||||
mirror_y = memnew( ToolButton );
|
mirror_y = memnew( ToolButton );
|
||||||
mirror_y->set_toggle_mode(true);
|
mirror_y->set_toggle_mode(true);
|
||||||
mirror_y->set_tooltip("Mirror Y (S)");
|
mirror_y->set_tooltip("Mirror Y (S)");
|
||||||
mirror_y->set_focus_mode(FOCUS_NONE);
|
mirror_y->set_focus_mode(FOCUS_NONE);
|
||||||
add_child(mirror_y);
|
canvas_item_editor_hb->add_child(mirror_y);
|
||||||
|
|
||||||
|
|
||||||
tool=TOOL_NONE;
|
tool=TOOL_NONE;
|
||||||
selection_active=false;
|
selection_active=false;
|
||||||
|
@ -782,12 +762,10 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
|
||||||
|
|
||||||
if (p_visible) {
|
if (p_visible) {
|
||||||
tile_map_editor->show();
|
tile_map_editor->show();
|
||||||
tile_map_editor->theme_panel->show();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
tile_map_editor->hide();
|
tile_map_editor->hide();
|
||||||
tile_map_editor->theme_panel->hide();
|
|
||||||
tile_map_editor->edit(NULL);
|
tile_map_editor->edit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,7 +775,8 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
|
||||||
|
|
||||||
editor=p_node;
|
editor=p_node;
|
||||||
tile_map_editor = memnew( TileMapEditor(p_node) );
|
tile_map_editor = memnew( TileMapEditor(p_node) );
|
||||||
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(tile_map_editor);
|
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(tile_map_editor);
|
||||||
|
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor,0);
|
||||||
|
|
||||||
tile_map_editor->hide();
|
tile_map_editor->hide();
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,14 @@
|
||||||
#include "scene/2d/tile_map.h"
|
#include "scene/2d/tile_map.h"
|
||||||
#include "scene/gui/tool_button.h"
|
#include "scene/gui/tool_button.h"
|
||||||
#include "scene/gui/button_group.h"
|
#include "scene/gui/button_group.h"
|
||||||
#include "tools/editor/pane_drag.h"
|
|
||||||
/**
|
/**
|
||||||
@author Juan Linietsky <reduzio@gmail.com>
|
@author Juan Linietsky <reduzio@gmail.com>
|
||||||
*/
|
*/
|
||||||
class CanvasItemEditor;
|
class CanvasItemEditor;
|
||||||
|
|
||||||
class TileMapEditor : public HBoxContainer {
|
class TileMapEditor : public VBoxContainer {
|
||||||
|
|
||||||
OBJ_TYPE(TileMapEditor, BoxContainer );
|
OBJ_TYPE(TileMapEditor, VBoxContainer );
|
||||||
|
|
||||||
UndoRedo *undo_redo;
|
UndoRedo *undo_redo;
|
||||||
|
|
||||||
|
@ -63,7 +62,6 @@ class TileMapEditor : public HBoxContainer {
|
||||||
Panel *panel;
|
Panel *panel;
|
||||||
TileMap *node;
|
TileMap *node;
|
||||||
MenuButton *options;
|
MenuButton *options;
|
||||||
PaneDrag *pane_drag;
|
|
||||||
|
|
||||||
bool selection_active;
|
bool selection_active;
|
||||||
Point2i selection_begin;
|
Point2i selection_begin;
|
||||||
|
@ -88,7 +86,6 @@ class TileMapEditor : public HBoxContainer {
|
||||||
int get_selected_tile() const;
|
int get_selected_tile() const;
|
||||||
|
|
||||||
void _update_palette();
|
void _update_palette();
|
||||||
void _pane_drag(const Point2& p_to);
|
|
||||||
void _canvas_draw();
|
void _canvas_draw();
|
||||||
void _menu_option(int p_option);
|
void _menu_option(int p_option);
|
||||||
|
|
||||||
|
@ -99,8 +96,6 @@ class TileMapEditor : public HBoxContainer {
|
||||||
void _tileset_settings_changed();
|
void _tileset_settings_changed();
|
||||||
|
|
||||||
|
|
||||||
friend class TileMapEditorPlugin;
|
|
||||||
Panel *theme_panel;
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
void _node_removed(Node *p_node);
|
void _node_removed(Node *p_node);
|
||||||
|
|
Loading…
Reference in New Issue