Skip to content

209 improve closing panels #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Pixed.Android/PlatformSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Pixed.Application.Platform;
namespace Pixed.Android;
Expand All @@ -22,4 +23,14 @@ public string GetVersion()
PackageInfo info = MainActivity.PackageManager.GetPackageInfo(MainActivity.PackageName, 0);
return info.VersionName;
}

public void ProcessMinimumScreenSize(int minScreenSize)
{
var metrics = MainActivity.WindowManager.CurrentWindowMetrics;
var width = metrics.Bounds.Width() / metrics.Density;
if (width <= minScreenSize)
{
MainActivity.RequestedOrientation = ScreenOrientation.Landscape;
}
}
}
1 change: 1 addition & 0 deletions Pixed.Application/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ResourceInclude Source="/Themes/LayersListBoxItem.axaml"/>
<ResourceInclude Source="/Themes/MainPage.axaml"/>
<ResourceInclude Source="/Themes/NoGesturesScrollViewer.axaml"/>
<ResourceInclude Source="/Themes/ShellView.axaml"/>
<ResourceInclude Source="/Themes/TabStripItem.axaml"/>
<ResourceInclude Source="/Themes/ToolButton.axaml"/>
<ResourceInclude Source="/Themes/ToolRadio.axaml"/>
Expand Down
2 changes: 2 additions & 0 deletions Pixed.Application/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public async override void OnFrameworkInitializationCompleted()
InitializeServices();
singleViewPlatform.MainView = new MainView();
}

IPlatformSettings.Instance.ProcessMinimumScreenSize(500);
base.OnFrameworkInitializationCompleted();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="124"/>
Expand Down Expand Up @@ -58,11 +57,5 @@
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
<controls:TouchButton Command="{Binding CloseViewCommand}" Theme="{StaticResource BaseButton}" Grid.Row="2" IsVisible="True" Height="32">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_arrow_exit_20_regular.svg}" Width="16" Height="16"/>
<ToolTip.Tip>
<controls:TextTooltip Text="Close view"/>
</ToolTip.Tip>
</controls:TouchButton>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,11 @@
x:DataType="vm:PropertiesSectionViewModel"
Width="242"
IsVisible="{Binding IsVisible}">
<Grid Width="242">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollViewer Width="242" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Theme="{StaticResource HandledFixScrollViewer}">
<StackPanel Name="rightPanel" Width="242" HorizontalAlignment="Stretch">
<mainsections:AnimationSection/>
<mainsections:PaletteSection/>
<mainsections:LayersSection/>
</StackPanel>
</ScrollViewer>
<controls:TouchButton Command="{Binding CloseViewCommand}" Theme="{StaticResource BaseButton}" Grid.Row="1" IsVisible="True" Height="32">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_arrow_exit_20_regular.svg}" Width="16" Height="16"/>
<ToolTip.Tip>
<controls:TextTooltip Text="Close view"/>
</ToolTip.Tip>
</controls:TouchButton>
</Grid>
<ScrollViewer Width="242" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Theme="{StaticResource HandledFixScrollViewer}">
<StackPanel Name="rightPanel" Width="242" HorizontalAlignment="Stretch">
<mainsections:AnimationSection/>
<mainsections:PaletteSection/>
<mainsections:LayersSection/>
</StackPanel>
</ScrollViewer>
</UserControl>
10 changes: 8 additions & 2 deletions Pixed.Application/Controls/PaintCanvas.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@
</Border>
</Border>
</ScrollViewer>
<Button Width="32" Height="64" HorizontalAlignment="Left" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding IsFramesViewButtonVisible}" Command="{Binding OpenFramesView}">
<Button Width="32" Height="64" HorizontalAlignment="Left" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding !IsFramesViewButtonVisible}" Command="{Binding OpenFramesView}">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_panel_left_expand_28_regular.svg}" Width="16" Height="16"/>
</Button>
<Button Width="32" Height="64" HorizontalAlignment="Right" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding IsPropertiesViewButtonVisible}" Command="{Binding OpenPropertiesView}">
<Button Width="32" Height="64" HorizontalAlignment="Left" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding IsFramesViewButtonVisible}" Command="{Binding CloseFramesView}">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_panel_left_contract_28_regular.svg}" Width="16" Height="16"/>
</Button>
<Button Width="32" Height="64" HorizontalAlignment="Right" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding !IsPropertiesViewButtonVisible}" Command="{Binding OpenPropertiesView}">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_panel_right_expand_20_regular.svg}" Width="16" Height="16"/>
</Button>
<Button Width="32" Height="64" HorizontalAlignment="Right" VerticalAlignment="Center" Theme="{StaticResource FlyingButton}" IsVisible="{Binding IsPropertiesViewButtonVisible}" Command="{Binding ClosePropertiesView}">
<Image Source="{SvgImage avares://Pixed.Application/Resources/fluent-icons/ic_fluent_panel_right_contract_24_regular.svg}" Width="16" Height="16"/>
</Button>
<StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="5" Margin="4">
<TextBlock Text="Tool size" VerticalAlignment="Center"/>
<NumericUpDown Minimum="1" Maximum="20" Value="{Binding ToolSize, Mode=TwoWay}" Width="105" FormatString="0" Increment="1"/>
Expand Down
5 changes: 5 additions & 0 deletions Pixed.Application/Platform/DefaultPlatformSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ public string GetVersion()
var versionInfo = FileVersionInfo.GetVersionInfo(assemblyName);
return versionInfo.FileVersion;
}

