public void ShowTooltip(Point Where, String Tip) { var item = ConstructWidget(new Widget { Text = Tip, Border = "border-dark", Font = TooltipFont, TextSize = TooltipTextSize, TextColor = new Vector4(1, 1, 1, 1) }); var bestSize = item.GetBestSize(); Rectangle rect = new Rectangle( Where.X + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, Where.Y, bestSize.X, bestSize.Y); rect = MathFunctions.SnapRect(rect, RealScreen); item.Rect = rect; RootItem.AddChild(item); if (TooltipItem != null) { DestroyWidget(TooltipItem); } TooltipItem = item; }
/// <summary> /// Show a widget as a popup. Replaces any existing popup widget already displayed. /// </summary> /// <param name="Popup"></param> public void ShowPopup(Widget Popup, PopupExclusivity Exclusivity = PopupExclusivity.AddToStack) { if (Exclusivity == PopupExclusivity.DestroyExistingPopups) { CleanupPopupStack(); } PopupStack.Add(Popup); RootItem.AddChild(Popup); }
/// <summary> /// Show a widget as a popup. Replaces any existing popup widget already displayed. /// </summary> /// <param name="Popup"></param> public void ShowPopup(Widget Popup, bool DestroyOnOffClick) { if (PopupItem != null) { SafeCall(PopupItem.OnPopupClose, PopupItem); DestroyWidget(PopupItem); } PopupItem = Popup; DestroyPopupOnOffClick = DestroyOnOffClick; RootItem.AddChild(PopupItem); }
public void ShowTooltip(Point Where, String Tip) { if (TooltipItem != null) { DestroyWidget(TooltipItem); } TooltipItem = ConstructWidget(new Widget { Text = Tip, Border = "border-thin", Font = TooltipFont, TextSize = TooltipTextSize }); var bestSize = TooltipItem.GetBestSize(); TooltipItem.Rect = new Rectangle( Where.X + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, Where.Y, bestSize.X, bestSize.Y); RootItem.AddChild(TooltipItem); }
public void ShowTooltip(Point Where, Widget Tip) { if (TooltipItem != null && TooltipItem.Text == Tip.Text) { //TODO (Mklingen): handle the case where the tooltip is the same, // but the widget has moved. var myBestSize = TooltipItem.GetBestSize(); Rectangle myRect = new Rectangle( // ?? Why are we assuming the tooltip is being opened at the mouse position? Where.X + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, Where.Y + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, myBestSize.X, myBestSize.Y); if (myRect == TooltipItem.Rect) { return; } } RootItem.AddChild(Tip); var bestSize = Tip.GetBestSize(); Rectangle rect = new Rectangle( // ?? Why are we assuming the tooltip is being opened at the mouse position? Where.X + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, Where.Y + (MousePointer == null ? 0 : GetTileSheet(MousePointer.Sheet).TileWidth) + 2, bestSize.X, bestSize.Y); rect = MathFunctions.SnapRect(rect, RenderData.VirtualScreen); Tip.Rect = rect; if (TooltipItem != null) { DestroyWidget(TooltipItem); } TooltipItem = Tip; }
/// <summary> /// Show a widget as a popup. Replaces any existing popup widget already displayed. /// </summary> /// <param name="Popup"></param> public void ShowModalPopup(Widget Popup) { var screenDarkener = new Widget() { Background = new TileReference("basic", 0), BackgroundColor = new Vector4(0, 0, 0, 0.5f), Rect = RootItem.Rect }; RootItem.AddChild(screenDarkener); PopupStack.Add(screenDarkener); screenDarkener.AddChild(Popup); // Need to hook the popup's OnClose to also remove the darkener. var lambdaOnClose = Popup.OnClose; Popup.OnClose = (sender) => { this.SafeCall(lambdaOnClose, sender); screenDarkener.Children.Clear(); // Avoid recursing back into popup's OnClose. DestroyWidget(screenDarkener); }; }
/// <summary> /// Show a widget as a popup. Replaces any existing popup widget already displayed. /// </summary> /// <param name="Popup"></param> public void ShowMinorPopup(Widget Popup) { PopupStack.Add(Popup); RootItem.AddChild(Popup); }
/// <summary> /// Shortcut function for showing a uiitem as a 'dialog'. /// </summary> /// <param name="Dialog"></param> public void ShowDialog(Widget Dialog) { RootItem.AddChild(Dialog); }