diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 4 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 28 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 6 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 1 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 9 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 28 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 17 |
9 files changed, 68 insertions, 33 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 91c5263bf5..54a58159ac 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2811,12 +2811,12 @@ void Control::_bind_methods() { BIND_ENUM_CONSTANT(PRESET_WIDE); BIND_ENUM_CONSTANT(PRESET_MODE_MINSIZE); - BIND_ENUM_CONSTANT(PRESET_MODE_KEEP_HEIGHT); BIND_ENUM_CONSTANT(PRESET_MODE_KEEP_WIDTH); + BIND_ENUM_CONSTANT(PRESET_MODE_KEEP_HEIGHT); BIND_ENUM_CONSTANT(PRESET_MODE_KEEP_SIZE); - BIND_ENUM_CONSTANT(SIZE_EXPAND); BIND_ENUM_CONSTANT(SIZE_FILL); + BIND_ENUM_CONSTANT(SIZE_EXPAND); BIND_ENUM_CONSTANT(SIZE_EXPAND_FILL); BIND_ENUM_CONSTANT(SIZE_SHRINK_CENTER); BIND_ENUM_CONSTANT(SIZE_SHRINK_END); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index d8ff048dfb..6ade4fcc38 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -759,38 +759,42 @@ FileDialog::FileDialog() { mode = MODE_SAVE_FILE; set_title(RTR("Save a File")); + HBoxContainer *hbc = memnew(HBoxContainer); + hbc->add_child(memnew(Label(RTR("Path:")))); dir = memnew(LineEdit); - HBoxContainer *pathhb = memnew(HBoxContainer); - pathhb->add_child(dir); + hbc->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); refresh = memnew(ToolButton); refresh->connect("pressed", this, "_update_file_list"); - pathhb->add_child(refresh); + hbc->add_child(refresh); drives = memnew(OptionButton); - pathhb->add_child(drives); + hbc->add_child(drives); drives->connect("item_selected", this, "_select_drive"); makedir = memnew(Button); makedir->set_text(RTR("Create Folder")); makedir->connect("pressed", this, "_make_dir"); - pathhb->add_child(makedir); - - vbc->add_margin_child(RTR("Path:"), pathhb); + hbc->add_child(makedir); + vbc->add_child(hbc); tree = memnew(Tree); tree->set_hide_root(true); vbc->add_margin_child(RTR("Directories & Files:"), tree, true); + hbc = memnew(HBoxContainer); + hbc->add_child(memnew(Label(RTR("File:")))); file = memnew(LineEdit); - //add_child(file); - vbc->add_margin_child(RTR("File:"), file); - + file->set_stretch_ratio(4); + file->set_h_size_flags(SIZE_EXPAND_FILL); + hbc->add_child(file); filter = memnew(OptionButton); - //add_child(filter); - vbc->add_margin_child(RTR("Filter:"), filter); + filter->set_stretch_ratio(3); + filter->set_h_size_flags(SIZE_EXPAND_FILL); filter->set_clip_text(true); //too many extensions overflow it + hbc->add_child(filter); + vbc->add_child(hbc); dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); access = ACCESS_RESOURCES; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index a034c7224f..623a110263 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -489,7 +489,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } } else { @@ -500,7 +500,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (items[i].selected && mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } else { bool selected = !items[i].selected; @@ -515,7 +515,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, pos); + emit_signal("item_rmb_selected", i, get_local_mouse_position()); } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) { emit_signal("item_activated", i); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 07b49538d9..ad519d8d0c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1984,6 +1984,7 @@ void RichTextLabel::_bind_methods() { BIND_ENUM_CONSTANT(ITEM_ALIGN); BIND_ENUM_CONSTANT(ITEM_INDENT); BIND_ENUM_CONSTANT(ITEM_LIST); + BIND_ENUM_CONSTANT(ITEM_TABLE); BIND_ENUM_CONSTANT(ITEM_META); } diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 116e0ac354..e88742a3e3 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -157,6 +157,12 @@ void Slider::_notification(int p_what) { mouse_inside = false; update(); } break; + case NOTIFICATION_VISIBILITY_CHANGED: // fallthrough + case NOTIFICATION_EXIT_TREE: { + + mouse_inside = false; + grab.active = false; + } break; case NOTIFICATION_DRAW: { RID ci = get_canvas_item(); Size2i size = get_size(); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 6e50614e8f..cfe924ecd4 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -94,15 +94,20 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { // Handle navigation buttons. if (buttons_visible_cache) { + int popup_ofs = 0; + if (popup) { + popup_ofs = menu->get_width(); + } + Ref<Texture> increment = get_icon("increment"); Ref<Texture> decrement = get_icon("decrement"); - if (pos.x > size.width - increment->get_width()) { + if (pos.x > size.width - increment->get_width() - popup_ofs) { if (last_tab_cache < tabs.size() - 1) { first_tab_cache += 1; update(); } return; - } else if (pos.x > size.width - increment->get_width() - decrement->get_width()) { + } else if (pos.x > size.width - increment->get_width() - decrement->get_width() - popup_ofs) { if (first_tab_cache > 0) { first_tab_cache -= 1; update(); diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 085f6de6b8..49823e18fc 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -820,9 +820,9 @@ void Tabs::_bind_methods() { BIND_ENUM_CONSTANT(ALIGN_RIGHT); BIND_ENUM_CONSTANT(ALIGN_MAX); + BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_NEVER); BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY); BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS); - BIND_ENUM_CONSTANT(CLOSE_BUTTON_SHOW_NEVER); BIND_ENUM_CONSTANT(CLOSE_BUTTON_MAX); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index de69406b37..977ba2da7c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -732,6 +732,19 @@ void TextEdit::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); } + if (str.length() == 0) { + // draw line background if empty as we won't loop at at all + if (line == cursor.line) { + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); + } + + // give visual indication of empty selected line + if (selection.active && line >= selection.from_line && line <= selection.to_line) { + int char_w = cache.font->get_char_size(' ').width; + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, char_w, get_row_height()), cache.selection_color); + } + } + if (text.is_breakpoint(line) && !draw_breakpoint_gutter) { #ifdef TOOLS_ENABLED VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); @@ -953,15 +966,18 @@ void TextEdit::_notification(int p_what) { bool in_selection = (selection.active && line >= selection.from_line && line <= selection.to_line && (line > selection.from_line || j >= selection.from_column) && (line < selection.to_line || j < selection.to_column)); if (line == cursor.line) { - if (j == 0) - //first char + // if its the first char draw behind line numbers + if (j == 0) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, (char_ofs + char_margin), get_row_height()), cache.current_line_color); - else if (j == str.length() - 1) - //last char + } + // if its the last char draw to end of the line + if (j == str.length() - 1) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); - - if (!in_selection) + } + // actual text + if (!in_selection) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); + } } if (in_selection) { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 178a1c272b..931dcfed91 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -47,18 +47,21 @@ void TreeItem::move_to_top() { } void TreeItem::move_to_bottom() { - if (!parent || !next) return; - while (next) { + TreeItem *prev = get_prev(); + TreeItem *last = next; + while (last->next) + last = last->next; - if (parent->childs == this) - parent->childs = next; - TreeItem *n = next; - next = n->next; - n->next = this; + if (prev) { + prev->next = next; + } else { + parent->childs = next; } + last->next = this; + next = NULL; } Size2 TreeItem::Cell::get_icon_size() const { |