-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dynamically change mini-window window controls alignment based on window position #125
Dynamically change mini-window window controls alignment based on window position #125
Conversation
WalkthroughThis update assigns a Name ("WindowControls") to the StackPanel in CompactWindow.axaml for easier reference. Additionally, CompactWindow.axaml.cs now imports System.Linq and Avalonia.Layout and enhances the OnPositionChanged method. This method computes an aggregated bounding rectangle based on all screens and adjusts the HorizontalAlignment of WindowControls based on whether the window is partially off-screen. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Window as CompactWindow
participant Method as OnPositionChanged
participant Display as ScreenManager
participant Controls as WindowControls
User->>Window: Moves window
Window->>Method: Trigger OnPositionChanged
Method->>Display: Aggregate working areas
Display-->>Method: Return bounding rectangle
Method->>Window: Check window boundaries
alt Window partially off-screen
Method->>Controls: Update HorizontalAlignment (Left/Right)
else Window fully visible
Method-->>Controls: No alignment change
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs (2)
73-97
: Add null check for WindowControls.The implementation looks good! However, consider adding a null check before accessing WindowControls to prevent potential NullReferenceException.
- if (isRightOffScreen) + if (WindowControls != null) { - WindowControls.HorizontalAlignment = HorizontalAlignment.Left; - } - else if (isRightFullyVisible) - { - WindowControls.HorizontalAlignment = HorizontalAlignment.Right; + if (isRightOffScreen) + { + WindowControls.HorizontalAlignment = HorizontalAlignment.Left; + } + else if (isRightFullyVisible) + { + WindowControls.HorizontalAlignment = HorizontalAlignment.Right; + } }
74-81
: Consider extracting screen bounds calculation.The screen bounds calculation logic could be moved to a separate method for better maintainability and reusability.
+ private PixelRect GetTotalScreenBounds() + { + return Screens.All + .Select(s => s.WorkingArea) + .Aggregate((acc, next) => acc.Union(next)); + } + private void OnPositionChanged(object? sender, PixelPointEventArgs e) { if (DataContext is CompactWindowViewModel model) { model.UpdatePosition(this); } - // Get the bounding rectangle of all screens combined - var totalScreenBounds = Screens.All - .Select(s => s.WorkingArea) - .Aggregate((acc, next) => acc.Union(next)); + var totalScreenBounds = GetTotalScreenBounds(); var totalLeft = totalScreenBounds.X; var totalRight = totalScreenBounds.X + totalScreenBounds.Width;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
vATIS.Desktop/Ui/Windows/CompactWindow.axaml
(1 hunks)vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- vATIS.Desktop/Ui/Windows/CompactWindow.axaml
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: build (macos-latest)
- GitHub Check: Analyze (cpp)
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Analyze (csharp)
- GitHub Check: Analyze (cpp)
- GitHub Check: Analyze (csharp)
🔇 Additional comments (1)
vATIS.Desktop/Ui/Windows/CompactWindow.axaml.cs (1)
7-7
: LGTM! Required imports added for new functionality.The new imports support LINQ operations for screen bounds calculation and HorizontalAlignment for window controls positioning.
Also applies to: 12-12
Summary by CodeRabbit