From 2fd9b77828bcc7c22594c7037db17efd11ba1909 Mon Sep 17 00:00:00 2001 From: Jean Jung Date: Tue, 28 Jun 2016 14:09:17 -0300 Subject: [PATCH 1/3] itemlist-get_selected_items --- scene/gui/item_list.cpp | 16 ++++++++++++++-- scene/gui/item_list.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 53798367468..d63c483ef92 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1245,6 +1245,19 @@ real_t ItemList::get_icon_scale() const { return icon_scale; } +Vector ItemList::get_selected_items() { + Vector selected; + for (int i = 0; i < items.size(); i++) { + if (items[i].selected) { + selected.push_back(i); + if (this->select_mode == SELECT_SINGLE) { + break; + } + } + } + return selected; +} + void ItemList::_bind_methods(){ ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true)); @@ -1277,6 +1290,7 @@ void ItemList::_bind_methods(){ ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true)); ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect); ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected); + ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items); ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count); ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item); @@ -1330,8 +1344,6 @@ void ItemList::_bind_methods(){ ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index"))); } - - ItemList::ItemList() { current=-1; diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index aa6dd64c502..e1902d1c1fc 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -144,6 +144,7 @@ public: void select(int p_idx,bool p_single=true); void unselect(int p_idx); bool is_selected(int p_idx) const; + Vector get_selected_items(); void set_current(int p_current); int get_current() const; From 5502499469e84176bcaa3eaf3c2e0aff3778227e Mon Sep 17 00:00:00 2001 From: Jean Jung Date: Tue, 28 Jun 2016 16:11:58 -0300 Subject: [PATCH 2/3] syncing the reference --- doc/base/classes.xml | 120 ++++++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 40 deletions(-) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 805f64ad8aa..86dd3caad14 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2517,12 +2517,6 @@ Return whether the animation has the loop flag set. - - - - - - @@ -2579,12 +2573,6 @@ Set a flag indicating that the animation must loop. This is uses for correct interpolation of animation cycles, and for hinting the player that it must restart the animation. - - - - - - @@ -4685,6 +4673,12 @@ + + + + + + @@ -6994,6 +6988,12 @@ Set a custom transform for drawing. Anything drawn afterwards will be transformed by this. + + + + + + @@ -17507,6 +17507,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) + + + + + + @@ -18912,6 +18918,34 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Clear the [LineEdit] text. + + + + + Gets whether the line edit caret is blinking. + + + + + + + Gets the line edit caret blink speed. + + + + + + + Set the line edit caret to blink. + + + + + + + Set the line edit caret blink speed. Cannot be less then or equal to 0. + + @@ -18991,34 +19025,6 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Set the cursor position inside the [LineEdit], causing it to scroll if needed. - - - - - Set the line edit caret to blink. - - - - - - - Gets whether the line edit caret is blinking. - - - - - - - Set the line edit caret blink speed. Cannot be less then or equal to 0. - - - - - - - Gets the line edit caret blink speed. - - @@ -24036,6 +24042,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Return the mirroring of the ParallaxLayer. + + + + + + @@ -24050,6 +24062,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Set the mirroring of the ParallaxLayer. If an axis is set to 0 then that axis will have no mirroring. + + + + + + @@ -24882,6 +24900,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) + + + + + + @@ -36504,6 +36528,10 @@ A similar effect may be achieved moving this node's descendants. + + + + @@ -38495,6 +38523,12 @@ A similar effect may be achieved moving this node's descendants. + + + + + + @@ -39357,6 +39391,10 @@ A similar effect may be achieved moving this node's descendants. + + + + @@ -39365,6 +39403,8 @@ A similar effect may be achieved moving this node's descendants. + + From 673e3b70b6bb888093f4963348c76c1423987aa8 Mon Sep 17 00:00:00 2001 From: Jean Jung Date: Tue, 28 Jun 2016 16:22:36 -0300 Subject: [PATCH 3/3] Added ItemList.get_selected_items() doc --- doc/base/classes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 86dd3caad14..4b5c424d4bf 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -17511,6 +17511,7 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) + Returns a list of selected indexes.