Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TabViewComponent.c
Go to the documentation of this file.
3typedef ScriptInvokerBase<ScriptInvokerTabViewMethod> ScriptInvokerTabView;
7typedef ScriptInvokerBase<ScriptInvokerTabViewIndexMethod> ScriptInvokerTabViewIndex;
8
9void ScriptInvokerTabViewContentIndexMethod(SCR_TabViewComponent tabView, SCR_TabViewContent tabContent, int index);
11typedef ScriptInvokerBase<ScriptInvokerTabViewContentIndexMethod> ScriptInvokerTabViewContentIndex;
12
14{
15 [Attribute("", UIWidgets.Object, "")]
16 protected ref array<ref SCR_TabViewContent> m_aElements;
17
18 [Attribute("0", UIWidgets.EditBox, "Element selected by default")]
20
21 [Attribute("", UIWidgets.ColorPicker, "Color of gaps between tabs")]
23
24 [Attribute("0", UIWidgets.CheckBox, "Do not delete tabs, which are hidden")]
26
27 [Attribute("false", UIWidgets.CheckBox, "Create all tabs on initialization, do not wait for first selection")]
29
30 [Attribute("false", UIWidgets.CheckBox, "Do not initialize yourself. This is for initialization by supermenu.")]
32
33 [Attribute("0", UIWidgets.CheckBox, "Do not delete tabs, which are hidden")]
35
36 [Attribute("{668B05FDEF1D3268}UI/layouts/WidgetLibrary/WLib_TabViewElement.layout", UIWidgets.ResourceNamePicker, "Layout element used", "layout")]
38
39 [Attribute("true")]
40 protected bool m_ListenToActions;
41
42 [Attribute("MenuTabRight", UIWidgets.EditBox, "Action used for navigating left")]
44
45 [Attribute("MenuTabLeft", UIWidgets.EditBox, "Action used for navigating right")]
48 [Attribute("300", UIWidgets.EditBox, "Select tab width. Use -1 to use fill mode")]
50
51 [Attribute("32", UIWidgets.EditBox, "Select tab width. Use -1 to use fill mode")]
54 [Attribute(SCR_SoundEvent.TAB_SWITCH, UIWidgets.EditBox)]
55 protected string m_sSwitchSound;
57 [Attribute("0", desc: "If true it will hide the text of the tab and only show it when the tab is selected. Tabs should have images otherwise it might look weird")]
59
60 protected Widget m_wButtons;
66 // Invokers
75 //--- Called when a tab is selected, no matter if any content widget is tied to it
78 protected const float BUTTON_PADDING_RIGHT = 4;
79
80 protected const int MANW_TAB_WIDTH = 270;
81 protected const string MANW_IDENTIFIER = "MANW";
82
83 //------------------------------------------------------------------------------------------------
84 override void HandlerAttached(Widget w)
85 {
86 super.HandlerAttached(w);
87 if (!m_bManualInit)
88 Init();
89 }
90
91 //------------------------------------------------------------------------------------------------
92 void Init()
93 {
94 // Prevent multiple initialization
95 if (!m_wRoot || m_wButtonBar)
96 return;
97
98 m_wButtonBar = m_wRoot.FindAnyWidget("HorizontalLayout0");
99 m_wButtons = m_wRoot.FindAnyWidget("Tabs");
100 m_wContentOverlay = m_wRoot.FindAnyWidget("ContentOverlay");
101
103 return;
104
107
108 if (!m_aElements)
109 return;
110
111 foreach (int i, SCR_TabViewContent content : m_aElements)
112 {
116 }
117
118 int realSelected = m_iSelectedTab;
119 m_iSelectedTab = -1;
120 ShowTab(realSelected, true, false);
122 if (m_PagingLeft)
123 m_PagingLeft.SetAction(m_sActionLeft);
124
125 if (m_PagingRight)
126 m_PagingRight.SetAction(m_sActionRight);
127
130
133 }
134
135 //------------------------------------------------------------------------------------------------
136 override void HandlerDeattached(Widget w)
137 {
138 super.HandlerDeattached(w);
140 }
141
142 //------------------------------------------------------------------------------------------------
143 void CreateTab(SCR_TabViewContent content)
144 {
145 // Create tab button
146 Widget button = GetGame().GetWorkspace().CreateWidgets(m_TabLayout, m_wButtons);
147 if (!button)
148 return;
149
150 HorizontalLayoutSlot.SetPadding(button, 0, 0, BUTTON_PADDING_RIGHT, 0); // Add padding
151
153 if (!comp)
154 return;
155
156 if (!content.m_bEnabled)
157 comp.SetEnabled(false, false);
158
159 if (m_fTabWidth < 0)
160 {
161 LayoutSlot.SetSizeMode(button, LayoutSizeMode.Fill);
162 content.m_wLayout = SizeLayoutWidget.Cast(button.GetChildren());
163 }
164 else
165 {
166 SizeLayoutWidget layout = SizeLayoutWidget.Cast(button.GetChildren());
167 content.m_wLayout = layout;
168 if (layout)
169 {
170 layout.EnableWidthOverride(true);
171
172 if (content.m_sTabIdentifier == MANW_IDENTIFIER)
173 layout.SetWidthOverride(MANW_TAB_WIDTH);
174 else
175 layout.SetWidthOverride(m_fTabWidth);
176 }
177 }
178
179 comp.m_OnClicked.Insert(OnSelection);
180 comp.m_OnToggled.Insert(OnTabButtonToggle);
181 comp.SetTextWithParam(content.m_sTabButtonContent, content.m_sTabButtonContentParam1, content.m_sTabButtonContentParam2);
182 content.m_ButtonComponent = comp;
183
184 ImageWidget image = ImageWidget.Cast(button.FindAnyWidget("TabImage"));
185 if (image)
187 image.SetVisible(content.m_bShowImage);
188 if (content.m_bShowImage)
189 SCR_WLibComponentBase.SetTexture(image, content.m_TabImage, content.m_sTabImageName);
190 }
191
192 Widget imageSize = button.FindAnyWidget("SizeTabImage");
193 if (imageSize)
194 imageSize.SetVisible(content.m_bShowImage);
195
196 if (content.m_bShowIcon)
198 }
199
200 //------------------------------------------------------------------------------------------------
201 protected void CreateIcon(SCR_TabViewContent content)
202 {
203 Widget overlay = content.m_ButtonComponent.GetRootWidget().FindAnyWidget("Overlay");
204 if (!overlay)
205 return;
206
207 SizeLayoutWidget size = SizeLayoutWidget.Cast(GetGame().GetWorkspace().CreateWidget(WidgetType.SizeLayoutWidgetTypeID, WidgetFlags.VISIBLE, Color.FromInt(Color.WHITE), 0, overlay));
208 if (!size)
209 return;
210
211 float width = content.m_fIconWidth;
212 float height = content.m_fIconHeight;
213
214 size.EnableWidthOverride(true);
215 size.EnableHeightOverride(true);
216 size.SetWidthOverride(width);
217 size.SetHeightOverride(height);
218
219 OverlaySlot.SetVerticalAlign(size, LayoutVerticalAlign.Top);
220 OverlaySlot.SetHorizontalAlign(size, LayoutHorizontalAlign.Right);
221 OverlaySlot.SetPadding(size, 0, -height * 0.5, BUTTON_PADDING_RIGHT, 0); // Set some reasonable offset for the icon
222
223 content.m_wIcon = GetGame().GetWorkspace().CreateWidgets(content.m_IconLayout, size);
224 }
225
226 //------------------------------------------------------------------------------------------------
227 protected void CreateTabContent(SCR_TabViewContent content, int index)
228 {
229 ResourceName path = content.m_ElementLayout;
230 if (path == string.Empty)
231 return;
232
233 Widget w = GetGame().GetWorkspace().CreateWidgets(path, m_wContentOverlay);
234 if (!w)
235 return;
236
237 OverlaySlot.SetVerticalAlign(w, LayoutVerticalAlign.Stretch);
238 OverlaySlot.SetHorizontalAlign(w, LayoutHorizontalAlign.Stretch);
239
240 content.m_wTab = w;
241
243 m_OnContentCreate.Invoke(this, w, index);
244
245 int i = m_aElements.Find(content);
246 if (i != m_iSelectedTab)
247 {
248 w.SetVisible(false);
249 }
250 else
251 {
253
254 if (m_OnContentShow)
255 m_OnContentShow.Invoke(this, w);
256 }
257
258 SCR_MenuHelper.OnTabChange(this, w);
259
260 if (m_OnTabChange)
261 m_OnTabChange.Invoke(this, w);
262 }
263
264 //------------------------------------------------------------------------------------------------
266 {
267 Widget child = w;
268 while (child)
269 {
270 ButtonWidget button = ButtonWidget.Cast(child);
271 if (button && button.IsEnabled())
272 {
273 GetGame().GetWorkspace().SetFocusedWidget(button);
274 return;
275 }
276
277 child = child.GetChildren();
278 }
279 }
281 //------------------------------------------------------------------------------------------------
282 void ShowIcon(int entry, bool show)
283 {
284 if (entry < 0 || entry >= m_aElements.Count())
285 return;
286
287 Widget w = m_aElements[entry].m_wIcon;
288 if (w)
289 w.SetVisible(show);
290 else if (show)
291 CreateIcon(m_aElements[entry]);
292 }
294 //------------------------------------------------------------------------------------------------
295 bool IsIconShown(int entry)
296 {
297 if (entry < 0 || entry >= m_aElements.Count())
298 return false;
299
300 Widget w = m_aElements[entry].m_wIcon;
301 if (w && w.IsVisible())
302 return true;
303
304 return false;
305 }
306
307 //------------------------------------------------------------------------------------------------
309 {
310 if (entry < 0 || entry > m_aElements.Count())
311 return null;
312
313 return m_aElements[entry].m_wIcon;
314 }
315
316 //------------------------------------------------------------------------------------------------
317 SCR_TabViewContent GetEntryContent(int index)
318 {
320 return null;
321
322 return m_aElements[index];
323 }
324
325 //------------------------------------------------------------------------------------------------
326 array<ref SCR_TabViewContent> GetContents()
327 {
328 return m_aElements;
329 }
330
331 //------------------------------------------------------------------------------------------------
332 SCR_TabViewContent GetContent(int index)
333 {
334 if (!m_aElements.IsIndexValid(index))
335 return null;
337 return m_aElements[index];
338 }
339
340 //------------------------------------------------------------------------------------------------
342 {
343 SCR_TabViewContent content = GetContent(index);
344 if (!content)
345 return null;
346
347 return content.m_wTab;
348 }
349
350 //------------------------------------------------------------------------------------------------
351 protected void SelectIndex(bool select, int i)
352 {
353 if (!m_aElements || i < 0 || i >= m_aElements.Count())
354 return;
355
356 SCR_TabViewContent content = m_aElements[i];
357 if (!content)
358 return;
359
360 if (!content.m_ButtonComponent)
361 return;
362
363 content.m_ButtonComponent.SetToggled(select, false);
364
365 Widget tab = content.m_wTab;
366 if (select)
367 {
368 if (m_bKeepHiddenTabs && tab)
369 {
370 if (m_OnContentShow)
371 m_OnContentShow.Invoke(this, tab);
372
373 tab.SetVisible(true);
374 FocusFirstWidget(tab);
375 }
376 else
377 {
379 }
380
382 m_OnContentSelect.Invoke(this, content, i);
383 }
384 else
385 {
386 if (!tab)
387 return;
388
390 {
391 if (m_OnContentHide)
392 m_OnContentHide.Invoke(this, tab);
393
394 tab.SetVisible(false);
395 }
396 else
399 m_OnContentRemove.Invoke(this, tab);
400
401 tab.RemoveFromHierarchy();
402 }
403 }
404
405 SCR_MenuHelper.OnTabChange(this, tab);
406
407 if (m_OnTabChange)
408 m_OnTabChange.Invoke(this, tab);
409 }
410
411 //------------------------------------------------------------------------------------------------
412 void ShowTab(int i, bool callAction = true, bool playSound = true)
413 {
414 if (i == m_iSelectedTab)
415 callAction = false;
416
418 {
419 ShowTabText(i, true, m_fTabWidth);
421 }
422
423 // Do not switch into invalid or disabled element
424 if (i < 0 || i >= m_aElements.Count() || !m_aElements[i].m_bEnabled)
425 return;
426
427 // Deselect old tab, select new tab
429 m_iSelectedTab = i;
430 SelectIndex(true, i);
431
432 if (playSound)
434
435 if (callAction && m_OnChanged)
436 m_OnChanged.Invoke(this, m_wRoot, m_iSelectedTab);
437
439 }
441 //------------------------------------------------------------------------------------------------
442 void ShowTabByIdentifier(string identifier, bool callAction = true, bool playSound = true)
443 {
444 for (int i = 0; i < m_aElements.Count(); i++)
445 {
446 if (m_aElements[i].m_sTabIdentifier == identifier)
447 {
448 ShowTab(i, callAction, playSound);
449 return;
450 }
451 }
453
454 //------------------------------------------------------------------------------------------------
456 {
457 return m_iSelectedTab;
458 }
459
460 //------------------------------------------------------------------------------------------------
462 {
463 return m_aElements.Count();
464 }
465
466 //------------------------------------------------------------------------------------------------
467 void AddTab(ResourceName layout, string content, bool enabled = true, ResourceName tabImage = string.Empty, ResourceName iconLayout = string.Empty, float width = 32, float height = 32, string contentParam1 = string.Empty, string contentParam2 = string.Empty, string identifier = string.Empty)
468 {
469 SCR_TabViewContent tabContent = new SCR_TabViewContent;
470 tabContent.m_ElementLayout = layout;
471 tabContent.m_bEnabled = enabled;
472 tabContent.m_sTabButtonContent = content;
473 tabContent.m_sTabButtonContentParam1 = contentParam1;
474 tabContent.m_sTabButtonContentParam2 = contentParam2;
475 tabContent.m_sTabIdentifier = identifier;
476
477 if (iconLayout != string.Empty)
478 {
479 tabContent.m_bShowIcon = true;
480 tabContent.m_IconLayout = iconLayout;
481 tabContent.m_fIconWidth = width;
482 tabContent.m_fIconHeight = height;
483 }
484
485 if (!tabImage.IsEmpty())
486 {
487 tabContent.m_TabImage = tabImage;
488 tabContent.m_bShowImage = true;
489 }
490
491 m_aElements.Insert(tabContent);
493 // If tabView wasn't initialized do not create anything
494 if (!m_wButtonBar)
495 return;
496
497 // Create button
498 CreateTab(tabContent);
499
501 CreateTabContent(tabContent, m_aElements.Count() - 1);
502
504 }
505
506 //------------------------------------------------------------------------------------------------
507 void RemoveTab(int index)
508 {
509 SCR_TabViewContent content = m_aElements[index];
510 if (!content)
511 return;
512
513 // Always remove ordered
514 if (content.m_ButtonComponent)
515 {
516 Widget button = content.m_ButtonComponent.GetRootWidget();
517 if (button)
518 button.RemoveFromHierarchy();
519 }
520
521 Widget tab = content.m_wTab;
522 if (tab)
523 {
524 if (m_OnContentHide)
525 m_OnContentHide.Invoke(this, tab);
526
528 m_OnContentRemove.Invoke(this, tab);
529
530 content.m_wTab.RemoveFromHierarchy();
531 }
532
533 SCR_TabViewContent currentContent = m_aElements[m_iSelectedTab];
534
535 m_aElements.RemoveOrdered(index);
536
537 int newIndex = m_aElements.Find(currentContent);
538
539 if (index == m_iSelectedTab)
540 ShowTab(0, true);
541 else
542 ShowTab(newIndex, true, playSound: false);
543
545 }
547 //------------------------------------------------------------------------------------------------
548 void RemoveTabByIdentifier(string identifier)
549 {
550 for (int i = 0; i < m_aElements.Count(); i++)
551 {
552 if (m_aElements[i].m_sTabIdentifier == identifier)
553 {
554 RemoveTab(i);
555 return;
556 }
557 }
558 }
559
560 //------------------------------------------------------------------------------------------------
561 void AddContentElement(SCR_TabViewContent content)
562 {
563 m_aElements.Insert(content);
564 }
565
566 //------------------------------------------------------------------------------------------------
567 void ShowTabText(int index, bool show, int buttonWidth = -1)
568 {
570 return;
571
572 m_aElements[index].m_ButtonComponent.GetTextWidget().SetVisible(show);
573
574 if (buttonWidth > 0 && m_aElements[index].m_wLayout)
575 {
576 if (m_aElements[index].m_wLayout)
577 {
578 m_aElements[index].m_wLayout.EnableWidthOverride(true);
579 m_aElements[index].m_wLayout.SetWidthOverride(buttonWidth);
580 }
581 }
582 }
583
584 //------------------------------------------------------------------------------------------------
585 void ShowAllTabsText(bool show, int buttonWidth = -1, bool ignoreSelected = true)
586 {
587 if (ignoreSelected)
588 {
589 for (int i = 0; i < m_aElements.Count(); i++)
591 if (i != m_iSelectedTab)
592 ShowTabText(i, show, buttonWidth);
593 }
594 }
595 else
596 {
597 for (int i = 0; i < m_aElements.Count(); i++)
598 {
599 ShowTabText(i, show, buttonWidth);
600 }
601 }
602 }
604 //------------------------------------------------------------------------------------------------
605 void SetTabText(int index, string text, string textParam1 = string.Empty, string textParam2 = string.Empty)
606 {
608 return;
609
610 m_aElements[index].m_sTabButtonContent = text;
611 m_aElements[index].m_sTabButtonContentParam1 = textParam1;
612 m_aElements[index].m_sTabButtonContentParam2 = textParam2;
613
614 m_aElements[index].m_ButtonComponent.GetTextWidget().SetTextFormat(text, textParam1, textParam2);
615 }
616
617 //------------------------------------------------------------------------------------------------
618 void SetTabImage(int index, ResourceName tabImage)
619 {
621 return;
622
623 m_aElements[index].m_TabImage = tabImage;
624 m_aElements[index].m_bShowImage = true;
625
626 Widget tabRoot = m_aElements[index].m_ButtonComponent.GetRootWidget();
627
628 ImageWidget image = ImageWidget.Cast(tabRoot.FindAnyWidget("TabImage"));
629 if (image)
630 {
631 image.LoadImageTexture(0, tabImage);
632 image.SetVisible(true);
633 }
634
635 Widget imageSize = tabRoot.FindAnyWidget("SizeTabImage");
636 if (imageSize)
637 imageSize.SetVisible(true);
638 }
639
640 //------------------------------------------------------------------------------------------------
641 void ShowImage(int index, bool show)
642 {
644 return;
645
646 Widget tabRoot = m_aElements[index].m_ButtonComponent.GetRootWidget();
647
648 ImageWidget image = ImageWidget.Cast(tabRoot.FindAnyWidget("TabImage"));
649 if (image)
650 image.SetVisible(show);
651
652 Widget imageSize = tabRoot.FindAnyWidget("SizeTabImage");
653 if (imageSize)
654 imageSize.SetVisible(show);
655 }
656
657 //------------------------------------------------------------------------------------------------
659 {
660 for (int i = 0, len = m_aElements.Count(); i < len; i++)
661 {
662 // Deselect the old button, select the new button
663 if (m_aElements[i].m_ButtonComponent != button)
664 continue;
665
666 // Prevent change when clicking same button
667 if (m_iSelectedTab == i)
668 {
669 m_aElements[i].m_ButtonComponent.SetToggled(true);
670 return;
671 }
672
673 ShowTab(i);
674 return;
675 }
676 }
678 //------------------------------------------------------------------------------------------------
681 protected void OnTabButtonToggle(SCR_ButtonBaseComponent button, bool isToggled)
682 {
683 if (!button)
684 return;
685
686 SCR_ModularButtonComponent modularButton = SCR_ModularButtonComponent.Cast(button.GetRootWidget().FindHandler(SCR_ModularButtonComponent));
687 if (modularButton)
688 modularButton.SetToggled(isToggled);
689 }
690
691 //------------------------------------------------------------------------------------------------
692 protected void OnTabLeft()
693 {
695 return;
696
697 int i = GetNextValidItem(true);
698 if (i >= 0)
699 ShowTab(i);
701
702 //------------------------------------------------------------------------------------------------
703 protected void OnTabRight()
704 {
706 return;
707
708 int i = GetNextValidItem(false);
709 if (i >= 0)
710 ShowTab(i);
711 }
712
713 //------------------------------------------------------------------------------------------------
715 protected void UpdatePagingButtons(bool animate = true)
716 {
717 if (m_PagingLeft)
718 m_PagingLeft.SetEnabled(GetNextValidItem(true) > -1 && m_ListenToActions, animate);
719 if (m_PagingRight)
720 m_PagingRight.SetEnabled(GetNextValidItem(false) > -1 && m_ListenToActions, animate);
721 }
722
723 //------------------------------------------------------------------------------------------------
724 int GetNextValidItem(bool toLeft)
725 {
726 if (m_aElements.IsEmpty())
727 return -1;
728
729 SCR_ButtonTextComponent selectedElement;
730 int lastIndex = m_aElements.Count() - 1;
731
732 int i = m_iSelectedTab;
733 int foundItem = -1;
734 int nextItem = 1;
735 if (toLeft)
736 nextItem = -1;
737
738 while (foundItem < 0)
739 {
740 i += nextItem;
741 if (i < 0)
742 {
743 if (m_bCycleMode)
744 i = lastIndex;
745 else
746 return -1;
747
748 }
749 else if (i > lastIndex)
750 {
751 if (m_bCycleMode)
752 i = 0;
753 else
754 return -1;
755 }
756
757 if (m_iSelectedTab >= 0 && m_iSelectedTab >= lastIndex && m_aElements[m_iSelectedTab] == m_aElements[i])
758 return -1; // Went through all elements, found nothing
759
760 if (m_aElements[i].m_bEnabled)
761 foundItem = i;
762 }
763 return foundItem;
764 }
765
766 //------------------------------------------------------------------------------------------------
767 void EnableTab(int tabIndex, bool enable, bool animate = true)
768 {
769 if (tabIndex < 0 || tabIndex >= m_aElements.Count())
770 return;
772 SCR_TabViewContent tab = m_aElements[tabIndex];
773 if (!tab)
774 return;
775
776 if (!tab.m_ButtonComponent)
777 return;
778
779 tab.m_ButtonComponent.SetEnabled(enable, animate);
780 tab.m_bEnabled = tab.m_ButtonComponent.IsVisible() && tab.m_ButtonComponent.IsEnabled();
781
783 }
784
785 //------------------------------------------------------------------------------------------------
786 void EnableAllTabs(bool enable, bool ignoreCurrentActive = true, bool animate = true)
787 {
788 int count = m_aElements.Count();
789
790 for (int i = 0; i < count; i++)
791 {
792 if (ignoreCurrentActive && m_iSelectedTab == i)
793 continue;
794
795 EnableTab(i, enable, animate);
796 }
797 }
798
799 //------------------------------------------------------------------------------------------------
800 void SetTabVisible(int tabIndex, bool visible, bool animate = true)
801 {
802 if (tabIndex < 0 || tabIndex >= m_aElements.Count())
803 return;
804
805 SCR_TabViewContent tab = m_aElements[tabIndex];
806 if (!tab)
807 return;
808
809 if (!tab.m_ButtonComponent)
810 return;
811
812 tab.m_ButtonComponent.SetVisible(visible, animate);
813 tab.m_bEnabled = tab.m_ButtonComponent.IsVisible() && tab.m_ButtonComponent.IsEnabled();
814
816
817 //~ If active tab is set invisible try to set new active tab. If fails it will keep the current tab active
818 if (!visible && tabIndex == GetShownTab())
819 {
820 for (int i = 0; i < m_aElements.Count(); i++)
821 {
822 if (!m_aElements[i].m_ButtonComponent)
823 continue;
824
825 if (m_aElements[i].m_ButtonComponent.IsVisible() && m_aElements[i].m_ButtonComponent.IsEnabled())
826 {
827 ShowTab(i, true, animate);
828 break;
829 }
830 }
831 }
832 }
833
834 //------------------------------------------------------------------------------------------------
835 void Enable(bool enable)
837 Widget w = m_wRoot.FindAnyWidget("ContentOverlay");
838 w.SetEnabled(enable);
839 }
840
841 //------------------------------------------------------------------------------------------------
842 bool IsTabEnabled(int tabIndex)
843 {
844 if (tabIndex == -1 || tabIndex >= m_aElements.Count())
845 return false;
846
847 return m_aElements[tabIndex].m_bEnabled;
849
850 //------------------------------------------------------------------------------------------------
851 void SetCanNavigate(bool isAllowed)
852 {
853 m_ListenToActions = isAllowed;
855
856 //------------------------------------------------------------------------------------------------
858 {
859 return m_ListenToActions;
861
862 //------------------------------------------------------------------------------------------------
863 void SetListenToActions(bool isAllowed)
864 {
865 m_ListenToActions = isAllowed;
866 }
867
868 //------------------------------------------------------------------------------------------------
871 return m_ListenToActions;
872 }
873
874 //------------------------------------------------------------------------------------------------
875 protected void AddActionListeners()
876 {
877 if (m_PagingLeft)
878 m_PagingLeft.m_OnActivated.Insert(OnTabLeft);
880 if (m_PagingRight)
881 m_PagingRight.m_OnActivated.Insert(OnTabRight);
882 }
883
884 //------------------------------------------------------------------------------------------------
885 protected void RemoveActionListeners()
886 {
887 if (m_PagingLeft)
888 m_PagingLeft.m_OnActivated.Remove(OnTabLeft);
889 if (m_PagingRight)
890 m_PagingRight.m_OnActivated.Remove(OnTabRight);
891 }
892
893 //------------------------------------------------------------------------------------------------
894 SCR_TabViewContent GetShownTabComponent()
895 {
897 }
899 //------------------------------------------------------------------------------------------------
900 void SetEntryIconSize(int index, float width = -1, float height = -1)
901 {
903 return;
904
905 if (width > 0)
906 m_aElements[index].m_fIconWidth = width;
907
908 if (height > 0)
909 m_aElements[index].m_fIconHeight = height;
911
912 //------------------------------------------------------------------------------------------------
913 void SetPagingButtonsVisible(bool visible, bool animate = true)
914 {
915 if (m_PagingLeft)
916 m_PagingLeft.SetVisible(visible, animate);
917 if (m_PagingRight)
918 m_PagingRight.SetVisible(visible, animate);
920
921 //------------------------------------------------------------------------------------------------
922 // --- Invokers ---
923 //------------------------------------------------------------------------------------------------
924 //------------------------------------------------------------------------------------------------
926 {
927 if (!m_OnChanged)
929
930 return m_OnChanged;
931 }
932
933 //------------------------------------------------------------------------------------------------
935 {
938
939 return m_OnContentCreate;
940 }
941
942 //------------------------------------------------------------------------------------------------
944 {
945 if (!m_OnContentShow)
947
948 return m_OnContentShow;
949 }
950
951 //------------------------------------------------------------------------------------------------
953 {
954 if (!m_OnContentHide)
956
957 return m_OnContentHide;
958 }
959
960 //------------------------------------------------------------------------------------------------
962 {
965
966 return m_OnContentRemove;
967 }
968
969 //------------------------------------------------------------------------------------------------
971 {
972 if (!m_OnTabChange)
974
975 return m_OnTabChange;
976 }
977
978 //------------------------------------------------------------------------------------------------
986}
987
988//------------------------------------------------------------------------------------------------
990class SCR_TabViewContent
991{
992 [Attribute("", UIWidgets.ResourceNamePicker, "Layout element used", "layout")]
993 ResourceName m_ElementLayout;
994
995 [Attribute("Button", UIWidgets.EditBox, "Content of the button: It can contain either name or image resource")]
996 string m_sTabButtonContent;
997
998 [Attribute("", UIWidgets.EditBox, "Unique identifier of tab used in script to look for this one - optional for now")]
999 string m_sTabIdentifier;
1000
1001 [Attribute(desc: "Param if m_sTabButtonContent is name rather then image resource")]
1002 LocalizedString m_sTabButtonContentParam1;
1003
1004 [Attribute(desc: "Param if m_sTabButtonContent is name rather then image resource")]
1005 LocalizedString m_sTabButtonContentParam2;
1006
1007 [Attribute("true", UIWidgets.CheckBox, "Is tab enabled?")]
1008 bool m_bEnabled;
1009
1010 [Attribute(desc: "Image shown in front of tab text", params: "edds imageset")]
1011 ResourceName m_TabImage;
1012
1013 [Attribute(desc: "Image name used in front of tab text when using image set")]
1014 string m_sTabImageName;
1015
1016 [Attribute("0")]
1017 bool m_bShowImage;
1018
1019 [Attribute()]
1020 bool m_bShowIcon;
1021
1022 [Attribute("{6B997B683BD0FC21}UI/layouts/WidgetLibrary/TabView/WLib_TabViewInfoIcon.layout", UIWidgets.ResourceNamePicker, "", "Path to layout")]
1023 ResourceName m_IconLayout;
1024
1025 [Attribute("32")]
1026 float m_fIconWidth;
1027
1028 [Attribute("32")]
1029 float m_fIconHeight;
1030
1032 SCR_ButtonTextComponent m_ButtonComponent;
1033 Widget m_wTab;
1034 SizeLayoutWidget m_wLayout;
1035}
string path
class RestAPIHelper< JsonApiStruct T > content
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI layouts Menus CleanSweep CleanSweepAreaSelection layout
Widget m_wRoot
ImageWidget m_wIcon
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ScriptedWidgetTooltipContentBase GetContent()
ref ScriptInvokerTabView m_OnContentRemove
void OnTabRight()
string m_sActionRight
func ScriptInvokerTabViewContentIndexMethod
ref ScriptInvokerTabView m_OnContentShow
func ScriptInvokerTabViewIndexMethod
string m_sSwitchSound
float m_fTabWidthTextHidden
ref ScriptInvokerTabView m_OnContentHide
func ScriptInvokerTabViewMethod
bool m_bCreateAllTabsAtStart
const float BUTTON_PADDING_RIGHT
ref ScriptInvokerTabViewIndex m_OnChanged
SCR_TabViewComponent SCR_ScriptedWidgetComponent BaseContainerProps()
bool m_ListenToActions
ref array< ref SCR_TabViewContent > m_aElements
SCR_PagingButtonComponent m_PagingLeft
int m_iSelectedTab
ScriptInvokerBase< ScriptInvokerTabViewContentIndexMethod > ScriptInvokerTabViewContentIndex
bool m_bShowTextOnlyWhenSelectedTab
string m_sActionLeft
Widget m_wButtonBar
SCR_TabViewComponent SCR_ScriptedWidgetComponent SCR_BaseContainerLocalizedTitleField("m_sTabButtonContent")
SCR_PagingButtonComponent m_PagingRight
ScriptInvokerBase< ScriptInvokerTabViewMethod > ScriptInvokerTabView
ScriptInvokerBase< ScriptInvokerTabViewIndexMethod > ScriptInvokerTabViewIndex
ref ScriptInvokerTabViewIndex m_OnContentCreate
override void CreateWidget(Widget parent)
Definition Color.c:13
Base class for any button, regardless its own content.
void SetTextWithParam(string text, string param1, string param2)
static SCR_PagingButtonComponent GetPagingButtonComponent(string name, Widget parent, bool searchAllChildren=true)
array< ref SCR_TabViewContent > GetContents()
ref ScriptInvokerTabView m_OnContentShow
void AddContentElement(SCR_TabViewContent content)
ref ScriptInvokerTabView m_OnContentRemove
SCR_TabViewContent GetContent(int index)
SCR_PagingButtonComponent m_PagingLeft
void EnableTab(int tabIndex, bool enable, bool animate=true)
void SetPagingButtonsVisible(bool visible, bool animate=true)
ref ScriptInvokerTabViewIndex m_OnChanged
void ShowTabText(int index, bool show, int buttonWidth=-1)
override void HandlerDeattached(Widget w)
void SetTabImage(int index, ResourceName tabImage)
ScriptInvokerTabViewIndex GetOnContentCreate()
void ShowTab(int i, bool callAction=true, bool playSound=true)
Widget GetEntryIcon(int entry)
ScriptInvokerTabView GetOnContentRemove()
void CreateTabContent(SCR_TabViewContent content, int index)
void ShowIcon(int entry, bool show)
void AddTab(ResourceName layout, string content, bool enabled=true, ResourceName tabImage=string.Empty, ResourceName iconLayout=string.Empty, float width=32, float height=32, string contentParam1=string.Empty, string contentParam2=string.Empty, string identifier=string.Empty)
SCR_PagingButtonComponent m_PagingRight
ScriptInvokerTabView GetOnContentShow()
void SetListenToActions(bool isAllowed)
void ShowAllTabsText(bool show, int buttonWidth=-1, bool ignoreSelected=true)
void SelectIndex(bool select, int i)
void RemoveTabByIdentifier(string identifier)
SCR_TabViewContent GetShownTabComponent()
ref ScriptInvokerTabViewContentIndex m_OnContentSelect
void CreateTab(SCR_TabViewContent content)
void SetTabVisible(int tabIndex, bool visible, bool animate=true)
override void HandlerAttached(Widget w)
ref ScriptInvokerTabView m_OnContentHide
ref array< ref SCR_TabViewContent > m_aElements
void SetEntryIconSize(int index, float width=-1, float height=-1)
void EnableAllTabs(bool enable, bool ignoreCurrentActive=true, bool animate=true)
bool IsTabEnabled(int tabIndex)
int GetNextValidItem(bool toLeft)
void OnTabButtonToggle(SCR_ButtonBaseComponent button, bool isToggled)
void SetCanNavigate(bool isAllowed)
void CreateIcon(SCR_TabViewContent content)
void ShowImage(int index, bool show)
void UpdatePagingButtons(bool animate=true)
Enable or disable paging buttons, if it's possible to page to the right or left.
Widget GetContentWidget(int index)
void OnSelection(SCR_ButtonBaseComponent button)
void SetTabText(int index, string text, string textParam1=string.Empty, string textParam2=string.Empty)
ScriptInvokerTabViewIndex GetOnChanged()
ScriptInvokerTabView GetOnContentHide()
void ShowTabByIdentifier(string identifier, bool callAction=true, bool playSound=true)
SCR_TabViewContent GetEntryContent(int index)
ref ScriptInvokerTabView m_OnTabChange
ScriptInvokerTabView GetOnTabChange()
ref ScriptInvokerTabViewIndex m_OnContentCreate
ScriptInvokerTabViewContentIndex GetOnContentSelect()
Base class for all final Reforger interactive elements.
static bool SetTexture(ImageWidget widget, ResourceName texture, string image="")
SCR_FieldOfViewSettings Attribute
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14
LayoutHorizontalAlign
LayoutSizeMode
LayoutVerticalAlign