Skip to content

Commit

Permalink
Merge pull request #1539 from Nexus-Mods/spine_left_men_styles
Browse files Browse the repository at this point in the history
Spine Loadout ImageButtons Styling and Tooltip fix
  • Loading branch information
Al12rs authored Jun 5, 2024
2 parents acfdaef + 87d7349 commit 750e850
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 98 deletions.
15 changes: 10 additions & 5 deletions docs/development-guidelines/UIStylingGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ Each setter element identifies the property that will be changed by name, and th

!!! example

```xml
<Style Selector="selector syntax">
<Setter Property="property name" Value="new value"/>
```xml
<Style Selector="selector syntax">
<Setter Property="property name" Value="new value"/>
...
</Style>
```
</Style>
```

The Avalonia UI style selector syntax is analogous to that used by CSS (cascading style sheets).

!!! warning "If selectors are not made specific enough, ToolTips and Context menu contents will also be affected"

Selectors should either use the `x:Name`, a Class or the hierarchical path of the control to be styled,
to avoid affecting other controls of the same type.

### Example

This is an example of how a style is written and applied to a `Control` element, with a style class to help selection:
Expand Down
22 changes: 11 additions & 11 deletions src/NexusMods.App.UI/Controls/Spine/Buttons/Icon/IconButton.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
xmlns:reactiveUi="http://reactiveui.net"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:icons="clr-namespace:NexusMods.Icons;assembly=NexusMods.Icons">

<Design.DataContext>
<icon:IconButtonDesignViewModel />
</Design.DataContext>
Expand All @@ -26,17 +27,16 @@
<Button.Template>
<ControlTemplate>
<Grid>
<icons:UnifiedIcon
Classes="HelpCircle"
Size="20"
HorizontalAlignment="Center"
Margin="0"
Padding="0"
VerticalAlignment="Center" />
<Border
Classes="Rounded-full"
Height="50"
Width="50" />
<icons:UnifiedIcon Classes="HelpCircle"
Size="20"
HorizontalAlignment="Center"
Margin="0"
Padding="0"
VerticalAlignment="Center" />
<Border x:Name="IconButtonInnerBorder"
Classes="Rounded-full"
Height="50"
Width="50" />
</Grid>
</ControlTemplate>
</Button.Template>
Expand Down
35 changes: 13 additions & 22 deletions src/NexusMods.App.UI/Controls/Spine/Buttons/Image/ImageButton.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<reactiveUi:ReactiveUserControl
d:DesignHeight="90"
d:DesignWidth="90"
d:DesignHeight="150"
d:DesignWidth="150"
mc:Ignorable="d"
x:Class="NexusMods.App.UI.Controls.Spine.Buttons.Image.ImageButton"
x:TypeArguments="buttons:IImageButtonViewModel"
Expand All @@ -15,27 +15,18 @@
<buttons:ImageButtonDesignViewModel />
</Design.DataContext>

<Button
Classes="Spine Image"
Height="64"
Width="64"
x:Name="Button">
<Button Classes="ImageButton"
x:Name="Button"
HorizontalAlignment="Stretch">
<ToolTip.Tip>
<TextBlock x:Name="ToolTipTextBlock"/>
<TextBlock x:Name="ToolTipTextBlock" />
</ToolTip.Tip>

<Grid>
<icons:UnifiedIcon
Size="50"
x:Name="Image">
<icons:UnifiedIcon.Clip>
<EllipseGeometry Rect="0, 0, 50, 50" />
</icons:UnifiedIcon.Clip>
</icons:UnifiedIcon>
<Border
Height="50"
Width="50" />
</Grid>

<Border x:Name="ClippingBorder">
<Grid x:Name="InnerGrid">
<icons:UnifiedIcon x:Name="Image" />
<Rectangle x:Name="Mask" />
<Border x:Name="DecorationBorder" />
</Grid>
</Border>
</Button>
</reactiveUi:ReactiveUserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
<!-- NeutralTranslucent -->

<!-- Colors -->
<StaticResource x:Key="SurfaceTranslucentLow" ResourceKey="BrandTranslucentLight100" />
<StaticResource x:Key="SurfaceTranslucentLow" ResourceKey="BrandTranslucentLight50" />
<StaticResource x:Key="SurfaceTranslucentMid" ResourceKey="BrandTranslucentLight100" />
<StaticResource x:Key="SurfaceTranslucentHigh" ResourceKey="BrandTranslucentLight200" />

<!-- SolidColorBrushes -->
<SolidColorBrush x:Key="SurfaceTranslucentLowBrush" Color="{StaticResource SurfaceTranslucentLow}" />
<SolidColorBrush x:Key="SurfaceTranslucentMidBrush" Color="{StaticResource SurfaceTranslucentMid}" />
<SolidColorBrush x:Key="SurfaceTranslucentHighBrush" Color="{StaticResource SurfaceTranslucentHigh}" />

<!-- TransparentBrush -->
<!-- NOTE: Avalonia treats Transparent color as click through, so it can't be used correctly as a background color. -->
Expand Down
Loading

0 comments on commit 750e850

Please sign in to comment.