mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 05:19:50 +01:00
Removed the diffferently styled context menu from the SpatialEditor and the CanvasItemEditor. New controls are now added directly to the main FlowContainer, so they wrap properly. While having a different background for context sensitive items can look good, it doesn't work well if it's not per plugin.
This commit is contained in:
parent
2b0a9700b8
commit
86ee8840ac
@ -3840,8 +3840,6 @@ void CanvasItemEditor::_notification(int p_what) {
|
||||
zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
|
||||
zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
|
||||
|
||||
_update_context_menu_stylebox();
|
||||
|
||||
presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons"));
|
||||
|
||||
PopupMenu *p = presets_menu->get_popup();
|
||||
@ -3958,18 +3956,6 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_update_context_menu_stylebox() {
|
||||
// This must be called when the theme changes to follow the new accent color.
|
||||
Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat);
|
||||
const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor");
|
||||
context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
|
||||
// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
|
||||
context_menu_stylebox->set_border_color(accent_color);
|
||||
context_menu_stylebox->set_border_width(MARGIN_BOTTOM, Math::round(2 * EDSCALE));
|
||||
context_menu_stylebox->set_default_margin(MARGIN_BOTTOM, 0);
|
||||
context_menu_panel->add_theme_style_override("panel", context_menu_stylebox);
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_update_scrollbars() {
|
||||
updating_scroll = true;
|
||||
|
||||
@ -5252,11 +5238,11 @@ void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) {
|
||||
void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
|
||||
ERR_FAIL_COND(!p_control);
|
||||
|
||||
context_menu_hbox->add_child(p_control);
|
||||
main_flow->add_child(p_control);
|
||||
}
|
||||
|
||||
void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) {
|
||||
context_menu_hbox->remove_child(p_control);
|
||||
main_flow->remove_child(p_control);
|
||||
}
|
||||
|
||||
void CanvasItemEditor::add_control_to_left_panel(Control *p_control) {
|
||||
@ -5381,7 +5367,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
||||
editor->call_deferred("connect", "stop_pressed", this, "_update_override_camera_button", make_binds(false));
|
||||
|
||||
// A fluid container for all toolbars.
|
||||
HFlowContainer *main_flow = memnew(HFlowContainer);
|
||||
main_flow = memnew(HFlowContainer);
|
||||
add_child(main_flow);
|
||||
|
||||
// Main toolbars.
|
||||
@ -5666,18 +5652,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
context_menu_panel = memnew(PanelContainer);
|
||||
context_menu_hbox = memnew(HBoxContainer);
|
||||
context_menu_panel->add_child(context_menu_hbox);
|
||||
// Use a custom stylebox to make contextual menu items stand out from the rest.
|
||||
// This helps with editor usability as contextual menu items change when selecting nodes,
|
||||
// even though it may not be immediately obvious at first.
|
||||
main_flow->add_child(context_menu_panel);
|
||||
_update_context_menu_stylebox();
|
||||
|
||||
presets_menu = memnew(MenuButton);
|
||||
presets_menu->set_text(TTR("Layout"));
|
||||
context_menu_hbox->add_child(presets_menu);
|
||||
main_flow->add_child(presets_menu);
|
||||
presets_menu->hide();
|
||||
presets_menu->set_switch_on_hover(true);
|
||||
|
||||
@ -5690,13 +5667,13 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
||||
anchors_popup->connect("id_pressed", this, "_popup_callback");
|
||||
|
||||
anchor_mode_button = memnew(ToolButton);
|
||||
context_menu_hbox->add_child(anchor_mode_button);
|
||||
main_flow->add_child(anchor_mode_button);
|
||||
anchor_mode_button->set_toggle_mode(true);
|
||||
anchor_mode_button->hide();
|
||||
anchor_mode_button->connect("toggled", this, "_button_toggle_anchor_mode");
|
||||
|
||||
animation_hb = memnew(HBoxContainer);
|
||||
context_menu_hbox->add_child(animation_hb);
|
||||
main_flow->add_child(animation_hb);
|
||||
animation_hb->add_child(memnew(VSeparator));
|
||||
animation_hb->hide();
|
||||
|
||||
|
@ -73,6 +73,7 @@ class VScrollBar;
|
||||
class VSplitContainer;
|
||||
class WindowDialog;
|
||||
struct Color;
|
||||
class HFlowContainer;
|
||||
|
||||
class CanvasItemEditorSelectedItem : public Object {
|
||||
GDCLASS(CanvasItemEditorSelectedItem, Object);
|
||||
@ -261,10 +262,7 @@ private:
|
||||
HScrollBar *h_scroll;
|
||||
VScrollBar *v_scroll;
|
||||
|
||||
// Used for secondary menu items which are displayed depending on the currently selected node
|
||||
// (such as MeshInstance's "Mesh" menu).
|
||||
PanelContainer *context_menu_panel;
|
||||
HBoxContainer *context_menu_hbox;
|
||||
HFlowContainer *main_flow;
|
||||
|
||||
ToolButton *zoom_minus;
|
||||
ToolButton *zoom_reset;
|
||||
@ -577,7 +575,6 @@ private:
|
||||
HSplitContainer *right_panel_split;
|
||||
VSplitContainer *bottom_split;
|
||||
|
||||
void _update_context_menu_stylebox();
|
||||
void _popup_warning_temporarily(Control *p_control, const float p_duration);
|
||||
void _popup_warning_depop(Control *p_control);
|
||||
|
||||
|
@ -6256,18 +6256,6 @@ void SpatialEditor::_init_indicators() {
|
||||
_generate_selection_boxes();
|
||||
}
|
||||
|
||||
void SpatialEditor::_update_context_menu_stylebox() {
|
||||
// This must be called when the theme changes to follow the new accent color.
|
||||
Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat);
|
||||
const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor");
|
||||
context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
|
||||
// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
|
||||
context_menu_stylebox->set_border_color(accent_color);
|
||||
context_menu_stylebox->set_border_width(MARGIN_BOTTOM, Math::round(2 * EDSCALE));
|
||||
context_menu_stylebox->set_default_margin(MARGIN_BOTTOM, 0);
|
||||
context_menu_panel->add_theme_style_override("panel", context_menu_stylebox);
|
||||
}
|
||||
|
||||
void SpatialEditor::_update_gizmos_menu() {
|
||||
gizmos_menu->clear();
|
||||
|
||||
@ -6762,7 +6750,6 @@ void SpatialEditor::_notification(int p_what) {
|
||||
_init_indicators();
|
||||
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
_update_gizmos_menu_theme();
|
||||
_update_context_menu_stylebox();
|
||||
} else if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
_finish_indicators();
|
||||
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
|
||||
@ -6830,11 +6817,11 @@ Vector<int> SpatialEditor::get_subgizmo_selection() {
|
||||
}
|
||||
|
||||
void SpatialEditor::add_control_to_menu_panel(Control *p_control) {
|
||||
context_menu_hbox->add_child(p_control);
|
||||
main_flow->add_child(p_control);
|
||||
}
|
||||
|
||||
void SpatialEditor::remove_control_from_menu_panel(Control *p_control) {
|
||||
context_menu_hbox->remove_child(p_control);
|
||||
main_flow->remove_child(p_control);
|
||||
}
|
||||
|
||||
void SpatialEditor::set_can_preview(Camera *p_preview) {
|
||||
@ -7134,7 +7121,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
||||
camera_override_viewport_id = 0;
|
||||
|
||||
// A fluid container for all toolbars.
|
||||
HFlowContainer *main_flow = memnew(HFlowContainer);
|
||||
main_flow = memnew(HFlowContainer);
|
||||
vbc->add_child(main_flow);
|
||||
|
||||
// Main toolbars.
|
||||
@ -7307,15 +7294,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
context_menu_panel = memnew(PanelContainer);
|
||||
context_menu_hbox = memnew(HBoxContainer);
|
||||
context_menu_panel->add_child(context_menu_hbox);
|
||||
// Use a custom stylebox to make contextual menu items stand out from the rest.
|
||||
// This helps with editor usability as contextual menu items change when selecting nodes,
|
||||
// even though it may not be immediately obvious at first.
|
||||
main_flow->add_child(context_menu_panel);
|
||||
_update_context_menu_stylebox();
|
||||
|
||||
// Get the view menu popup and have it stay open when a checkable item is selected
|
||||
p = view_menu->get_popup();
|
||||
p->set_hide_on_checkable_item_selection(false);
|
||||
|
@ -98,6 +98,7 @@ class VSplitContainer;
|
||||
class Viewport;
|
||||
class SpinBox;
|
||||
class ViewportNavigationControl;
|
||||
class HFlowContainer;
|
||||
|
||||
class ViewportRotationControl : public Control {
|
||||
GDCLASS(ViewportRotationControl, Control);
|
||||
@ -696,10 +697,7 @@ private:
|
||||
void _update_camera_override_button(bool p_game_running);
|
||||
void _update_camera_override_viewport(Object *p_viewport);
|
||||
|
||||
// Used for secondary menu items which are displayed depending on the currently selected node
|
||||
// (such as MeshInstance's "Mesh" menu).
|
||||
PanelContainer *context_menu_panel;
|
||||
HBoxContainer *context_menu_hbox;
|
||||
HFlowContainer *main_flow;
|
||||
|
||||
void _generate_selection_boxes();
|
||||
UndoRedo *undo_redo;
|
||||
@ -707,7 +705,6 @@ private:
|
||||
int camera_override_viewport_id;
|
||||
|
||||
void _init_indicators();
|
||||
void _update_context_menu_stylebox();
|
||||
void _update_gizmos_menu();
|
||||
void _update_gizmos_menu_theme();
|
||||
void _init_grid();
|
||||
|
Loading…
Reference in New Issue
Block a user