8 protected string m_sTickBoxImageName;
11 protected string m_sTickBoxButtonName;
15 protected ResourceName m_sTickBoxImageToggled;
18 protected ResourceName m_sTickBoxImageUntoggled;
22 protected typename m_LinkedOverrideAttributeType =
typename.Empty;
23 protected Widget m_Root;
24 protected ImageWidget m_TickBoxImage;
25 protected Widget m_TickBoxButton;
27 protected float m_fDisabledAlphaColor = 0.25;
30 protected bool m_bToggled;
31 protected bool m_bEnabled =
true;
39 void ToggleTickbox(
bool toggled)
46 if (m_OnToggleChanged)
47 m_OnToggleChanged.Invoke(toggled);
51 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageToggled);
52 m_TickBoxImage.SetImage(0);
56 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageUntoggled);
57 m_TickBoxImage.SetImage(0);
60 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
61 if (!attributesManager)
64 if (m_LinkedOverrideAttributeType !=
typename.Empty)
67 overideValue.SetBool(toggled);
68 attributesManager.SetAttributeVariable(m_LinkedOverrideAttributeType, overideValue);
75 void ToggleEnableByAttribute(
bool enabled)
81 protected void OnButtonToggle()
97 bool IsVisibleAndEnabled()
99 return m_TickBoxButton.IsEnabled() &&
m_Root.IsVisible();
105 if (!m_OnToggleChanged)
108 return m_OnToggleChanged;
115 protected void SetVisible(
bool frameVisible,
bool buttonVisible)
117 m_Root.SetVisible(frameVisible);
118 m_TickBoxButton.SetVisible(buttonVisible);
122 protected void SetEnabled(
bool enabled)
127 Color color = Color.FromInt(m_TickBoxImage.GetColor().PackToInt());
129 color.SetA(m_fDisabledAlphaColor);
133 m_TickBoxImage.SetColor(color);
135 m_TickBoxButton.SetEnabled(enabled);
154 m_LinkedOverrideAttributeType = linkedOverrideAttributeType;
156 SetVisible(
true,
true);
157 ToggleTickbox(toggleState);
158 m_AttributeUI = attributeUI;
162 m_AttributeUI.GetOnEnabledByAttribute().Insert(OnAttributeEnabledByAttribute);
163 SetEnabled(m_AttributeUI.GetAttribute().IsEnabled());
171 SetVisible(
true,
true);
174 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageToggled);
175 m_TickBoxImage.SetImage(0);
179 protected void OnAttributeEnabledByAttribute(
bool enabled)
185 override void HandlerAttached(Widget w)
189 m_TickBoxImage = ImageWidget.Cast(w.FindAnyWidget(m_sTickBoxImageName));
193 m_TickBoxButton = w.FindAnyWidget(m_sTickBoxButtonName);
194 if (!m_TickBoxButton)
198 if (onButton) onButton.Insert(OnButtonToggle);
202 override void HandlerDeattached(Widget w)
205 m_AttributeUI.GetOnEnabledByAttribute().Remove(OnAttributeEnabledByAttribute);