3 protected Widget m_HighlightWidget;
12 static Widget CreateHighlight(Widget widget, ResourceName
layout, Widget parent =
null)
16 Print(
"Cannot create highlight, widget not found!", LogLevel.WARNING);
25 WorkspaceWidget workspace =
GetGame().GetWorkspace();
29 highlight.m_HighlightWidget = workspace.CreateWidgets(
layout, parent);
30 widget.AddHandler(highlight);
31 return highlight.m_HighlightWidget;
40 static Widget CreateHighlight(
string widgetName, ResourceName
layout, Widget parent =
null)
42 Widget widget =
GetGame().GetWorkspace().FindAnyWidget(widgetName);
45 Print(
string.Format(
"Cannot create highlight, widget '%1' not found!", widgetName), LogLevel.WARNING);
48 return CreateHighlight(widget,
layout, parent);
51 protected void Update(Widget w)
54 if (!m_HighlightWidget || !w.GetParent())
60 WorkspaceWidget workspace =
GetGame().GetWorkspace();
63 float posX, posY, posW, posH;
64 w.GetScreenPos(posX, posY);
65 w.GetScreenSize(posW, posH);
66 FrameSlot.SetPos(m_HighlightWidget, workspace.DPIUnscale(posX), workspace.DPIUnscale(posY));
67 FrameSlot.SetSize(m_HighlightWidget, workspace.DPIUnscale(posW), workspace.DPIUnscale(posH));
70 bool isVisible =
true;
73 if (!w.IsVisible() || w.GetOpacity() == 0)
80 m_HighlightWidget.SetVisible(isVisible);
82 override void HandlerAttached(Widget w)
86 GetGame().GetCallqueue().CallLater(Update, 1,
true, w);
88 override void HandlerDeattached(Widget w)
93 GetGame().GetCallqueue().Remove(Update);
96 if (m_HighlightWidget)
97 m_HighlightWidget.RemoveFromHierarchy();