Skip to content

Commit

Permalink
Buffer height ratio calculations by title bar height
Browse files Browse the repository at this point in the history
  • Loading branch information
fatheroctopus committed Sep 21, 2018
1 parent e98fff6 commit cac42a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions DeckPredictor/PredictionLayout.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace DeckPredictor
public partial class PredictionLayout
{
private const int CardHeight = 32;
private const double BottomFromScreenRatio = .2;
private const double LeftFromScreenRatio = .005;
private const double FittedMaxHeightRatio = .55;
private const double AbsoluteMaxHeightRatio = .8;
private const double AbsoluteMaxHeightRatio = 1 - BottomFromScreenRatio;
private PluginConfig _config;

public PredictionLayout(PluginConfig config)
Expand Down Expand Up @@ -98,7 +100,9 @@ public void Update(PredictionInfo prediction)
// UI elements.
double maxHeightRatio =
_config.FitDeckListToDisplay ? FittedMaxHeightRatio : AbsoluteMaxHeightRatio;
double maxHeight = maxHeightRatio * Core.OverlayWindow.Height;
double displayHeight =
Core.OverlayWindow.Height - System.Windows.SystemParameters.WindowCaptionHeight;
double maxHeight = maxHeightRatio * displayHeight;
if (cards.Count * CardHeight > maxHeight - InfoBox.ActualHeight)
{
CardView.Height = maxHeight - InfoBox.ActualHeight;
Expand All @@ -109,8 +113,8 @@ public void Update(PredictionInfo prediction)
}

// Reposition on canvas, in case window has been resized.
Canvas.SetBottom(this, Core.OverlayWindow.Height * 20 / 100);
Canvas.SetLeft(this, Core.OverlayWindow.Width * .5 / 100);
Canvas.SetBottom(this, Core.OverlayWindow.Height * BottomFromScreenRatio);
Canvas.SetLeft(this, Core.OverlayWindow.Width * LeftFromScreenRatio);
}

public class PercentageItem
Expand Down

0 comments on commit cac42a3

Please sign in to comment.