InstrumentMenu: Channels panel expands with the window (#46033)

* Vertically expanding channels, -pointless Controls

* scamboni

* XAML control for the base midi CFG item
This commit is contained in:
Whatstone 2026-09-18 04:54:08 +00:00 • committed by GitHub
parent 1e1f7748fe
commit 2d25896763
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 85 additions and 78 deletions

View file

@ -1,27 +1,27 @@
<Control xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Orientation="Vertical">
<ScrollContainer MinHeight="90">
<BoxContainer Orientation="Vertical" Name="ChannelsContainer" SeparationOverride="3" />
</ScrollContainer>
<controls:HSpacer Spacing="10" />
<GridContainer Columns="5" HSeparationOverride="1" VSeparationOverride="1">
<!-- Name display selector -->
<Label Text="{Loc 'instruments-component-channels-name-display-selector-label'}" />
<controls:VSpacer Spacing="10" />
<Button Name="TrackSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-track-button'}"
HorizontalExpand="true"
StyleClasses="OpenBoth" />
<Button Name="ProgramSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-program-button'}"
Pressed="True"
HorizontalExpand="true"
StyleClasses="OpenBoth" />
<Button Name="InstrumentSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-instrument-button'}"
HorizontalExpand="true"
StyleClasses="OpenBoth" />
</GridContainer>
</BoxContainer>
</Control>
<BoxContainer xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Orientation="Vertical"
VerticalExpand="True">
<ScrollContainer MinHeight="90" VerticalExpand="True">
<BoxContainer Orientation="Vertical" Name="ChannelsContainer" SeparationOverride="3" VerticalExpand="True"/>
</ScrollContainer>
<controls:HSpacer Spacing="10" />
<GridContainer Columns="5" HSeparationOverride="1" VSeparationOverride="1">
<!-- Name display selector -->
<Label Text="{Loc 'instruments-component-channels-name-display-selector-label'}" />
<controls:VSpacer Spacing="10" />
<Button Name="TrackSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-track-button'}"
HorizontalExpand="True"
StyleClasses="OpenBoth" />
<Button Name="ProgramSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-program-button'}"
Pressed="True"
HorizontalExpand="True"
StyleClasses="OpenBoth" />
<Button Name="InstrumentSelectorButton"
Text="{Loc 'instruments-component-channels-name-display-selector-instrument-button'}"
HorizontalExpand="True"
StyleClasses="OpenBoth" />
</GridContainer>
</BoxContainer>

View file

@ -1,5 +1,4 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Audio.Midi;
@ -7,7 +6,7 @@ using Robust.Shared.Audio.Midi;
namespace Content.Client.Instruments.UI;
[GenerateTypedNameReferences]
public sealed partial class ChannelsControl : Control
public sealed partial class ChannelsControl : BoxContainer
{
/// <summary>
/// Raised when a channel is toggled.

View file

@ -85,9 +85,12 @@ public sealed partial class InstrumentBoundUserInterface : BoundUserInterface
// Initialize controls used to configure various system parameters.
// Append any additional configuration controls here.
_instrumentMenu.AddConfigurationControl(
var channels = _instrumentMenu.AddConfigurationControl(
_loc.GetString("instruments-component-menu-channels-label"),
_channelsControl);
channels.Panel.VerticalExpand = true;
channels.VerticalExpand = true;
_instrumentMenu.AddConfigurationControl(
_loc.GetString("instruments-component-midi-file-collection-label"),
_midiCollectionUtilsControl);

View file

@ -1,7 +1,7 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
MinSize="480 270"
MinSize="480 440"
SetSize="500 500">
<BoxContainer Orientation="Vertical" Margin="1,0,0,5" SeparationOverride="10">
<TabContainer Name="MainTabContainer" VerticalExpand="True">

View file

@ -78,37 +78,22 @@ public sealed partial class InstrumentMenu : FancyWindow
/// </summary>
/// <param name="name">The string to display on the tab header for this configuration.</param>
/// <param name="ctrl">The control used for this configuration.</param>
public void AddConfigurationControl(string name, Control ctrl)
/// <returns>The new control.</param>
public MidiConfigurationControl AddConfigurationControl(string name, Control ctrl)
{
var formatted = new FormattedMessage();
var styleBox = new StyleBoxFlat
{
BorderColor = Color.FromHex("#3D4059"),
BorderThickness = new Thickness(2),
};
var panel = new PanelContainer
{
PanelOverride = styleBox,
Margin = new Thickness(0, 0, 0, 10),
};
var header = new RichTextLabel
{
StyleClasses = { StyleClass.LabelKeyText },
Margin = new Thickness(10, 0, 0, 0),
};
var cfgCtrl = new MidiConfigurationControl();
ctrl.VerticalExpand = true;
ctrl.Margin = new Thickness(5);
formatted.AddMarkupOrThrow($"[bold]{name}[/bold]");
header.SetMessage(formatted, Color.FromHex("#A88B5E"));
cfgCtrl.Header.SetMessage(formatted, Color.FromHex("#A88B5E"));
panel.AddChild(ctrl);
cfgCtrl.Panel.AddChild(ctrl);
ConfigurationItemsContainer.AddChild(header);
ConfigurationItemsContainer.AddChild(panel);
ConfigurationItemsContainer.AddChild(cfgCtrl);
return cfgCtrl;
}
/// <summary>

View file

@ -1,17 +1,16 @@
<Control xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Orientation="Vertical">
<Label Name="MidiCountLabel" />
<BoxContainer Orientation="Horizontal">
<Button Name="OpenDirectoryButton"
Text="{Loc 'instruments-component-midi-file-collection-open-dir-button'}" HorizontalExpand="true"
VerticalExpand="true" StyleClasses="OpenRight" />
<Button Name="ReloadCollectionButton"
Text="{Loc 'instruments-component-midi-file-collection-reload-button'}" HorizontalExpand="true"
VerticalExpand="true" StyleClasses="OpenBoth" />
<controls:ConfirmButton Name="DeleteAllButton"
Text="{Loc 'instruments-component-midi-file-collection-delete-all-button'}"
HorizontalExpand="true" VerticalExpand="true" StyleClasses="OpenLeft" />
</BoxContainer>
<BoxContainer xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Orientation="Vertical">
<Label Name="MidiCountLabel" />
<BoxContainer Orientation="Horizontal">
<Button Name="OpenDirectoryButton"
Text="{Loc 'instruments-component-midi-file-collection-open-dir-button'}" HorizontalExpand="true"
VerticalExpand="true" StyleClasses="OpenRight" />
<Button Name="ReloadCollectionButton"
Text="{Loc 'instruments-component-midi-file-collection-reload-button'}" HorizontalExpand="true"
VerticalExpand="true" StyleClasses="OpenBoth" />
<controls:ConfirmButton Name="DeleteAllButton"
Text="{Loc 'instruments-component-midi-file-collection-delete-all-button'}"
HorizontalExpand="true" VerticalExpand="true" StyleClasses="OpenLeft" />
</BoxContainer>
</Control>
</BoxContainer>

View file

@ -2,7 +2,6 @@ using System.Linq;
using Content.Client.Audio.Midi;
using Content.Client.Stylesheets;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.ContentPack;
@ -10,7 +9,7 @@ using Robust.Shared.ContentPack;
namespace Content.Client.Instruments.UI;
[GenerateTypedNameReferences]
public sealed partial class MidiCollectionUtilsControl : Control
public sealed partial class MidiCollectionUtilsControl : BoxContainer
{
[Dependency] private MidiFileCollectionManager _midiCollection = default!;
[Dependency] private IResourceManager _resourceManager = default!;

View file

@ -0,0 +1,16 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Orientation="Vertical">
<RichTextLabel Name="Header"
Access="Public"
StyleClasses="LabelKeyText"
Margin="10 0 0 0"/>
<PanelContainer Name="Panel"
Access="Public"
Margin="0 0 0 10">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BorderColor="#3D4059"
BorderThickness="2"/>
</PanelContainer.PanelOverride>
</PanelContainer>
</BoxContainer>

View file

@ -0,0 +1,7 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Instruments.UI;
[GenerateTypedNameReferences]
public sealed partial class MidiConfigurationControl : BoxContainer;

View file

@ -1,6 +1,4 @@
<Control xmlns="https://spacestation14.io">
<BoxContainer Orientation="Horizontal" VerticalExpand="True" Margin="2 2 0 0">
<Slider Name="MidiMinVolumeSlider" HorizontalExpand="True" MinValue="0" MaxValue="127" />
<Label Name="MidiMinVolumeValueLabel" MinWidth="28" Margin="6 0 3 0" Align="Right" />
</BoxContainer>
</Control>
<BoxContainer xmlns="https://spacestation14.io" Orientation="Horizontal" VerticalExpand="True" Margin="2 2 0 0">
<Slider Name="MidiMinVolumeSlider" HorizontalExpand="True" MinValue="0" MaxValue="127" />
<Label Name="MidiMinVolumeValueLabel" MinWidth="28" Margin="6 0 3 0" Align="Right" />
</BoxContainer>

View file

@ -1,12 +1,13 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
namespace Content.Client.Instruments.UI;
[GenerateTypedNameReferences]
public sealed partial class MinVolumeControl : Control
public sealed partial class MinVolumeControl : BoxContainer
{
/// <summary>
/// Raised when the user changes the min volume for MIDI input.