Skip to content

Commit 4e000e2

Browse files
committed
Merge pull request godotengine#106231 from Meorge/feat/movie-maker-dropdown-2-electric-boogaloo
Add dropdown to Movie Maker button in editor run bar to access settings
2 parents f5bf37a + e603833 commit 4e000e2

File tree

3 files changed

+53
-21
lines changed

3 files changed

+53
-21
lines changed

editor/gui/editor_run_bar.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "editor/gui/editor_bottom_panel.h"
4242
#include "editor/gui/editor_quick_open_dialog.h"
4343
#include "editor/gui/editor_toaster.h"
44+
#include "editor/project_settings_editor.h"
4445
#include "editor/themes/editor_scale.h"
4546
#include "scene/gui/box_container.h"
4647
#include "scene/gui/button.h"
@@ -95,20 +96,18 @@ void EditorRunBar::_notification(int p_what) {
9596

9697
if (is_movie_maker_enabled()) {
9798
main_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("LaunchPadMovieMode"), EditorStringName(EditorStyles)));
99+
write_movie_button->set_theme_type_variation("RunBarButtonMovieMakerEnabled");
100+
98101
write_movie_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("MovieWriterButtonPressed"), EditorStringName(EditorStyles)));
99102
} else {
100103
main_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("LaunchPadNormal"), EditorStringName(EditorStyles)));
104+
write_movie_button->set_theme_type_variation("RunBarButtonMovieMakerDisabled");
105+
101106
write_movie_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("MovieWriterButtonNormal"), EditorStringName(EditorStyles)));
102107
}
103108

104109
write_movie_button->set_button_icon(get_editor_theme_icon(SNAME("MainMovieWrite")));
105-
// This button behaves differently, so color it as such.
106-
write_movie_button->begin_bulk_theme_override();
107-
write_movie_button->add_theme_color_override("icon_normal_color", get_theme_color(SNAME("movie_writer_icon_normal"), EditorStringName(EditorStyles)));
108-
write_movie_button->add_theme_color_override("icon_pressed_color", get_theme_color(SNAME("movie_writer_icon_pressed"), EditorStringName(EditorStyles)));
109-
write_movie_button->add_theme_color_override("icon_hover_color", get_theme_color(SNAME("movie_writer_icon_hover"), EditorStringName(EditorStyles)));
110-
write_movie_button->add_theme_color_override("icon_hover_pressed_color", get_theme_color(SNAME("movie_writer_icon_hover_pressed"), EditorStringName(EditorStyles)));
111-
write_movie_button->end_bulk_theme_override();
110+
112111
} break;
113112
}
114113
}
@@ -157,6 +156,23 @@ void EditorRunBar::_update_play_buttons() {
157156
}
158157
}
159158

159+
void EditorRunBar::_movie_maker_item_pressed(int p_id) {
160+
switch (p_id) {
161+
case MOVIE_MAKER_TOGGLE: {
162+
bool new_enabled = !is_movie_maker_enabled();
163+
set_movie_maker_enabled(new_enabled);
164+
write_movie_button->get_popup()->set_item_checked(0, new_enabled);
165+
write_movie_button->set_pressed(new_enabled);
166+
_write_movie_toggled(new_enabled);
167+
break;
168+
}
169+
case MOVIE_MAKER_OPEN_SETTINGS:
170+
ProjectSettingsEditor::get_singleton()->popup_project_settings(true);
171+
ProjectSettingsEditor::get_singleton()->set_general_page("editor/movie_writer");
172+
break;
173+
}
174+
}
175+
160176
void EditorRunBar::_write_movie_toggled(bool p_enabled) {
161177
if (p_enabled) {
162178
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("LaunchPadMovieMode"), EditorStringName(EditorStyles)));
@@ -454,11 +470,12 @@ OS::ProcessID EditorRunBar::get_current_process() const {
454470
}
455471

456472
void EditorRunBar::set_movie_maker_enabled(bool p_enabled) {
457-
write_movie_button->set_pressed(p_enabled);
473+
movie_maker_enabled = p_enabled;
474+
write_movie_button->get_popup()->set_item_checked(0, p_enabled);
458475
}
459476

460477
bool EditorRunBar::is_movie_maker_enabled() const {
461-
return write_movie_button->is_pressed();
478+
return movie_maker_enabled;
462479
}
463480

