Skip to content

Commit

Permalink
Fixed oscillation cause by strange ITextServices values returned.
Browse files Browse the repository at this point in the history
  • Loading branch information
AelyoSoftWorks committed Oct 29, 2023
1 parent 1e39a2b commit 6bb2cbd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Wice/ScrollViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ private void OnViewerArranged(object sender, EventArgs e)

if (viewerSize.IsZero)
{
IsVerticalScrollBarVisible = false;
IsHorizontalScrollBarVisible = false;
// this causes oscillation
//IsVerticalScrollBarVisible = false;
//IsHorizontalScrollBarVisible = false;
return;
}

Expand Down
8 changes: 6 additions & 2 deletions Wice/ScrollbarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Wice
{
public class ScrollBarButton : ButtonBase
{
private GeometrySource2D _lastGeometrySource2D;

public static VisualProperty IsArrowOpenProperty = VisualProperty.Add(typeof(Visual), nameof(IsArrowOpen), VisualPropertyInvalidateModes.Render, true);
public static VisualProperty ArrowRatioProperty = VisualProperty.Add(typeof(Visual), nameof(ArrowRatio), VisualPropertyInvalidateModes.Render, float.NaN);

Expand Down Expand Up @@ -36,13 +38,15 @@ public ScrollBarButton(DockType type)
protected override void OnArranged(object sender, EventArgs e)
{
base.OnArranged(sender, e);

var size = (Child.ArrangedRect - Child.Margin).Size;

var open = IsArrowOpen;
var type = Dock.GetDockType(this);
var geoSource = Application.Current.ResourceManager.GetScrollBarButtonGeometrySource(type, size.width, ArrowRatio, open);
if (geoSource.Equals(_lastGeometrySource2D))
return;

Child.GeometrySource2D = geoSource.GetIGeometrySource2();
_lastGeometrySource2D = geoSource;
}

protected override void OnAttachedToComposition(object sender, EventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions Wice/TitleBarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Wice
public class TitleBarButton : ButtonBase
{
private TitleBarButtonType _buttonType;
private GeometrySource2D _lastGeometrySource2D;

public TitleBarButton()
{
Expand Down Expand Up @@ -50,7 +51,11 @@ protected override void OnArranged(object sender, EventArgs e)
var size = (Path.ArrangedRect - Path.Margin).Size;
var geoSize = size.height;
var geoSource = Application.Current.ResourceManager.GetTitleBarButtonGeometrySource(ButtonType, geoSize);
if (geoSource.Equals(_lastGeometrySource2D))
return;

Path.GeometrySource2D = geoSource.GetIGeometrySource2();
_lastGeometrySource2D = geoSource;
}

protected override void OnAttachedToComposition(object sender, EventArgs e)
Expand Down

0 comments on commit 6bb2cbd

Please sign in to comment.