diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/popup_menu.cpp | 28 | ||||
-rw-r--r-- | scene/gui/popup_menu.h | 12 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 2 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 17 |
4 files changed, 30 insertions, 29 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index e37cdd5cc9..32f889e826 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -624,7 +624,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bo update(); } -void PopupMenu::add_statable_item(const String &p_label, int p_max_states, int p_default_state, int p_ID, uint32_t p_accel) { +void PopupMenu::add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_ID, uint32_t p_accel) { Item item; item.text = p_label; @@ -839,14 +839,14 @@ void PopupMenu::set_item_h_offset(int p_idx, int p_offset) { update(); } -void PopupMenu::set_item_statable(int p_idx, int p_state) { +void PopupMenu::set_item_multistate(int p_idx, int p_state) { ERR_FAIL_INDEX(p_idx, items.size()); items[p_idx].state = p_state; update(); } -void PopupMenu::toggle_item_statable(int p_idx) { +void PopupMenu::toggle_item_multistate(int p_idx) { ERR_FAIL_INDEX(p_idx, items.size()); if (0 >= items[p_idx].max_states) { @@ -940,7 +940,7 @@ void PopupMenu::activate_item(int p_item) { if (!hide_on_checkable_item_selection || !pop->is_hide_on_checkable_item_selection()) break; } else if (0 < items[p_item].max_states) { - if (!hide_on_statable_item_selection || !pop->is_hide_on_statable_item_selection()) + if (!hide_on_multistate_item_selection || !pop->is_hide_on_multistate_item_selection()) break; } else if (!hide_on_item_selection || !pop->is_hide_on_item_selection()) break; @@ -957,7 +957,7 @@ void PopupMenu::activate_item(int p_item) { if (!hide_on_checkable_item_selection) return; } else if (0 < items[p_item].max_states) { - if (!hide_on_statable_item_selection) + if (!hide_on_multistate_item_selection) return; } else if (!hide_on_item_selection) return; @@ -1093,14 +1093,14 @@ bool PopupMenu::is_hide_on_checkable_item_selection() const { return hide_on_checkable_item_selection; } -void PopupMenu::set_hide_on_statable_item_selection(bool p_enabled) { +void PopupMenu::set_hide_on_multistate_item_selection(bool p_enabled) { - hide_on_statable_item_selection = p_enabled; + hide_on_multistate_item_selection = p_enabled; } -bool PopupMenu::is_hide_on_statable_item_selection() const { +bool PopupMenu::is_hide_on_multistate_item_selection() const { - return hide_on_statable_item_selection; + return hide_on_multistate_item_selection; } String PopupMenu::get_tooltip(const Point2 &p_pos) const { @@ -1161,10 +1161,10 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("set_item_as_checkable", "idx", "enable"), &PopupMenu::set_item_as_checkable); ClassDB::bind_method(D_METHOD("set_item_tooltip", "idx", "tooltip"), &PopupMenu::set_item_tooltip); ClassDB::bind_method(D_METHOD("set_item_shortcut", "idx", "shortcut", "global"), &PopupMenu::set_item_shortcut, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_item_statable", "idx", "state"), &PopupMenu::set_item_statable); + ClassDB::bind_method(D_METHOD("set_item_multistate", "idx", "state"), &PopupMenu::set_item_multistate); ClassDB::bind_method(D_METHOD("toggle_item_checked", "idx"), &PopupMenu::toggle_item_checked); - ClassDB::bind_method(D_METHOD("toggle_item_statable", "idx"), &PopupMenu::toggle_item_statable); + ClassDB::bind_method(D_METHOD("toggle_item_multistate", "idx"), &PopupMenu::toggle_item_multistate); ClassDB::bind_method(D_METHOD("get_item_text", "idx"), &PopupMenu::get_item_text); ClassDB::bind_method(D_METHOD("get_item_icon", "idx"), &PopupMenu::get_item_icon); @@ -1196,8 +1196,8 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("set_hide_on_checkable_item_selection", "enable"), &PopupMenu::set_hide_on_checkable_item_selection); ClassDB::bind_method(D_METHOD("is_hide_on_checkable_item_selection"), &PopupMenu::is_hide_on_checkable_item_selection); - ClassDB::bind_method(D_METHOD("set_hide_on_state_item_selection", "enable"), &PopupMenu::set_hide_on_statable_item_selection); - ClassDB::bind_method(D_METHOD("is_hide_on_state_item_selection"), &PopupMenu::is_hide_on_statable_item_selection); + ClassDB::bind_method(D_METHOD("set_hide_on_state_item_selection", "enable"), &PopupMenu::set_hide_on_multistate_item_selection); + ClassDB::bind_method(D_METHOD("is_hide_on_state_item_selection"), &PopupMenu::is_hide_on_multistate_item_selection); ClassDB::bind_method(D_METHOD("_submenu_timeout"), &PopupMenu::_submenu_timeout); @@ -1222,7 +1222,7 @@ PopupMenu::PopupMenu() { set_as_toplevel(true); set_hide_on_item_selection(true); set_hide_on_checkable_item_selection(true); - set_hide_on_statable_item_selection(false); + set_hide_on_multistate_item_selection(false); submenu_timer = memnew(Timer); submenu_timer->set_wait_time(0.3); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 5a10bf0765..ee514f4c4b 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -90,7 +90,7 @@ class PopupMenu : public Popup { bool invalidated_click; bool hide_on_item_selection; bool hide_on_checkable_item_selection; - bool hide_on_statable_item_selection; + bool hide_on_multistate_item_selection; Vector2 moved; Array _get_items() const; @@ -120,7 +120,7 @@ public: void add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID = -1, bool p_global = false); void add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID = -1, bool p_global = false); - void add_statable_item(const String &p_label, int p_max_states, int p_default_state, int p_ID = -1, uint32_t p_accel = 0); + void add_multistate_item(const String &p_label, int p_max_states, int p_default_state, int p_ID = -1, uint32_t p_accel = 0); void set_item_text(int p_idx, const String &p_text); void set_item_icon(int p_idx, const Ref<Texture> &p_icon); @@ -135,8 +135,8 @@ public: void set_item_tooltip(int p_idx, const String &p_tooltip); void set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bool p_global = false); void set_item_h_offset(int p_idx, int p_offset); - void set_item_statable(int p_idx, int p_state); - void toggle_item_statable(int p_idx); + void set_item_multistate(int p_idx, int p_state); + void toggle_item_multistate(int p_idx); void toggle_item_checked(int p_idx); @@ -183,8 +183,8 @@ public: void set_hide_on_checkable_item_selection(bool p_enabled); bool is_hide_on_checkable_item_selection() const; - void set_hide_on_statable_item_selection(bool p_enabled); - bool is_hide_on_statable_item_selection() const; + void set_hide_on_multistate_item_selection(bool p_enabled); + bool is_hide_on_multistate_item_selection() const; PopupMenu(); ~PopupMenu(); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 45188c3a52..05c6e9f77e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -453,7 +453,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & for (int i = 0; i < frame->lines.size(); i++) { _process_line(frame, Point2(), ly, p_width, i, PROCESS_CACHE, cfont, Color()); - table->columns[column].min_width = MAX(table->columns[i].min_width, frame->lines[i].minimum_width); + table->columns[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].minimum_width); } idx++; } diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index e88742a3e3..70b8616af1 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -171,47 +171,48 @@ void Slider::_notification(int p_what) { Ref<StyleBox> grabber_area = get_stylebox("grabber_area"); Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); Ref<Texture> tick = get_icon("tick"); + double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio(); if (orientation == VERTICAL) { int widget_width = style->get_minimum_size().width + style->get_center_size().width; float areasize = size.height - grabber->get_size().height; style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height))); - grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * get_as_ratio() - grabber->get_size().height / 2), Size2i(widget_width, areasize * get_as_ratio() + grabber->get_size().width / 2))); + grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_size().height / 2), Size2i(widget_width, areasize * ratio + grabber->get_size().width / 2))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); */ if (ticks > 1) { - int tickarea = size.height - tick->get_height(); + int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2); for (int i = 0; i < ticks; i++) { if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) continue; - int ofs = i * tickarea / (ticks - 1); + int ofs = (i * areasize / (ticks - 1)) + grabber_offset; tick->draw(ci, Point2i((size.width - widget_width) / 2, ofs)); } } - grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_as_ratio() * areasize - grabber->get_size().height)); + grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - ratio * areasize - grabber->get_size().height)); } else { int widget_height = style->get_minimum_size().height + style->get_center_size().height; float areasize = size.width - grabber->get_size().width; style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height))); - grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * get_as_ratio() + grabber->get_size().width / 2, widget_height))); + grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * ratio + grabber->get_size().width / 2, widget_height))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); */ if (ticks > 1) { - int tickarea = size.width - tick->get_width(); + int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2); for (int i = 0; i < ticks; i++) { if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) continue; - int ofs = i * tickarea / (ticks - 1); + int ofs = (i * areasize / (ticks - 1)) + grabber_offset; tick->draw(ci, Point2i(ofs, (size.height - widget_height) / 2)); } } - grabber->draw(ci, Point2i(get_as_ratio() * areasize, size.height / 2 - grabber->get_size().height / 2)); + grabber->draw(ci, Point2i(ratio * areasize, size.height / 2 - grabber->get_size().height / 2)); } } break; |