diff options
Diffstat (limited to 'scene/gui/button_array.cpp')
-rw-r--r-- | scene/gui/button_array.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index 3d7c0e2825..2fd5f0df83 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -58,9 +58,10 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { int idx=what.to_int(); ERR_FAIL_INDEX_V(idx,buttons.size(),false); String f = n.get_slicec('/',2); - if (f=="text") + if (f=="text") { buttons[idx].text=p_value; - else if (f=="tooltip") + buttons[idx].xl_text=XL_MESSAGE(p_value); + } else if (f=="tooltip") buttons[idx].tooltip=p_value; else if (f=="icon") buttons[idx].icon=p_value; @@ -146,7 +147,7 @@ Size2 ButtonArray::get_minimum_size() const { Ref<Font> f = i==selected ? font_selected : font_normal; Size2 ms; - ms = f->get_string_size(buttons[i].text); + ms = f->get_string_size(buttons[i].xl_text); if (buttons[i].icon.is_valid()) { Size2 bs = buttons[i].icon->get_size(); @@ -275,7 +276,7 @@ void ButtonArray::_notification(int p_what) { c=color_normal; } - Size2 ssize = f->get_string_size(buttons[i].text); + Size2 ssize = f->get_string_size(buttons[i].xl_text); if (buttons[i].icon.is_valid()) { ssize.x+=buttons[i].icon->get_width(); @@ -287,7 +288,7 @@ void ButtonArray::_notification(int p_what) { text_ofs.x+=buttons[i].icon->get_width()+icon_sep; } - draw_string(f,text_ofs+r.pos,buttons[i].text,c); + draw_string(f,text_ofs+r.pos,buttons[i].xl_text,c); buttons[i]._pos_cache=ofs; buttons[i]._size_cache=s; @@ -404,6 +405,7 @@ void ButtonArray::add_button(const String& p_text,const String& p_tooltip) { Button button; button.text=p_text; + button.xl_text=XL_MESSAGE(p_text); button.tooltip=p_tooltip; buttons.push_back(button); update(); @@ -418,6 +420,7 @@ void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_tex Button button; button.text=p_text; + button.xl_text=XL_MESSAGE(p_text); button.icon=p_icon; button.tooltip=p_tooltip; buttons.push_back(button); @@ -432,6 +435,7 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) { ERR_FAIL_INDEX(p_button,buttons.size()); buttons[p_button].text=p_text; + buttons[p_button].xl_text=XL_MESSAGE(p_text); update(); minimum_size_changed(); @@ -527,24 +531,24 @@ void ButtonArray::get_translatable_strings(List<String> *p_strings) const { void ButtonArray::_bind_methods() { - ClassDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL("")); - ClassDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL("")); - ClassDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text); - ClassDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip); - ClassDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon); - ClassDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text); - ClassDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip); - ClassDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon); - ClassDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count); - ClassDB::bind_method(_MD("set_flat","enabled"),&ButtonArray::set_flat); - ClassDB::bind_method(_MD("is_flat"),&ButtonArray::is_flat); - ClassDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected); - ClassDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered); - ClassDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected); - ClassDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button); - ClassDB::bind_method(_MD("clear"),&ButtonArray::clear); - - ClassDB::bind_method(_MD("_gui_input"),&ButtonArray::_gui_input); + ClassDB::bind_method(D_METHOD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL("")); + ClassDB::bind_method(D_METHOD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL("")); + ClassDB::bind_method(D_METHOD("set_button_text","button_idx","text"),&ButtonArray::set_button_text); + ClassDB::bind_method(D_METHOD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip); + ClassDB::bind_method(D_METHOD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon); + ClassDB::bind_method(D_METHOD("get_button_text","button_idx"),&ButtonArray::get_button_text); + ClassDB::bind_method(D_METHOD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip); + ClassDB::bind_method(D_METHOD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon); + ClassDB::bind_method(D_METHOD("get_button_count"),&ButtonArray::get_button_count); + ClassDB::bind_method(D_METHOD("set_flat","enabled"),&ButtonArray::set_flat); + ClassDB::bind_method(D_METHOD("is_flat"),&ButtonArray::is_flat); + ClassDB::bind_method(D_METHOD("get_selected"),&ButtonArray::get_selected); + ClassDB::bind_method(D_METHOD("get_hovered"),&ButtonArray::get_hovered); + ClassDB::bind_method(D_METHOD("set_selected","button_idx"),&ButtonArray::set_selected); + ClassDB::bind_method(D_METHOD("erase_button","button_idx"),&ButtonArray::erase_button); + ClassDB::bind_method(D_METHOD("clear"),&ButtonArray::clear); + + ClassDB::bind_method(D_METHOD("_gui_input"),&ButtonArray::_gui_input); BIND_CONSTANT( ALIGN_BEGIN ); BIND_CONSTANT( ALIGN_CENTER ); @@ -552,7 +556,7 @@ void ButtonArray::_bind_methods() { BIND_CONSTANT( ALIGN_FILL ); BIND_CONSTANT( ALIGN_EXPAND_FILL ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), "set_flat","is_flat") ; ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx"))); |