Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat(bar): move out component grid from `ComponentContainer`; rename `ComponentContainer` -> `ComponentPortal`

Lars Berger7bee68087d33
diff --git a/GlazeWM.Bar/Components/ComponentContainer.xaml b/GlazeWM.Bar/Components/ComponentContainer.xaml
deleted file mode 100644
index a27d79d2..00000000
--- a/GlazeWM.Bar/Components/ComponentContainer.xaml
+++ /dev/null
@@ -1,31 +0,0 @@
-<UserControl
- x:Class="GlazeWM.Bar.Components.ComponentContainer"
- x:Name="Self"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:GlazeWM.Bar.Components"
- xmlns:components="clr-namespace:GlazeWM.Bar.Components"
- xmlns:domain="clr-namespace:GlazeWM.Domain.UserConfigs;assembly=GlazeWM.Domain"
- mc:Ignorable="d">
- <ItemsControl ItemsSource="{Binding ComponentConfigs, ElementName=Self}">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <UniformGrid
- Rows="1"
- HorizontalAlignment="Left"
- IsItemsHost="True" />
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
-
- <ItemsControl.Resources>
- <DataTemplate DataType="{x:Type domain:WorkspacesComponentConfig}">
- <components:WorkspacesComponent />
- </DataTemplate>
- <DataTemplate DataType="{x:Type domain:ClockComponentConfig}">
- <components:ClockComponent />
- </DataTemplate>
- </ItemsControl.Resources>
- </ItemsControl>
-</UserControl>
diff --git a/GlazeWM.Bar/Components/ComponentContainer.xaml.cs b/GlazeWM.Bar/Components/ComponentContainer.xaml.cs
deleted file mode 100644
index 5cd18bb3..00000000
--- a/GlazeWM.Bar/Components/ComponentContainer.xaml.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using GlazeWM.Domain.UserConfigs;
-
-namespace GlazeWM.Bar.Components
-{
- /// <summary>
- /// Interaction logic for ComponentContainer.xaml
- /// </summary>
- public partial class ComponentContainer : UserControl
- {
-
- public static readonly DependencyProperty ComponentConfigsProperty =
- DependencyProperty.Register("ComponentConfigs", typeof(List<BarComponentConfig>), typeof(ComponentContainer), new FrameworkPropertyMetadata(new List<BarComponentConfig>()));
-
- public List<BarComponentConfig> ComponentConfigs
- {
- get { return (List<BarComponentConfig>)GetValue(ComponentConfigsProperty); }
- set { SetValue(ComponentConfigsProperty, value); }
- }
-
- public ComponentContainer()
- {
- InitializeComponent();
- }
- }
-}
-
diff --git a/GlazeWM.Bar/Components/ComponentPortal.xaml b/GlazeWM.Bar/Components/ComponentPortal.xaml
new file mode 100644
index 00000000..3d81ccd6
--- /dev/null
+++ b/GlazeWM.Bar/Components/ComponentPortal.xaml
@@ -0,0 +1,21 @@
+<UserControl
+ x:Class="GlazeWM.Bar.Components.ComponentPortal"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
+ mc:Ignorable="d">
+ <!-- <StackPanel>
+ <StackPanel.Resources> -->
+ <UserControl.Resources>
+ <DataTemplate DataType="{x:Type components:WorkspacesComponentViewModel}">
+ <components:WorkspacesComponent />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type components:ClockComponentViewModel}">
+ <components:ClockComponent />
+ </DataTemplate>
+ </UserControl.Resources>
+ <!-- </StackPanel.Resources>
+ </StackPanel> -->
+</UserControl>
diff --git a/GlazeWM.Bar/Components/ComponentPortal.xaml.cs b/GlazeWM.Bar/Components/ComponentPortal.xaml.cs
new file mode 100644
index 00000000..b629f48b
--- /dev/null
+++ b/GlazeWM.Bar/Components/ComponentPortal.xaml.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using GlazeWM.Domain.UserConfigs;
+
+namespace GlazeWM.Bar.Components
+{
+ /// <summary>
+ /// Interaction logic for ComponentPortal.xaml
+ /// </summary>
+ public partial class ComponentPortal : UserControl
+ {
+ public ComponentPortal()
+ {
+ InitializeComponent();
+ }
+ }
+}
+
diff --git a/GlazeWM.Bar/MainWindow.xaml b/GlazeWM.Bar/MainWindow.xaml
index c3168866..7b8796ec 100644
--- a/GlazeWM.Bar/MainWindow.xaml
+++ b/GlazeWM.Bar/MainWindow.xaml
@@ -9,11 +9,11 @@
mc:Ignorable="d"
WindowStyle="None"
ResizeMode="NoResize"
- Background="{Binding Background}"
Title="GlazeWMBar"
ShowInTaskbar="False"
Width="800"
Height="50"
+ Background="{Binding Background}"
FontFamily="{Binding FontFamily}"
FontSize="{Binding FontSize}"
Opacity="{Binding Opacity}"
@@ -29,18 +29,63 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
- <components:ComponentContainer
+ <ItemsControl
Grid.Column="0"
- ComponentConfigs="{Binding ComponentsLeft}" />
+ ItemsSource="{Binding ComponentsLeft}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <UniformGrid
+ Rows="1"
+ HorizontalAlignment="Left"
+ IsItemsHost="True" />
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <components:ComponentPortal />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
- <components:ComponentContainer
+ <ItemsControl
Grid.Column="1"
- ComponentConfigs="{Binding ComponentsCenter}" />
+ ItemsSource="{Binding ComponentsCenter}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <UniformGrid
+ Rows="1"
+ HorizontalAlignment="Left"
+ IsItemsHost="True" />
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
- <components:ComponentContainer
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <components:ComponentPortal />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+
+ <ItemsControl
Grid.Column="2"
HorizontalAlignment="Right"
- ComponentConfigs="{Binding ComponentsRight}" />
+ ItemsSource="{Binding ComponentsRight}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <UniformGrid
+ Rows="1"
+ HorizontalAlignment="Left"
+ IsItemsHost="True" />
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <components:ComponentPortal />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
</Grid>
</Border>
</Window>