mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Refactor Controls to default to MouseFilterMode.Ignore (#1011)
* Refactor Controls to default to MouseFilterMode.Ignore * Clean up MouseFilterMode.Ignore from Controls * Fix BoxContainer eating UI clicks * Fix ScrollContainer using the wrong variable * Refactor ContainerButtons to use a StyleClass for formatting instead of typeof * Refactor BaseButton to work when child has MouseFilter.Pass
This commit is contained in:
@@ -221,8 +221,6 @@ namespace Robust.Client.State.States
|
||||
|
||||
private void PerformLayout()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
|
||||
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
var layout = new LayoutContainer();
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Robust.Client.UserInterface
|
||||
/// The mode that controls how mouse filtering works. See the enum for how it functions.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public MouseFilterMode MouseFilter { get; set; } = MouseFilterMode.Stop;
|
||||
public MouseFilterMode MouseFilter { get; set; } = MouseFilterMode.Ignore;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this control can take keyboard focus.
|
||||
|
||||
@@ -185,6 +185,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
/// </summary>
|
||||
public event Action<ButtonToggledEventArgs> OnToggled;
|
||||
|
||||
protected BaseButton()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
}
|
||||
|
||||
protected virtual void DrawModeChanged()
|
||||
{
|
||||
}
|
||||
@@ -245,8 +250,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
OnButtonUp?.Invoke(buttonEventArgs);
|
||||
|
||||
var drawMode = DrawMode;
|
||||
if (Mode == ActionMode.Release && _attemptingPress &&
|
||||
this == UserInterfaceManagerInternal.MouseGetControl(args.PointerLocation.Position))
|
||||
if (Mode == ActionMode.Release && _attemptingPress && HasPoint((args.PointerLocation.Position - GlobalPixelPosition) / UIScale))
|
||||
{
|
||||
// Can't un press a radio button directly.
|
||||
if (Group == null || !Pressed)
|
||||
|
||||
@@ -15,11 +15,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
private const int DefaultSeparation = 1;
|
||||
private protected abstract bool Vertical { get; }
|
||||
|
||||
protected BoxContainer()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies "where" the controls should be laid out.
|
||||
/// </summary>
|
||||
|
||||
@@ -8,12 +8,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
/// </summary>
|
||||
public class Button : ContainerButton
|
||||
{
|
||||
public const string StyleClassButton = "button";
|
||||
|
||||
public Label Label { get; }
|
||||
|
||||
public Button() : base()
|
||||
{
|
||||
AddStyleClass(StyleClassButton);
|
||||
Label = new Label
|
||||
{
|
||||
StyleClasses = { StyleClassButton }
|
||||
|
||||
@@ -21,21 +21,16 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
StyleClasses = { StyleClassCheckBox },
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
AddChild(hBox);
|
||||
|
||||
TextureRect = new TextureRect
|
||||
{
|
||||
StyleClasses = { StyleClassCheckBox },
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
hBox.AddChild(TextureRect);
|
||||
|
||||
Label = new Label
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
Label = new Label();
|
||||
hBox.AddChild(Label);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ namespace Robust.Client.UserInterface.Controls
|
||||
public class ContainerButton : BaseButton
|
||||
{
|
||||
public const string StylePropertyStyleBox = "stylebox";
|
||||
public const string StyleClassButton = "button";
|
||||
public const string StylePseudoClassNormal = "normal";
|
||||
public const string StylePseudoClassPressed = "pressed";
|
||||
public const string StylePseudoClassHover = "hover";
|
||||
public const string StylePseudoClassDisabled = "disabled";
|
||||
|
||||
public ContainerButton()
|
||||
public ContainerButton() : base()
|
||||
{
|
||||
DrawModeChanged();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public ItemList()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
|
||||
RectClipContent = true;
|
||||
|
||||
_scrollBar = new VScrollBar
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public Label()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public MenuBarTopButton(Menu menu)
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
Menu = menu;
|
||||
AddChild(Label = new Label {Text = menu.Title});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.Label;
|
||||
|
||||
namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
@@ -21,15 +20,13 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public string Prefix { get; set; }
|
||||
|
||||
public OptionButton()
|
||||
public OptionButton() : base()
|
||||
{
|
||||
AddStyleClass(StyleClassButton);
|
||||
Prefix = "";
|
||||
OnPressed += _onPressed;
|
||||
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
var hBox = new HBoxContainer();
|
||||
AddChild(hBox);
|
||||
|
||||
_popup = new Popup();
|
||||
@@ -41,7 +38,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
StyleClasses = { StyleClassOptionButton },
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
hBox.AddChild(_label);
|
||||
|
||||
@@ -49,7 +45,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
StyleClasses = { StyleClassOptionTriangle },
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
hBox.AddChild(textureRect);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -27,6 +27,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public OutputPanel()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
RectClipContent = true;
|
||||
|
||||
_scrollBar = new VScrollBar
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
@@ -17,8 +17,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
public PopupContainer()
|
||||
{
|
||||
RectClipContent = true;
|
||||
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
}
|
||||
|
||||
public static void SetPopupOrigin(Control control, Vector2 origin)
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
protected ScrollBar(OrientationMode orientation)
|
||||
{
|
||||
_orientation = orientation;
|
||||
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
|
||||
_orientation = orientation;
|
||||
}
|
||||
|
||||
public bool IsAtEnd
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public ScrollContainer()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
RectClipContent = true;
|
||||
|
||||
Action<Range> ev = _scrollValueChanged;
|
||||
@@ -181,7 +182,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
_vScrollBar.ValueTarget -= args.Delta.Y * 50;
|
||||
}
|
||||
|
||||
if (_vScrollEnabled)
|
||||
if (_hScrollEnabled)
|
||||
{
|
||||
_hScrollBar.ValueTarget += args.Delta.X * 50;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.LayoutContainer;
|
||||
|
||||
@@ -65,27 +65,16 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public Slider()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Stop;
|
||||
|
||||
AddChild(new LayoutContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
Children =
|
||||
{
|
||||
(_backgroundPanel = new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
}),
|
||||
(_fillPanel = new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
}),
|
||||
(_foregroundPanel = new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
}),
|
||||
(_grabber = new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
})
|
||||
(_backgroundPanel = new PanelContainer()),
|
||||
(_fillPanel = new PanelContainer()),
|
||||
(_foregroundPanel = new PanelContainer()),
|
||||
(_grabber = new PanelContainer())
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public SpinBox() : base()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
|
||||
_lineEdit = new LineEdit
|
||||
{
|
||||
CustomMinimumSize = new Vector2(40, 0),
|
||||
|
||||
@@ -66,6 +66,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public event Action<int> OnTabChanged;
|
||||
|
||||
public TabContainer()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
}
|
||||
|
||||
public string GetTabTitle(int tab)
|
||||
{
|
||||
return _tabData[tab].Name ?? GetChild(tab).Name ?? Loc.GetString("No title");
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public Tree()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
RectClipContent = true;
|
||||
|
||||
_scrollBar = new VScrollBar
|
||||
@@ -99,6 +100,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
_selectedIndex = item.Index;
|
||||
OnItemSelected?.Invoke();
|
||||
args.Handle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
private void PerformLayout()
|
||||
{
|
||||
Visible = false;
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
|
||||
var styleBox = new StyleBoxFlat
|
||||
{
|
||||
@@ -60,7 +59,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
AddChild(new LayoutContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
Children =
|
||||
{
|
||||
(MainControl = new VBoxContainer
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
var gameTiming1 = gameTiming;
|
||||
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
Visible = false;
|
||||
|
||||
/*
|
||||
|
||||
@@ -83,7 +83,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
(SearchBar = new LineEdit
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Stop,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
PlaceHolder = _loc.GetString("Search")
|
||||
}),
|
||||
@@ -409,11 +408,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
public const float Separation = 2;
|
||||
|
||||
public PrototypeListContainer()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
}
|
||||
|
||||
protected override Vector2 CalculateMinimumSize()
|
||||
{
|
||||
if (ChildCount == 0)
|
||||
@@ -469,13 +463,11 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
AddChild(new HBoxContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
Children =
|
||||
{
|
||||
(EntityTextureRect = new TextureRect
|
||||
{
|
||||
CustomMinimumSize = (32, 32),
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
||||
SizeFlagsVertical = SizeFlags.ShrinkCenter,
|
||||
Stretch = TextureRect.StretchMode.KeepAspectCentered,
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
FontColorShadowOverride = Color.Black;
|
||||
ShadowOffsetXOverride = 1;
|
||||
ShadowOffsetYOverride = 1;
|
||||
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
}
|
||||
|
||||
protected override void Update(FrameEventArgs args)
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
_gameTiming = gameTiming;
|
||||
|
||||
SizeFlagsHorizontal = SizeFlags.None;
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
}
|
||||
|
||||
protected override Vector2 CalculateMinimumSize()
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
public SS14Window()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Stop;
|
||||
|
||||
AddChild(new PanelContainer
|
||||
{
|
||||
StyleClasses = {StyleClassWindowPanel}
|
||||
@@ -31,7 +33,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
new PanelContainer
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
StyleClasses = {StyleClassWindowHeader},
|
||||
CustomMinimumSize = (0, HEADER_SIZE_Y),
|
||||
Children =
|
||||
@@ -44,7 +45,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
MarginLeftOverride = 5,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
Children =
|
||||
{
|
||||
(TitleLabel = new Label
|
||||
@@ -73,7 +73,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
MarginRightOverride = 10,
|
||||
MarginTopOverride = 10,
|
||||
RectClipContent = true,
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
@@ -14,8 +14,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
public Tooltip()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Ignore;
|
||||
|
||||
AddChild(_label = new Label());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Robust.Client.ViewVariables
|
||||
|
||||
public ViewVariablesPropertyControl(IViewVariablesManagerInternal viewVars, IResourceCache resourceCache)
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
|
||||
_viewVariablesManager = viewVars;
|
||||
_resourceCache = resourceCache;
|
||||
|
||||
@@ -34,7 +36,7 @@ namespace Robust.Client.ViewVariables
|
||||
|
||||
private void PerformLayout()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Stop;
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
ToolTip = "Click to expand";
|
||||
CustomMinimumSize = new Vector2(0, 25);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user