Skip to content

Commit

Permalink
min tab dimensions (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicdotexe authored Nov 21, 2024
1 parent ff44e95 commit e327d97
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
21 changes: 17 additions & 4 deletions FRBDK/Glue/Glue/Controls/MainPanelControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:plugins="clr-namespace:FlatRedBall.Glue.Plugins"
xmlns:controls1="clr-namespace:GlueFormsCore.Controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:converters="clr-namespace:FlatRedBall.Glue.Themes.Converters"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
PreviewKeyDown="UserControl_PreviewKeyDown"
Expand All @@ -28,16 +29,24 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Grid.Resources>
<converters:MinPanelConverter x:Key="MinPanelConverter"/>
</Grid.Resources>
<controls:ToolbarControl VerticalContentAlignment="Center" x:Name="ToolbarControl" Grid.Row="0"/>

<Grid Grid.Row="1" Margin="3">
<Grid.RowDefinitions>

<RowDefinition Height="{Binding TopPanelHeight, Mode=TwoWay}" />
<RowDefinition
Height="{Binding TopPanelHeight, Mode=TwoWay}"
MinHeight="{Binding TopTabItems.Count, Converter={StaticResource MinPanelConverter}}"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="{Binding BottomPanelHeight, Mode=TwoWay}" />
<RowDefinition
Height="{Binding BottomPanelHeight, Mode=TwoWay}"
MinHeight="{Binding BottomTabItems.Count, Converter={StaticResource MinPanelConverter}}"/>
</Grid.RowDefinitions>

<TabControl x:Name="TopTabControl"
Expand All @@ -58,11 +67,15 @@

<Grid Grid.Row="2" x:Name="CenterGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding LeftPanelWidth, Mode=TwoWay}" />
<ColumnDefinition
Width="{Binding LeftPanelWidth, Mode=TwoWay}"
MinWidth="{Binding LeftTabItems.Count, Converter={StaticResource MinPanelConverter}}" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="{Binding RightPanelWidth, Mode=TwoWay}" />
<ColumnDefinition
Width="{Binding RightPanelWidth, Mode=TwoWay}"
MinWidth="{Binding RightTabItems.Count, Converter={StaticResource MinPanelConverter}}"/>
</Grid.ColumnDefinitions>

<TabControl x:Name="LeftTabControl"
Expand Down
29 changes: 29 additions & 0 deletions FRBDK/Glue/Glue/Themes/Converters/MinPanelConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using FlatRedBall.Glue.Plugins;
using System.Globalization;
using System.Windows.Data;
using System.Windows;
using System;
using GlueFormsCore.Controls;
using GlueFormsCore.ViewModels;

namespace FlatRedBall.Glue.Themes.Converters;

/// <summary>
/// Used to determine the minimum length of a "panel" (grid section) in the main display
/// based on if it currently contains any tabs items.
/// </summary>
public class MinPanelConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not int count)
throw new InvalidOperationException();

return count > 0 ? 32 : 0; // Allow 0 (collapsed) for no tab items
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException("ConvertBack is not supported.");
}
}

0 comments on commit e327d97

Please sign in to comment.