Merge pull request #58813 from KoBeWi/reset_minsize

Remove set_as_minsize()
This commit is contained in:
Rémi Verschelde 2022-03-06 08:10:28 +01:00 committed by GitHub
commit b70a83a2b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 18 additions and 24 deletions

View File

@ -946,7 +946,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
if (menu->get_item_count()) {
menu->set_as_minsize();
menu->reset_size();
menu->set_position(popup_pos);
menu->popup();
}

View File

@ -2748,7 +2748,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE);
menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER);
menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE);
menu->set_as_minsize();
menu->reset_size();
Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height);
menu->set_position(popup_pos);
@ -2766,7 +2766,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST);
menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR);
menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC);
menu->set_as_minsize();
menu->reset_size();
Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height);
menu->set_position(popup_pos);
@ -2783,7 +2783,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
menu->clear();
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP);
menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP);
menu->set_as_minsize();
menu->reset_size();
Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height);
menu->set_position(popup_pos);
@ -2885,7 +2885,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
menu->add_separator();
menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE);
}
menu->set_as_minsize();
menu->reset_size();
menu->set_position(get_screen_position() + get_local_mouse_position());
menu->popup();

View File

@ -732,7 +732,7 @@ void EditorNode::_notification(int p_what) {
}
_update_scene_tabs();
recent_scenes->set_as_minsize();
recent_scenes->reset_size();
// debugger area
if (EditorDebuggerNode::get_singleton()->is_visible()) {
@ -3791,7 +3791,7 @@ void EditorNode::_update_recent_scenes() {
recent_scenes->add_separator();
recent_scenes->add_shortcut(ED_SHORTCUT("editor/clear_recent", TTR("Clear Recent Scenes")));
recent_scenes->set_as_minsize();
recent_scenes->reset_size();
}
void EditorNode::_quick_opened() {
@ -5432,7 +5432,7 @@ void EditorNode::remove_tool_menu_item(const String &p_name) {
memdelete(n);
}
tool_menu->remove_item(i);
tool_menu->set_as_minsize();
tool_menu->reset_size();
return;
}
}
@ -6211,7 +6211,7 @@ EditorNode::EditorNode() {
dock_vb->add_child(dock_float);
dock_select_popup->set_as_minsize();
dock_select_popup->reset_size();
dock_select_rect_over = -1;
dock_popup_selected = -1;
for (int i = 0; i < DOCK_SLOT_MAX; i++) {

View File

@ -1185,7 +1185,7 @@ void EditorPropertyLayers::_button_pressed() {
}
Rect2 gp = button->get_screen_rect();
layers->set_as_minsize();
layers->reset_size();
Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0);
layers->set_position(popup_pos);
layers->popup();

View File

@ -175,7 +175,7 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) {
Button *button = Object::cast_to<Button>(p_button);
changing_type_index = p_index;
Rect2 rect = button->get_screen_rect();
change_type->set_as_minsize();
change_type->reset_size();
change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0));
change_type->popup();
}
@ -751,7 +751,7 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) {
Button *button = Object::cast_to<Button>(p_button);
Rect2 rect = button->get_screen_rect();
change_type->set_as_minsize();
change_type->reset_size();
change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0));
change_type->popup();
changing_type_index = p_index;

View File

@ -149,7 +149,7 @@ void EditorResourcePicker::_update_menu() {
_update_menu_items();
Rect2 gt = edit_button->get_screen_rect();
edit_menu->set_as_minsize();
edit_menu->reset_size();
int ms = edit_menu->get_contents_minimum_size().width;
Vector2 popup_pos = gt.get_end() - Vector2(ms, 0);
edit_menu->set_position(popup_pos);
@ -476,7 +476,7 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) {
_update_menu_items();
Vector2 pos = get_screen_position() + mb->get_position();
edit_menu->set_as_minsize();
edit_menu->reset_size();
edit_menu->set_position(pos);
edit_menu->popup();
}

View File

@ -682,7 +682,7 @@ void ScriptEditor::_update_recent_scripts() {
recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files")));
recent_scripts->set_item_disabled(recent_scripts->get_item_id(recent_scripts->get_item_count() - 1), rc.is_empty());
recent_scripts->set_as_minsize();
recent_scripts->reset_size();
}
void ScriptEditor::_open_recent_script(int p_idx) {
@ -1635,7 +1635,7 @@ void ScriptEditor::_notification(int p_what) {
filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
recent_scripts->set_as_minsize();
recent_scripts->reset_size();
if (is_inside_tree()) {
_update_script_colors();

View File

@ -1304,7 +1304,7 @@ void ColorPickerButton::pressed() {
Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
popup->set_as_minsize();
popup->reset_size();
picker->_update_presets();
Rect2i usable_rect = popup->get_usable_parent_rect();

View File

@ -111,10 +111,6 @@ void Popup::_close_pressed() {
call_deferred(SNAME("hide"));
}
void Popup::set_as_minsize() {
set_size(get_contents_minimum_size());
}
void Popup::_bind_methods() {
ADD_SIGNAL(MethodInfo("popup_hide"));
}

View File

@ -58,8 +58,6 @@ protected:
static void _bind_methods();
public:
void set_as_minsize();
Popup();
~Popup();
};

View File

@ -186,7 +186,7 @@ void PopupMenu::_activate_submenu(int p_over) {
float scroll_offset = control->get_position().y;
submenu_popup->set_as_minsize(); // Shrink the popup size to its contents.
submenu_popup->reset_size(); // Shrink the popup size to its contents.
Size2 submenu_size = submenu_popup->get_size();
Point2 submenu_pos;