public void ProcessMinimumScreenSize(int minScreenSize)
{
//Not used
}
}
1 change: 1 addition & 0 deletions Pixed.Application/Platform/IPlatformSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface IPlatformSettings
public bool ExtensionsOnSave { get; }
public void Close();
public string GetVersion();
public void ProcessMinimumScreenSize(int minScreenSize);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions Pixed.Application/Themes/ShellView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTheme x:Key="{x:Type ShellView}" TargetType="ShellView">
<Setter Property="Background" Value="{DynamicResource AppBackground}" />
<Setter Property="Template">
<ControlTemplate>
<Panel Background="{TemplateBinding Background}">
<SplitView Name="PART_SplitView" DisplayMode="Inline" CompactPaneLength="0">
<SplitView.Pane>
<SideMenu Name="PART_SideMenu"
SelectedItem="{TemplateBinding SideMenuSelectedItem, Mode=TwoWay}"
Header="{TemplateBinding SideMenuHeader}"
Footer="{TemplateBinding SideMenuFooter}"
Contents="{TemplateBinding SideMenuContents}"
ContentsTemplate="{TemplateBinding SideMenuContentsTemplate}">
</SideMenu>
</SplitView.Pane>

<Grid RowDefinitions="Auto,*,Auto">
<ContentPresenter Name="PART_NavigationBarPlaceHolder"></ContentPresenter>
<StackContentView Name="PART_ContentView"
Grid.Row="1"
PageTransition="{TemplateBinding DefaultPageTransition}">
</StackContentView>
</Grid>
</SplitView>

<Rectangle IsVisible="{Binding ElementName=PART_Modal, Path=HasContent}"
Opacity="0.5">
<Rectangle.Fill>
<VisualBrush
TileMode="Tile"
SourceRect="0,0,8,8"
DestinationRect="0,0,8,8"
Stretch="UniformToFill">
<VisualBrush.Visual>
<Canvas Width="8" Height="8">
<Rectangle Fill="Black" Width="8" Height="8"></Rectangle>
<Line StartPoint="0,0" EndPoint="8,8" Stroke="#55555555" StrokeThickness="1" />
<Line StartPoint="0,8" EndPoint="8,0" Stroke="#55555555" StrokeThickness="1" />
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>

<StackContentView Name="PART_Modal"
IsVisible="{Binding ElementName=PART_Modal, Path=HasContent}"
PageTransition="{TemplateBinding ModalPageTransition}">
</StackContentView>
</Panel>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>
7 changes: 0 additions & 7 deletions Pixed.Application/ViewModels/FramesSectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public bool IsVisible
public ICommand NewFrameCommand { get; }
public ICommand RemoveFrameCommand { get; }
public ICommand DuplicateFrameCommand { get; }
public ICommand CloseViewCommand { get; }
public Subject<bool> IsVisibleChanged { get; } = new Subject<bool>();

