5 protected ScrollWidget m_Scroller;
6 protected Widget m_ContentContainer;
12 protected ImageWidget m_ImageExpand;
13 protected ImageWidget m_ImageCollapse;
18 void DropdownPrefab(
Widget root,
string text =
"" )
21 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/dropdown_prefab/dropdown_prefab.layout", root );
23 m_Scroller = ScrollWidget.Cast(
m_Root.FindAnyWidget(
"dropdown_container" ) );
24 m_ContentContainer =
m_Root.FindAnyWidget(
"dropdown_content" );
26 m_Holder =
m_Root.FindAnyWidget(
"holder" );
29 m_Button =
m_Root.FindAnyWidget(
"dropdown_selector_button" );
30 m_ImageExpand = ImageWidget.Cast(
m_Root.FindAnyWidget(
"expand_image" ) );
31 m_ImageCollapse = ImageWidget.Cast(
m_Root.FindAnyWidget(
"collapse_image" ) );
40 Widget child = m_ContentContainer.GetChildren();
43 if( m_Content.Find( child ) > -1 )
45 m_Content.Insert( child );
49 m_ContentContainer.Update();
53 m_ContentContainer.GetScreenSize(
x,
y );
54 if(
y > m_Scroller.GetContentHeight() )
56 m_Scroller.SetAlpha( 1 );
60 m_Scroller.SetAlpha( 0 );
64 int AddElement(
string text,
Widget content =
null )
66 ButtonWidget element = ButtonWidget.Cast(
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/dropdown_prefab/dropdown_element.layout", m_ContentContainer ) );
68 textWidget.SetText( text );
72 element.AddChild( content,
false );
74 m_ContentContainer.Update();
79 m_Content.Insert( element );
80 return m_Content.Count() - 1;
83 void RemoveElement(
int index )
85 if( 0 < index && index < m_Content.Count() )
87 delete m_Content.Get( index );
88 m_ContentContainer.Update();
108 void SetText(
string text )
115 int index = m_Content.Find( w );
118 m_OnSelectItem.Invoke( index );
130 if ( (w == m_Button || w ==
m_Text || w == m_Holder) && button ==
MouseState.LEFT )
139 m_ContentContainer.Update();