464481
void EditorRunBar::update_profiler_autostart_indicator() {
@@ -655,13 +672,15 @@ EditorRunBar::EditorRunBar() {
655672
write_movie_panel = memnew(PanelContainer);
656673
main_hbox->add_child(write_movie_panel);
657674

658-
write_movie_button = memnew(Button);
675+
write_movie_button = memnew(MenuButton);
676+
PopupMenu *write_movie_popup = write_movie_button->get_popup();
677+
write_movie_popup->add_check_item(TTRC("Enable Movie Maker Mode"), MOVIE_MAKER_TOGGLE);
678+
write_movie_popup->add_item(TTRC("Open Movie Maker Settings..."), MOVIE_MAKER_OPEN_SETTINGS);
679+
write_movie_popup->connect(SceneStringName(id_pressed), callable_mp(this, &EditorRunBar::_movie_maker_item_pressed));
680+
659681
write_movie_panel->add_child(write_movie_button);
660-
write_movie_button->set_theme_type_variation("RunBarButton");
661-
write_movie_button->set_toggle_mode(true);
662-
write_movie_button->set_pressed(false);
682+
write_movie_button->set_theme_type_variation("RunBarButtonMovieMakerDisabled");
663683
write_movie_button->set_focus_mode(Control::FOCUS_NONE);
664684
write_movie_button->set_tooltip_text(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file."));
665685
write_movie_button->set_accessibility_name(TTRC("Enable Movie Maker Mode"));
666-
write_movie_button->connect(SceneStringName(toggled), callable_mp(this, &EditorRunBar::_write_movie_toggled));
667686
}

editor/gui/editor_run_bar.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
class Button;
3838
class EditorRunNative;
39+
class MenuButton;
3940
class PanelContainer;
4041
class HBoxContainer;
4142
class AcceptDialog;
@@ -72,8 +73,13 @@ class EditorRunBar : public MarginContainer {
7273
EditorRun editor_run;
7374
EditorRunNative *run_native = nullptr;
7475

76+
enum MovieMakerMenuItem {
77+
MOVIE_MAKER_TOGGLE,
78+
MOVIE_MAKER_OPEN_SETTINGS,
79+
};
7580
PanelContainer *write_movie_panel = nullptr;
76-
Button *write_movie_button = nullptr;
81+
MenuButton *write_movie_button = nullptr;
82+
bool movie_maker_enabled = false;
7783

7884
RunMode current_mode = RunMode::STOPPED;
7985
String run_custom_filename;
@@ -82,6 +88,7 @@ class EditorRunBar : public MarginContainer {
8288
void _reset_play_buttons();
8389
void _update_play_buttons();
8490

91+
void _movie_maker_item_pressed(int p_id);
8592
void _write_movie_toggled(bool p_enabled);
8693
void _quick_run_selected(const String &p_file_path, int p_id = -1);
8794

editor/themes/editor_theme_manager.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,18 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
19571957
p_theme->set_stylebox("disabled", "RunBarButton", menu_transparent_style);
19581958
p_theme->set_stylebox(SceneStringName(pressed), "RunBarButton", menu_transparent_style);
19591959

1960+
p_theme->set_type_variation("RunBarButtonMovieMakerDisabled", "RunBarButton");
1961+
p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.7));
1962+
p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
1963+
p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.9));
1964+
p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
1965+
1966+
p_theme->set_type_variation("RunBarButtonMovieMakerEnabled", "RunBarButton");
1967+
p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.7));
1968+
p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
1969+
p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.9));
1970+
p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
1971+
19601972
// Bottom panel.
19611973
Ref<StyleBoxFlat> style_bottom_panel = p_config.content_panel_style->duplicate();
19621974
style_bottom_panel->set_corner_radius_all(p_config.corner_radius * EDSCALE);
@@ -2020,12 +2032,6 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
20202032
style_write_movie_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
20212033
p_theme->set_stylebox("MovieWriterButtonPressed", EditorStringName(EditorStyles), style_write_movie_button);
20222034

2023-
// Movie writer button colors.
2024-
p_theme->set_color("movie_writer_icon_normal", EditorStringName(EditorStyles), Color(1, 1, 1, 0.7));
2025-
p_theme->set_color("movie_writer_icon_pressed", EditorStringName(EditorStyles), Color(0, 0, 0, 0.84));
2026-
p_theme->set_color("movie_writer_icon_hover", EditorStringName(EditorStyles), Color(1, 1, 1, 0.9));
2027-
p_theme->set_color("movie_writer_icon_hover_pressed", EditorStringName(EditorStyles), Color(0, 0, 0, 0.84));
2028-
20292035
// Profiler autostart indicator panel.
20302036
Ref<StyleBoxFlat> style_profiler_autostart = style_launch_pad->duplicate();
20312037
style_profiler_autostart->set_bg_color(Color(1, 0.867, 0.396));

0 commit comments

Comments
 (0)