Merge pull request #5468 from jejung/itemlist-get-selected_items

itemlist-get_selected_items
This commit is contained in:
George Marques 2016-06-28 19:21:57 -03:00 committed by GitHub
commit 5e0edcc480
3 changed files with 96 additions and 42 deletions

View file

@ -2517,12 +2517,6 @@
Return whether the animation has the loop flag set. Return whether the animation has the loop flag set.
</description> </description>
</method> </method>
<method name="has_loop_interpolation" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="method_track_get_key_indices" qualifiers="const"> <method name="method_track_get_key_indices" qualifiers="const">
<return type="IntArray"> <return type="IntArray">
</return> </return>
@ -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. 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.
</description> </description>
</method> </method>
<method name="set_loop_interpolation">
<argument index="0" name="enabled" type="bool">
</argument>
<description>
</description>
</method>
<method name="set_step"> <method name="set_step">
<argument index="0" name="size_sec" type="float"> <argument index="0" name="size_sec" type="float">
</argument> </argument>
@ -4685,6 +4673,12 @@
</description> </description>
</method> </method>
</methods> </methods>
<signals>
<signal name="atlas_changed">
<description>
</description>
</signal>
</signals>
<constants> <constants>
</constants> </constants>
</class> </class>
@ -6994,6 +6988,12 @@
Set a custom transform for drawing. Anything drawn afterwards will be transformed by this. Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.
</description> </description>
</method> </method>
<method name="draw_set_transform_matrix">
<argument index="0" name="xform" type="Matrix32">
</argument>
<description>
</description>
</method>
<method name="draw_string"> <method name="draw_string">
<argument index="0" name="font" type="Font"> <argument index="0" name="font" type="Font">
</argument> </argument>
@ -17507,6 +17507,13 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
<description> <description>
</description> </description>
</method> </method>
<method name="get_selected_items">
<return type="IntArray">
</return>
<description>
Returns a list of selected indexes.
</description>
</method>
<method name="is_item_disabled" qualifiers="const"> <method name="is_item_disabled" qualifiers="const">
<return type="bool"> <return type="bool">
</return> </return>
@ -18912,6 +18919,34 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
Clear the [LineEdit] text. Clear the [LineEdit] text.
</description> </description>
</method> </method>
<method name="cursor_get_blink_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
Gets whether the line edit caret is blinking.
</description>
</method>
<method name="cursor_get_blink_speed" qualifiers="const">
<return type="float">
</return>
<description>
Gets the line edit caret blink speed.
</description>
</method>
<method name="cursor_set_blink_enabled">
<argument index="0" name="enable" type="bool">
</argument>
<description>
Set the line edit caret to blink.
</description>
</method>
<method name="cursor_set_blink_speed">
<argument index="0" name="blink_speed" type="float">
</argument>
<description>
Set the line edit caret blink speed. Cannot be less then or equal to 0.
</description>
</method>
<method name="get_align" qualifiers="const"> <method name="get_align" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
@ -18991,34 +19026,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 cursor position inside the [LineEdit], causing it to scroll if needed.
</description> </description>
</method> </method>
<method name="cursor_set_blink_enabled">
<argument index="0" name="enable" type="bool">
</argument>
<description>
Set the line edit caret to blink.
</description>
</method>
<method name="cursor_get_blink_enabled" qualifiers="const">
<return type="float">
</return>
<description>
Gets whether the line edit caret is blinking.
</description>
</method>
<method name="cursor_set_blink_speed">
<argument index="0" name="blink_speed" type="float">
</argument>
<description>
Set the line edit caret blink speed. Cannot be less then or equal to 0.
</description>
</method>
<method name="cursor_get_blink_speed" qualifiers="const">
<return type="float">
</return>
<description>
Gets the line edit caret blink speed.
</description>
</method>
<method name="set_editable"> <method name="set_editable">
<argument index="0" name="enabled" type="bool"> <argument index="0" name="enabled" type="bool">
</argument> </argument>
@ -24036,6 +24043,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
Return the mirroring of the ParallaxLayer. Return the mirroring of the ParallaxLayer.
</description> </description>
</method> </method>
<method name="get_motion_offset" qualifiers="const">
<return type="Vector2">
</return>
<description>
</description>
</method>
<method name="get_motion_scale" qualifiers="const"> <method name="get_motion_scale" qualifiers="const">
<return type="Vector2"> <return type="Vector2">
</return> </return>
@ -24050,6 +24063,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. Set the mirroring of the ParallaxLayer. If an axis is set to 0 then that axis will have no mirroring.
</description> </description>
</method> </method>
<method name="set_motion_offset">
<argument index="0" name="offset" type="Vector2">
</argument>
<description>
</description>
</method>
<method name="set_motion_scale"> <method name="set_motion_scale">
<argument index="0" name="scale" type="Vector2"> <argument index="0" name="scale" type="Vector2">
</argument> </argument>
@ -24882,6 +24901,12 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
</description> </description>
</method> </method>
</methods> </methods>
<signals>
<signal name="texture_changed">
<description>
</description>
</signal>
</signals>
<constants> <constants>
</constants> </constants>
</class> </class>
@ -36504,6 +36529,10 @@ A similar effect may be achieved moving this node's descendants.
<description> <description>
</description> </description>
</signal> </signal>
<signal name="texture_changed">
<description>
</description>
</signal>
</signals> </signals>
<constants> <constants>
</constants> </constants>
@ -38495,6 +38524,12 @@ A similar effect may be achieved moving this node's descendants.
</description> </description>
</method> </method>
</methods> </methods>
<signals>
<signal name="texture_changed">
<description>
</description>
</signal>
</signals>
<constants> <constants>
</constants> </constants>
</class> </class>
@ -39357,6 +39392,10 @@ A similar effect may be achieved moving this node's descendants.
</theme_item> </theme_item>
<theme_item name="completion" type="StyleBox"> <theme_item name="completion" type="StyleBox">
</theme_item> </theme_item>
<theme_item name="completion_background_color" type="Color">
</theme_item>
<theme_item name="completion_existing_color" type="Color">
</theme_item>
<theme_item name="completion_lines" type="int"> <theme_item name="completion_lines" type="int">
</theme_item> </theme_item>
<theme_item name="completion_max_width" type="int"> <theme_item name="completion_max_width" type="int">
@ -39365,6 +39404,8 @@ A similar effect may be achieved moving this node's descendants.
</theme_item> </theme_item>
<theme_item name="completion_scroll_width" type="int"> <theme_item name="completion_scroll_width" type="int">
</theme_item> </theme_item>
<theme_item name="completion_selected_color" type="Color">
</theme_item>
<theme_item name="current_line_color" type="Color"> <theme_item name="current_line_color" type="Color">
</theme_item> </theme_item>
<theme_item name="focus" type="StyleBox"> <theme_item name="focus" type="StyleBox">

View file

@ -1245,6 +1245,19 @@ real_t ItemList::get_icon_scale() const {
return icon_scale; return icon_scale;
} }
Vector<int> ItemList::get_selected_items() {
Vector<int> 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(){ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true)); 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("select","idx","single"),&ItemList::select,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect); ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected); 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("get_item_count"),&ItemList::get_item_count);
ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item); 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"))); ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
} }
ItemList::ItemList() { ItemList::ItemList() {
current=-1; current=-1;

View file

@ -144,6 +144,7 @@ public:
void select(int p_idx,bool p_single=true); void select(int p_idx,bool p_single=true);
void unselect(int p_idx); void unselect(int p_idx);
bool is_selected(int p_idx) const; bool is_selected(int p_idx) const;
Vector<int> get_selected_items();
void set_current(int p_current); void set_current(int p_current);
int get_current() const; int get_current() const;