This repository was archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move popup placing logic outside (win)
- Loading branch information
1 parent
7b3d541
commit 2e054cc
Showing
5 changed files
with
42 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/ui/windows/TogglDesktop/TogglDesktop/ui/Behaviors/TimelineTimeEntryPopupHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using TogglDesktop.ViewModels; | ||
|
||
namespace TogglDesktop.Behaviors | ||
{ | ||
public static class TimelineTimeEntryPopupHelper | ||
{ | ||
public static void OpenPopup(this TimelineTimeEntryBlockPopup popup, FrameworkElement placementTarget, ScrollViewer scroll) | ||
{ | ||
if (placementTarget.DataContext is TimeEntryBlock curBlock) | ||
{ | ||
popup.DataContext = curBlock; | ||
popup.Popup.PlacementTarget = placementTarget; | ||
popup.Popup.IsOpen = true; | ||
var visibleTopOffset = scroll.VerticalOffset + 10; | ||
var visibleBottomOffset = scroll.VerticalOffset + scroll.ActualHeight - 10; | ||
var offset = curBlock.VerticalOffset + placementTarget.ActualHeight / 2; | ||
popup.Popup.VerticalOffset = Math.Min(Math.Max(visibleTopOffset, offset), visibleBottomOffset) - | ||
curBlock.VerticalOffset; | ||
} | ||
} | ||
|
||
public static void ClosePopup(this TimelineTimeEntryBlockPopup popup) | ||
{ | ||
popup.Popup.IsOpen = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters