Browse Source

Merge pull request #106780 from arkology/no-more-distraction

Add "Distraction Free Mode" button to `EditorBottomPanel` when bottom panel is expanded
Thaddeus Crews 1 month ago
parent
commit
fc15c8f63f
3 changed files with 27 additions and 1 deletions
  1. 11 1
      editor/editor_node.cpp
  2. 3 0
      editor/editor_node.h
  3. 13 0
      editor/gui/editor_bottom_panel.cpp

+ 11 - 1
editor/editor_node.cpp

@@ -679,7 +679,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
 		editor_main_screen->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles)));
 		editor_main_screen->add_theme_style_override(SceneStringName(panel), theme->get_stylebox(SNAME("Content"), EditorStringName(EditorStyles)));
 		bottom_panel->_theme_changed();
 		bottom_panel->_theme_changed();
 		distraction_free->set_button_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons)));
 		distraction_free->set_button_icon(theme->get_icon(SNAME("DistractionFree"), EditorStringName(EditorIcons)));
-		distraction_free->add_theme_style_override(SceneStringName(pressed), theme->get_stylebox(CoreStringName(normal), "FlatMenuButton"));
+		update_distraction_free_button_theme();
 
 
 		help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), _get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode));
 		help_menu->set_item_icon(help_menu->get_item_index(HELP_SEARCH), _get_editor_theme_native_menu_icon(SNAME("HelpSearch"), global_menu, dark_mode));
 		help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), _get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode));
 		help_menu->set_item_icon(help_menu->get_item_index(HELP_COPY_SYSTEM_INFO), _get_editor_theme_native_menu_icon(SNAME("ActionCopy"), global_menu, dark_mode));
@@ -6568,6 +6568,16 @@ bool EditorNode::is_distraction_free_mode_enabled() const {
 	return distraction_free->is_pressed();
 	return distraction_free->is_pressed();
 }
 }
 
 
+void EditorNode::update_distraction_free_button_theme() {
+	if (distraction_free->get_meta("_scene_tabs_owned", true)) {
+		distraction_free->set_theme_type_variation("FlatMenuButton");
+		distraction_free->add_theme_style_override(SceneStringName(pressed), theme->get_stylebox(CoreStringName(normal), "FlatMenuButton"));
+	} else {
+		distraction_free->set_theme_type_variation("BottomPanelButton");
+		distraction_free->remove_theme_style_override(SceneStringName(pressed));
+	}
+}
+
 void EditorNode::set_center_split_offset(int p_offset) {
 void EditorNode::set_center_split_offset(int p_offset) {
 	center_split->set_split_offset(p_offset);
 	center_split->set_split_offset(p_offset);
 }
 }

+ 3 - 0
editor/editor_node.h

@@ -750,6 +750,8 @@ public:
 	static EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; }
 	static EditorBottomPanel *get_bottom_panel() { return singleton->bottom_panel; }
 	static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; }
 	static EditorMainScreen *get_editor_main_screen() { return singleton->editor_main_screen; }
 
 
+	static Button *get_distraction_free_button() { return singleton->distraction_free; }
+
 	static String adjust_scene_name_casing(const String &p_root_name);
 	static String adjust_scene_name_casing(const String &p_root_name);
 	static String adjust_script_name_casing(const String &p_file_name, ScriptLanguage::ScriptNameCasing p_auto_casing);
 	static String adjust_script_name_casing(const String &p_file_name, ScriptLanguage::ScriptNameCasing p_auto_casing);
 
 
@@ -800,6 +802,7 @@ public:
 	void update_distraction_free_mode();
 	void update_distraction_free_mode();
 	void set_distraction_free_mode(bool p_enter);
 	void set_distraction_free_mode(bool p_enter);
 	bool is_distraction_free_mode_enabled() const;
 	bool is_distraction_free_mode_enabled() const;
+	void update_distraction_free_button_theme();
 
 
 	void set_center_split_offset(int p_offset);
 	void set_center_split_offset(int p_offset);
 
 

+ 13 - 0
editor/gui/editor_bottom_panel.cpp

@@ -36,6 +36,7 @@
 #include "editor/editor_string_names.h"
 #include "editor/editor_string_names.h"
 #include "editor/gui/editor_toaster.h"
 #include "editor/gui/editor_toaster.h"
 #include "editor/gui/editor_version_button.h"
 #include "editor/gui/editor_version_button.h"
+#include "editor/scene/editor_scene_tabs.h"
 #include "editor/settings/editor_command_palette.h"
 #include "editor/settings/editor_command_palette.h"
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_scale.h"
 #include "scene/gui/box_container.h"
 #include "scene/gui/box_container.h"
@@ -186,6 +187,18 @@ void EditorBottomPanel::set_expanded(bool p_expanded) {
 
 
 void EditorBottomPanel::_expand_button_toggled(bool p_pressed) {
 void EditorBottomPanel::_expand_button_toggled(bool p_pressed) {
 	EditorNode::get_top_split()->set_visible(!p_pressed);
 	EditorNode::get_top_split()->set_visible(!p_pressed);
+
+	Button *distraction_free = EditorNode::get_singleton()->get_distraction_free_button();
+	distraction_free->set_meta("_scene_tabs_owned", !p_pressed);
+	EditorNode::get_singleton()->update_distraction_free_button_theme();
+	if (p_pressed) {
+		distraction_free->reparent(bottom_hbox);
+		bottom_hbox->move_child(distraction_free, -2);
+	} else {
+		distraction_free->get_parent()->remove_child(distraction_free);
+		EditorSceneTabs::get_singleton()->add_extra_button(distraction_free);
+	}
+	_theme_changed();
 }
 }
 
 
 void EditorBottomPanel::_update_center_split_offset() {
 void EditorBottomPanel::_update_center_split_offset() {