public FramesSectionViewModel(ApplicationData applicationData, IMenuItemRegistry menuItemRegistry, IPlatformFolder platformFolder)
Expand All @@ -84,7 +83,6 @@ public FramesSectionViewModel(ApplicationData applicationData, IMenuItemRegistry
NewFrameCommand = new ActionCommand(NewFrameAction);
RemoveFrameCommand = new ActionCommand(RemoveFrameAction);
DuplicateFrameCommand = new ActionCommand(DuplicateFrameAction);
CloseViewCommand = new ActionCommand(CloseView);
_projectChanged = Subjects.ProjectChanged.Subscribe(p =>
{
OnPropertyChanged(nameof(Frames));
Expand Down Expand Up @@ -164,9 +162,4 @@ private void DuplicateFrameAction()
SelectedFrame = Frames.Count - 1;
_applicationData.CurrentModel.AddHistory();
}

private void CloseView()
{
IsVisible = false;
}
}
12 changes: 8 additions & 4 deletions Pixed.Application/ViewModels/PaintCanvasViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ internal class PaintCanvasViewModel : ExtendedViewModel, IDisposable
public ActionCommand<double> MouseWheel { get; }
public ActionCommand MouseLeave { get; }
public ActionCommand OpenFramesView { get; }
public ActionCommand CloseFramesView { get; }
public ActionCommand OpenPropertiesView { get; }
public ActionCommand ClosePropertiesView { get; }

public int ToolSize
{
Expand Down Expand Up @@ -345,14 +347,16 @@ public PaintCanvasViewModel(ApplicationData applicationData, ToolsManager toolSe
GestureZoomEnabled = isEnabled;
};

IsFramesViewButtonVisible = !_applicationData.UserSettings.FramesViewVisible;
IsPropertiesViewButtonVisible = !_applicationData.UserSettings.PropertiesViewVisible;
IsFramesViewButtonVisible = _applicationData.UserSettings.FramesViewVisible;
IsPropertiesViewButtonVisible = _applicationData.UserSettings.PropertiesViewVisible;

_framesViewVisibleChanged = framesSectionViewModel.IsVisibleChanged.Subscribe(v => IsFramesViewButtonVisible = !v);
_propertiesViewVisibleChanged = propertiesSectionViewModel.IsVisibleChanged.Subscribe(v => IsPropertiesViewButtonVisible = !v);
_framesViewVisibleChanged = framesSectionViewModel.IsVisibleChanged.Subscribe(v => IsFramesViewButtonVisible = v);
_propertiesViewVisibleChanged = propertiesSectionViewModel.IsVisibleChanged.Subscribe(v => IsPropertiesViewButtonVisible = v);

OpenFramesView = new ActionCommand(() => framesSectionViewModel.IsVisible = true);
CloseFramesView = new ActionCommand(() => framesSectionViewModel.IsVisible = false);
OpenPropertiesView = new ActionCommand(() => propertiesSectionViewModel.IsVisible = true);
ClosePropertiesView = new ActionCommand(() => propertiesSectionViewModel.IsVisible = false);
}
public void RecalculateFactor(Point windowSize)
{
Expand Down
10 changes: 1 addition & 9 deletions Pixed.Application/ViewModels/PropertiesSectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,11 @@ public bool IsVisible

public Subject<bool> IsVisibleChanged { get; } = new Subject<bool>();

public ICommand CloseViewCommand { get; }

public PropertiesSectionViewModel(ApplicationData applicationData, IPlatformFolder platformFolder, IMenuItemRegistry menuItemRegistry)
public PropertiesSectionViewModel(ApplicationData applicationData, IPlatformFolder platformFolder)
{
_applicationData = applicationData;
_platformFolder = platformFolder;
CloseViewCommand = new ActionCommand(CloseView);
_isVisible = _applicationData.UserSettings.PropertiesViewVisible;
OnPropertyChanged(nameof(IsVisible));
}

private void CloseView()
{
IsVisible = false;
}
}
Loading