diff options
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r-- | scene/gui/tree.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 6ab1bf3d58..6f09488b64 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -121,7 +121,7 @@ void TreeItem::_cell_deselected(int p_cell) { void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) { ERR_FAIL_INDEX(p_column, cells.size()); - Cell &c = cells[p_column]; + Cell &c = cells.write[p_column]; c.mode = p_mode; c.min = 0; c.max = 100; @@ -144,7 +144,7 @@ TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const { void TreeItem::set_checked(int p_column, bool p_checked) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].checked = p_checked; + cells.write[p_column].checked = p_checked; _changed_notify(p_column); } @@ -157,22 +157,22 @@ bool TreeItem::is_checked(int p_column) const { void TreeItem::set_text(int p_column, String p_text) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].text = p_text; + cells.write[p_column].text = p_text; if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE || cells[p_column].mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) { Vector<String> strings = p_text.split(","); - cells[p_column].min = INT_MAX; - cells[p_column].max = INT_MIN; + cells.write[p_column].min = INT_MAX; + cells.write[p_column].max = INT_MIN; for (int i = 0; i < strings.size(); i++) { int value = i; if (!strings[i].get_slicec(':', 1).empty()) { value = strings[i].get_slicec(':', 1).to_int(); } - cells[p_column].min = MIN(cells[p_column].min, value); - cells[p_column].max = MAX(cells[p_column].max, value); + cells.write[p_column].min = MIN(cells[p_column].min, value); + cells.write[p_column].max = MAX(cells[p_column].max, value); } - cells[p_column].step = 0; + cells.write[p_column].step = 0; } _changed_notify(p_column); } @@ -186,7 +186,7 @@ String TreeItem::get_text(int p_column) const { void TreeItem::set_suffix(int p_column, String p_suffix) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].suffix = p_suffix; + cells.write[p_column].suffix = p_suffix; _changed_notify(p_column); } @@ -200,7 +200,7 @@ String TreeItem::get_suffix(int p_column) const { void TreeItem::set_icon(int p_column, const Ref<Texture> &p_icon) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].icon = p_icon; + cells.write[p_column].icon = p_icon; _changed_notify(p_column); } @@ -213,7 +213,7 @@ Ref<Texture> TreeItem::get_icon(int p_column) const { void TreeItem::set_icon_region(int p_column, const Rect2 &p_icon_region) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].icon_region = p_icon_region; + cells.write[p_column].icon_region = p_icon_region; _changed_notify(p_column); } @@ -226,7 +226,7 @@ Rect2 TreeItem::get_icon_region(int p_column) const { void TreeItem::set_icon_color(int p_column, const Color &p_icon_color) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].icon_color = p_icon_color; + cells.write[p_column].icon_color = p_icon_color; _changed_notify(p_column); } @@ -239,7 +239,7 @@ Color TreeItem::get_icon_color(int p_column) const { void TreeItem::set_icon_max_width(int p_column, int p_max) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].icon_max_w = p_max; + cells.write[p_column].icon_max_w = p_max; _changed_notify(p_column); } @@ -260,7 +260,7 @@ void TreeItem::set_range(int p_column, double p_value) { if (p_value > cells[p_column].max) p_value = cells[p_column].max; - cells[p_column].val = p_value; + cells.write[p_column].val = p_value; _changed_notify(p_column); } @@ -278,10 +278,10 @@ bool TreeItem::is_range_exponential(int p_column) const { void TreeItem::set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].min = p_min; - cells[p_column].max = p_max; - cells[p_column].step = p_step; - cells[p_column].expr = p_exp; + cells.write[p_column].min = p_min; + cells.write[p_column].max = p_max; + cells.write[p_column].step = p_step; + cells.write[p_column].expr = p_exp; _changed_notify(p_column); } @@ -296,7 +296,7 @@ void TreeItem::get_range_config(int p_column, double &r_min, double &r_max, doub void TreeItem::set_metadata(int p_column, const Variant &p_meta) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].meta = p_meta; + cells.write[p_column].meta = p_meta; } Variant TreeItem::get_metadata(int p_column) const { @@ -311,8 +311,8 @@ void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_NULL(p_object); - cells[p_column].custom_draw_obj = p_object->get_instance_id(); - cells[p_column].custom_draw_callback = p_callback; + cells.write[p_column].custom_draw_obj = p_object->get_instance_id(); + cells.write[p_column].custom_draw_callback = p_callback; } void TreeItem::set_collapsed(bool p_collapsed) { @@ -467,7 +467,7 @@ void TreeItem::remove_child(TreeItem *p_item) { void TreeItem::set_selectable(int p_column, bool p_selectable) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].selectable = p_selectable; + cells.write[p_column].selectable = p_selectable; } bool TreeItem::is_selectable(int p_column) const { @@ -517,7 +517,7 @@ void TreeItem::add_button(int p_column, const Ref<Texture> &p_button, int p_id, button.id = p_id; button.disabled = p_disabled; button.tooltip = p_tooltip; - cells[p_column].buttons.push_back(button); + cells.write[p_column].buttons.push_back(button); _changed_notify(p_column); } @@ -540,7 +540,7 @@ void TreeItem::erase_button(int p_column, int p_idx) { ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - cells[p_column].buttons.remove(p_idx); + cells.write[p_column].buttons.remove(p_idx); _changed_notify(p_column); } @@ -568,7 +568,7 @@ void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture> &p_button) ERR_FAIL_COND(p_button.is_null()); ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - cells[p_column].buttons[p_idx].texture = p_button; + cells.write[p_column].buttons.write[p_idx].texture = p_button; _changed_notify(p_column); } @@ -576,14 +576,14 @@ void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) { ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - cells[p_column].buttons[p_idx].color = p_color; + cells.write[p_column].buttons.write[p_idx].color = p_color; _changed_notify(p_column); } void TreeItem::set_editable(int p_column, bool p_editable) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].editable = p_editable; + cells.write[p_column].editable = p_editable; _changed_notify(p_column); } @@ -596,8 +596,8 @@ bool TreeItem::is_editable(int p_column) { void TreeItem::set_custom_color(int p_column, const Color &p_color) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].custom_color = true; - cells[p_column].color = p_color; + cells.write[p_column].custom_color = true; + cells.write[p_column].color = p_color; _changed_notify(p_column); } Color TreeItem::get_custom_color(int p_column) const { @@ -610,15 +610,15 @@ Color TreeItem::get_custom_color(int p_column) const { void TreeItem::clear_custom_color(int p_column) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].custom_color = false; - cells[p_column].color = Color(); + cells.write[p_column].custom_color = false; + cells.write[p_column].color = Color(); _changed_notify(p_column); } void TreeItem::set_tooltip(int p_column, const String &p_tooltip) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].tooltip = p_tooltip; + cells.write[p_column].tooltip = p_tooltip; } String TreeItem::get_tooltip(int p_column) const { @@ -630,17 +630,17 @@ String TreeItem::get_tooltip(int p_column) const { void TreeItem::set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].custom_bg_color = true; - cells[p_column].custom_bg_outline = p_bg_outline; - cells[p_column].bg_color = p_color; + cells.write[p_column].custom_bg_color = true; + cells.write[p_column].custom_bg_outline = p_bg_outline; + cells.write[p_column].bg_color = p_color; _changed_notify(p_column); } void TreeItem::clear_custom_bg_color(int p_column) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].custom_bg_color = false; - cells[p_column].bg_color = Color(); + cells.write[p_column].custom_bg_color = false; + cells.write[p_column].bg_color = Color(); _changed_notify(p_column); } @@ -655,7 +655,7 @@ Color TreeItem::get_custom_bg_color(int p_column) const { void TreeItem::set_custom_as_button(int p_column, bool p_button) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].custom_button = p_button; + cells.write[p_column].custom_button = p_button; } bool TreeItem::is_custom_set_as_button(int p_column) const { @@ -666,7 +666,7 @@ bool TreeItem::is_custom_set_as_button(int p_column) const { void TreeItem::set_text_align(int p_column, TextAlign p_align) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].text_align = p_align; + cells.write[p_column].text_align = p_align; _changed_notify(p_column); } @@ -678,7 +678,7 @@ TreeItem::TextAlign TreeItem::get_text_align(int p_column) const { void TreeItem::set_expand_right(int p_column, bool p_enable) { ERR_FAIL_INDEX(p_column, cells.size()); - cells[p_column].expand_right = p_enable; + cells.write[p_column].expand_right = p_enable; _changed_notify(p_column); } @@ -1486,7 +1486,7 @@ int Tree::_count_selected_items(TreeItem *p_from) const { } void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) { - TreeItem::Cell &selected_cell = p_selected->cells[p_col]; + TreeItem::Cell &selected_cell = p_selected->cells.write[p_col]; bool switched = false; if (r_in_range && !*r_in_range && (p_current == p_selected || p_current == p_prev)) { @@ -1498,7 +1498,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c for (int i = 0; i < columns.size(); i++) { - TreeItem::Cell &c = p_current->cells[i]; + TreeItem::Cell &c = p_current->cells.write[i]; if (!c.selectable) continue; @@ -1689,7 +1689,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool return -1; //collapse/uncollapse because nothing can be done with item } - TreeItem::Cell &c = p_item->cells[col]; + const TreeItem::Cell &c = p_item->cells[col]; bool already_selected = c.selected; bool already_cursor = (p_item == selected_item) && col == selected_col; @@ -1990,7 +1990,7 @@ void Tree::text_editor_enter(String p_text) { if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size()) return; - TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col]; + TreeItem::Cell &c = popup_edited_item->cells.write[popup_edited_item_col]; switch (c.mode) { case TreeItem::CELL_MODE_STRING: { @@ -2041,7 +2041,7 @@ void Tree::value_editor_changed(double p_value) { return; } - TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col]; + TreeItem::Cell &c = popup_edited_item->cells.write[popup_edited_item_col]; c.val = p_value; item_edited(popup_edited_item_col, popup_edited_item); update(); @@ -2055,7 +2055,7 @@ void Tree::popup_select(int p_option) { if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size()) return; - popup_edited_item->cells[popup_edited_item_col].val = p_option; + popup_edited_item->cells.write[popup_edited_item_col].val = p_option; //popup_edited_item->edited_signal.call( popup_edited_item_col ); update(); item_edited(popup_edited_item_col, popup_edited_item); @@ -2467,7 +2467,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } } else { - TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col]; + const TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col]; float diff_y = -mm->get_relative().y; diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y); diff_y *= 0.1; @@ -2681,7 +2681,7 @@ bool Tree::edit_selected() { popup_edited_item = s; popup_edited_item_col = col; - TreeItem::Cell &c = s->cells[col]; + const TreeItem::Cell &c = s->cells[col]; if (c.mode == TreeItem::CELL_MODE_CHECK) { @@ -3072,7 +3072,7 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { if (!p_item->cells[p_column].selectable) return; - p_item->cells[p_column].selected = true; + p_item->cells.write[p_column].selected = true; //emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select selected_col = p_column; @@ -3086,7 +3086,7 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { void Tree::item_deselected(int p_column, TreeItem *p_item) { if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { - p_item->cells[p_column].selected = false; + p_item->cells.write[p_column].selected = false; } update(); } @@ -3167,14 +3167,14 @@ void Tree::set_column_min_width(int p_column, int p_min_width) { if (p_min_width < 1) return; - columns[p_column].min_width = p_min_width; + columns.write[p_column].min_width = p_min_width; update(); } void Tree::set_column_expand(int p_column, bool p_expand) { ERR_FAIL_INDEX(p_column, columns.size()); - columns[p_column].expand = p_expand; + columns.write[p_column].expand = p_expand; update(); } @@ -3422,7 +3422,7 @@ bool Tree::are_column_titles_visible() const { void Tree::set_column_title(int p_column, const String &p_title) { ERR_FAIL_INDEX(p_column, columns.size()); - columns[p_column].title = p_title; + columns.write[p_column].title = p_title; update(); } @@ -3668,7 +3668,7 @@ String Tree::get_tooltip(const Point2 &p_pos) const { if (it) { - TreeItem::Cell &c = it->cells[col]; + const TreeItem::Cell &c = it->cells[col]; int col_width = get_column_width(col); for (int j = c.buttons.size() - 1; j >= 0; j--) { Ref<Texture> b = c.buttons[j].texture; |