Make the OptionButton match the width of the pop-up menu
The difference in width compared to the popup is due to the potentially different widths of the dedicated icons/styleboxes. Make the width at least the width of the popup. (cherry picked from commit b887d57671d88a754cff9ae8f7169ac46cbcb7c6)
This commit is contained in:
1 parent
4e8568cdac
commit
e57fc9f439
11 files changed
+21
No files matched your search
@@ -2158,6 +2158,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
|
||||
animation->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
animation->set_tooltip_text(TTRC("Display list of animations in player."));
|
||||
animation->set_clip_text(true);
|
||||
animation->set_fit_to_longest_item(false);
|
||||
animation->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
|
||||
autoplay = memnew(Button);
|
||||
|
||||
@@ -2171,6 +2171,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||
|
||||
sort->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
sort->set_clip_text(true);
|
||||
sort->set_fit_to_longest_item(false);
|
||||
sort->connect(SceneStringName(item_selected), callable_mp(this, &EditorAssetLibrary::_search).bind(1).unbind(1));
|
||||
|
||||
search_hb2->add_child(memnew(Label(TTRC("Category:"))));
|
||||
@@ -2182,6 +2183,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||
}
|
||||
categories->set_disabled(true);
|
||||
categories->set_clip_text(true);
|
||||
categories->set_fit_to_longest_item(false);
|
||||
categories->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
search_hb2->add_child(categories);
|
||||
categories->connect(SceneStringName(item_selected), callable_mp(this, &EditorAssetLibrary::_search).bind(1).unbind(1));
|
||||
@@ -2190,6 +2192,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
||||
repository = memnew(OptionButton);
|
||||
repository->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
repository->set_clip_text(true);
|
||||
repository->set_fit_to_longest_item(false);
|
||||
search_hb2->add_child(repository);
|
||||
repository->connect(SceneStringName(item_selected), callable_mp(this, &EditorAssetLibrary::_repository_changed));
|
||||
_update_repository_options();
|
||||
|
||||
@@ -1142,6 +1142,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
|
||||
send->set_accessibility_name(TTRC("Send"));
|
||||
send->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
send->set_clip_text(true);
|
||||
send->set_fit_to_longest_item(false);
|
||||
send->connect(SceneStringName(item_selected), callable_mp(this, &EditorAudioBus::_send_selected));
|
||||
vb->add_child(send);
|
||||
|
||||
|
||||
@@ -585,6 +585,7 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
|
||||
option_button->set_accessibility_name(TTRC("Enum Options"));
|
||||
option_button->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
option_button->set_clip_text(true);
|
||||
option_button->set_fit_to_longest_item(false);
|
||||
option_button->set_flat(true);
|
||||
option_button->set_search_bar_enabled(true);
|
||||
option_button->set_search_bar_min_item_count(10);
|
||||
@@ -997,6 +998,7 @@ OptionButton *EditorPropertyEnum::get_option_button() {
|
||||
EditorPropertyEnum::EditorPropertyEnum() {
|
||||
options = memnew(OptionButton);
|
||||
options->set_clip_text(true);
|
||||
options->set_fit_to_longest_item(false);
|
||||
options->set_flat(true);
|
||||
options->set_theme_type_variation(SNAME("EditorInspectorButton"));
|
||||
options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
|
||||
@@ -1568,6 +1568,7 @@ ProjectManager::ProjectManager() {
|
||||
|
||||
filter_option = memnew(OptionButton);
|
||||
filter_option->set_clip_text(true);
|
||||
filter_option->set_fit_to_longest_item(false);
|
||||
filter_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
filter_option->set_stretch_ratio(0.3);
|
||||
filter_option->set_accessibility_name(TTRC("Sort:"));
|
||||
|
||||
@@ -244,6 +244,7 @@ void EditorPropertyAnchorsPreset::setup(const Vector<String> &p_options) {
|
||||
EditorPropertyAnchorsPreset::EditorPropertyAnchorsPreset() {
|
||||
options = memnew(OptionButton);
|
||||
options->set_clip_text(true);
|
||||
options->set_fit_to_longest_item(false);
|
||||
options->set_flat(true);
|
||||
options->set_theme_type_variation(SNAME("EditorInspectorButton"));
|
||||
add_child(options);
|
||||
@@ -427,6 +428,7 @@ EditorPropertySizeFlags::EditorPropertySizeFlags() {
|
||||
|
||||
flag_presets = memnew(OptionButton);
|
||||
flag_presets->set_clip_text(true);
|
||||
flag_presets->set_fit_to_longest_item(false);
|
||||
flag_presets->set_flat(true);
|
||||
flag_presets->set_theme_type_variation(SNAME("EditorInspectorButton"));
|
||||
vb->add_child(flag_presets);
|
||||
|
||||
@@ -1403,6 +1403,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
branch_select->set_tooltip_text(TTR("Branches"));
|
||||
branch_select->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
branch_select->set_clip_text(true);
|
||||
branch_select->set_fit_to_longest_item(false);
|
||||
branch_select->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_branch_item_selected));
|
||||
branch_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list));
|
||||
menu_bar->add_child(branch_select);
|
||||
@@ -1450,6 +1451,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
remote_select->set_tooltip_text(TTR("Remotes"));
|
||||
remote_select->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
remote_select->set_clip_text(true);
|
||||
remote_select->set_fit_to_longest_item(false);
|
||||
remote_select->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_remote_selected));
|
||||
remote_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list));
|
||||
menu_bar->add_child(remote_select);
|
||||
|
||||
@@ -85,6 +85,7 @@ void EditorPropertyActionSet::set_option_button_clip(bool p_enable) {
|
||||
EditorPropertyActionSet::EditorPropertyActionSet() {
|
||||
options = memnew(OptionButton);
|
||||
options->set_clip_text(true);
|
||||
options->set_fit_to_longest_item(false);
|
||||
options->set_flat(true);
|
||||
options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
add_child(options);
|
||||
@@ -155,6 +156,7 @@ void EditorPropertyBindingPath::set_option_button_clip(bool p_enable) {
|
||||
EditorPropertyBindingPath::EditorPropertyBindingPath() {
|
||||
options = memnew(OptionButton);
|
||||
options->set_clip_text(true);
|
||||
options->set_fit_to_longest_item(false);
|
||||
options->set_flat(true);
|
||||
options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
add_child(options);
|
||||
|
||||
@@ -8368,6 +8368,7 @@ EditorPropertyVisualShaderMode::EditorPropertyVisualShaderMode() {
|
||||
options = memnew(OptionButton);
|
||||
options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||
options->set_clip_text(true);
|
||||
options->set_fit_to_longest_item(false);
|
||||
add_child(options);
|
||||
add_focusable(options);
|
||||
options->connect(SceneStringName(item_selected), callable_mp(this, &EditorPropertyVisualShaderMode::_option_selected));
|
||||
|
||||
@@ -2627,6 +2627,7 @@ FileDialog::FileDialog() {
|
||||
filter->set_stretch_ratio(3);
|
||||
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
filter->set_clip_text(true); // Too many extensions overflows it.
|
||||
filter->set_fit_to_longest_item(false);
|
||||
file_box->add_child(filter);
|
||||
filter->connect(SceneStringName(item_selected), callable_mp(this, &FileDialog::_filter_selected));
|
||||
|
||||
|
||||
@@ -71,6 +71,11 @@ Size2 OptionButton::get_minimum_size() const {
|
||||
minsize = content_size + padding;
|
||||
}
|
||||
|
||||
if (fit_to_longest_item) {
|
||||
// Make the width at least the width of the popup.
|
||||
minsize.width = MAX(minsize.width, popup->get_contents_minimum_size().width);
|
||||
}
|
||||
|
||||
return minsize;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user