Skip to content
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

Fixes #2489. New ScrollSlider and ScrollBar - Any View can have scrollbars easily #3820

Merged
merged 164 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
478c93d
Create a Scroll class with unit tests and use case.
BDisp May 23, 2024
84c69f0
Remove unnecessary _sliderContainer view.
BDisp May 24, 2024
4cb27fc
Rename to Scroll_ prefix on the Scroll event methods.
BDisp May 24, 2024
46d1749
Tweaks and suggestions
tig May 24, 2024
57d4f0d
More autosize related tweaks
tig May 24, 2024
d6a183c
Merge pull request #180 from tig/BDisp-v2_2489-tig-1
BDisp May 24, 2024
24e4f65
Remove unnecessary ClearOnVisibleFalse property.
BDisp May 24, 2024
de6d276
Remove unneeded comments.
BDisp May 24, 2024
86e0db2
Add mouse wheel.
BDisp May 24, 2024
30be052
Ensure the Position is valid if the slider is at end.
BDisp May 24, 2024
8c617f3
Fixes NumericUpDown resize when number of characters grows.
BDisp May 24, 2024
365f889
Added more tweaks.
BDisp May 24, 2024
d5b98a1
Suggestions and questions
tig May 25, 2024
dc9d384
Merge pull request #181 from tig/BDisp-v2_2489-tig-2
BDisp May 25, 2024
ee47e75
Change Parent to SuperView.
BDisp May 25, 2024
d4e6ae6
Resolving merge conflicts.
BDisp Jun 12, 2024
4e57840
Fix merge errors.
BDisp Jun 12, 2024
057e89c
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Jun 21, 2024
7489d6c
Replace local var with private getter field.
BDisp Jun 22, 2024
1e9e27a
Only raises PositionChanging and PositionChanged if position has chan…
BDisp Jun 22, 2024
becad1d
Add slider highlight effect.
BDisp Jun 22, 2024
5d2120e
Replace private _barSize with local variables barSize and improving p…
BDisp Jun 23, 2024
5c6b39b
Removed unnecessary methods and now unit test pass.
BDisp Jun 23, 2024
d44efe3
Setting entire ColorScheme attributes.
BDisp Jun 24, 2024
5cc3afb
Merge branch 'v2_2489_scroll-scrollbar-new' of github.com:BDisp/Termi…
tig Jun 24, 2024
9ed6cf7
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Jul 11, 2024
f9aa619
Fix merge errors.
BDisp Jul 11, 2024
e5f1476
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
tig Jul 11, 2024
4a68fc0
Resolving merge conflicts.
BDisp Aug 14, 2024
9b4269e
Fix merge errors.
BDisp Aug 14, 2024
91e4abf
Ensures Position set before call AdjustSlider and
BDisp Aug 14, 2024
c20b733
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Aug 14, 2024
b488796
Move Scroll.cs to the Scroll folder.
BDisp Aug 14, 2024
fa6fb11
Add internal ScrollSlider class.
BDisp Aug 14, 2024
4e22706
Using overridden methods instead of events.
BDisp Aug 14, 2024
3317c50
Moving slider code to his class.
BDisp Aug 16, 2024
b025beb
Rename id to scrollSlider to avoid conflict with the Slider view.
BDisp Aug 16, 2024
9b89657
Fix scroll slider when moving mouse outside the host.
BDisp Aug 16, 2024
3386d06
Ensure correct Width/Height when orientation is changed.
BDisp Aug 16, 2024
e59c02a
Rename to AdjustScroll method.
BDisp Aug 19, 2024
ffa08b8
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Aug 19, 2024
7e3a3b2
Fixes #3679. WantContinuousButtonPressed mustn't force calling GrabMo…
BDisp Aug 21, 2024
6add7a1
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Aug 21, 2024
c587cb9
Merge branch 'v2_3679_want-continuous-pressed-fix' into v2_2489_scrol…
BDisp Aug 21, 2024
8188822
Ensures slider to have a length proportional to the bar size.
BDisp Aug 21, 2024
92e067e
Prevents continuous mouse button pressed from processing mouse event …
BDisp Aug 21, 2024
5e7bb7b
Starting implementing ScrollBar.
BDisp Aug 23, 2024
479ff3d
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Aug 23, 2024
ecc44fc
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Aug 23, 2024
14ed92e
Restore color scheme on mouse leave no matter the button.
BDisp Aug 23, 2024
cb7bc94
Ensures accurate calculation if is hosted by a ScrollBar before initi…
BDisp Aug 24, 2024
d47188f
Consolidating GetPositionFromSliderLocation and GetSliderLocationDime…
BDisp Aug 25, 2024
7a1eb98
Code cleanup.
BDisp Aug 25, 2024
71d558f
Remove _wasSliderLayoutComplete field.
BDisp Aug 25, 2024
d3ab81e
Add ScrollBar unit tests and code cleanup.
BDisp Aug 25, 2024
a343fd0
Add ScrollButton unit test and code cleanup.
BDisp Aug 26, 2024
ae3fcef
Remove host parameter from scroll classes.
BDisp Aug 26, 2024
1ccd548
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Sep 2, 2024
a83b8f1
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Sep 2, 2024
e489146
Replaces VariationMode with NavigationDirection enum.
BDisp Sep 2, 2024
27aa591
Remove Virtual.
BDisp Sep 2, 2024
7343832
Replace with SuperViewAsScrollBar.
BDisp Sep 2, 2024
b16b463
Doc changes addressed by @tig.
BDisp Sep 2, 2024
3e7d950
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Sep 2, 2024
11fc893
Remove commented code.
BDisp Sep 2, 2024
f0d2bbe
Rename to SuperViewAsScroll.
BDisp Sep 2, 2024
1804d08
Add private BarSize method.
BDisp Sep 3, 2024
bf4b7bd
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Sep 3, 2024
c43de60
BarSize should use Viewport.
BDisp Sep 3, 2024
70b3be2
The barSize should use the Scroll Viewport.
BDisp Sep 3, 2024
6c972c6
Add AutoHideScrollBar and ShowScrollIndicator properties.
BDisp Sep 3, 2024
5279af1
Merge branch 'v2_2489_scroll-scrollbar-new' of tig:BDisp/Terminal.Gui…
tig Sep 3, 2024
e2a2aa1
Upgraded CharMap to use new ScrollBar
tig Sep 3, 2024
68b0352
Merge pull request #194 from tig/BDisp-v2_2489_scroll-scrollbar-new
BDisp Sep 3, 2024
cb1c793
Code cleanup and API doc improvements
tig Sep 3, 2024
c48f6d9
Merge branch 'v2_2489_scroll-scrollbar-new' into BDisp-v2_2489_scroll…
BDisp Sep 4, 2024
7983500
Fix @tig branch errors.
BDisp Sep 4, 2024
9075aca
Using Visible instead of ShowScrollIndicator.
BDisp Sep 4, 2024
3bd4638
I think this was already done before.
BDisp Sep 4, 2024
3701e21
Makes Scroll clicks move proportionally
tig Sep 4, 2024
b495afc
removed comment
tig Sep 4, 2024
da85d58
Rename to start and end.
BDisp Sep 4, 2024
20370c4
Remove comment.
BDisp Sep 4, 2024
f54ded3
Add KeepContentInAllViewport to Scroll.
BDisp Sep 4, 2024
07d7162
Prevent Size being negative.
BDisp Sep 4, 2024
14e2e3c
Fix some KeepContentInAllViewport bugs.
BDisp Sep 4, 2024
dbbde3e
Using GetContentSize.
BDisp Sep 4, 2024
bf3e9b2
Fixes #3729. ProcessContinuousButtonPressedAsync is using a stale Mou…
BDisp Sep 5, 2024
06e9910
Merge branch 'v2_3729_windowsdriver-continuous-mouse-pressed-fix' int…
BDisp Sep 5, 2024
6c56b99
merged latest
tig Sep 5, 2024
6b39670
Merge branch 'v2_develop' into v2_2489_scroll-scrollbar-new
BDisp Sep 5, 2024
cccbbc2
Typo.
BDisp Sep 5, 2024
8d346a8
Implement @tig scroll bars and fix some bugs.
BDisp Sep 5, 2024
84225fc
Fix unit test.
BDisp Sep 5, 2024
bd51356
Add unit test for KeepContentInAllViewport as false.
BDisp Sep 5, 2024
66ec2de
Fix more unit tests that were used with KeepContentInAllViewport as t…
BDisp Sep 5, 2024
630638e
Fix nullable warnings.
BDisp Sep 5, 2024
ae7a86f
Fix ScrollBar that was returning more 2 position at end.
BDisp Sep 6, 2024
c5e886f
Manipulate ViewportSettings with ScrollBars.
BDisp Sep 6, 2024
03dac3e
Merged bdisp latest.
tig Sep 7, 2024
b19437d
Merge pull request #197 from tig/BDisp-v2_2489_scroll-tig-builtin
BDisp Sep 7, 2024
060f915
Merge branch 'v2_2489_scroll-scrollbar-new' of tig:BDisp/Terminal.Gui…
tig Sep 8, 2024
38c604e
More CharMap tweaks
tig Sep 8, 2024
0f3c1ee
Merge pull request #198 from tig/BDisp-v2_2489_scroll-tig-builtin
BDisp Sep 9, 2024
0c55203
Merge branch 'v2_2489_scroll-scrollbar-new' of tig:BDisp/Terminal.Gui…
tig Sep 9, 2024
f4931c2
API doc and overview improvements
tig Sep 9, 2024
f8b2d02
Doc'd samples
tig Sep 9, 2024
0bafe6e
Merge pull request #199 from tig/BDisp-v2_2489_scroll-tig-builtin
BDisp Sep 9, 2024
43879e1
merged
tig Sep 13, 2024
b597925
Merge branch 'v2_2489_scroll-scrollbar-new' of tig:BDisp/Terminal.Gui…
tig Nov 7, 2024
dc7bd44
Merged v2_develop
tig Nov 8, 2024
127bfd5
Refactoring... WIP
tig Nov 9, 2024
427f5b1
Refactoring... WIP 2
tig Nov 9, 2024
b2eae4c
Refactoring... WIP 3
tig Nov 10, 2024
9777357
pulled & merged
tig Nov 10, 2024
701d592
Unit tests pass
tig Nov 10, 2024
805f702
Scrolling scenario upgraded
tig Nov 10, 2024
315b3cd
unit tests pass
tig Nov 10, 2024
362c1d9
Removed legacy scrollview stuff.
tig Nov 10, 2024
8d41641
REMOVED RESPONDER!
tig Nov 10, 2024
23d5ee2
REMOVED RESPONDER 2!
tig Nov 10, 2024
2c48ac6
REMOVED RESPONDER 3!
tig Nov 10, 2024
f206bb0
Merge branch 'v2_develop' into BDisp-v2_2489_scroll-scrollbar-new
tig Nov 10, 2024
6f9816b
Fixed bugs
tig Nov 10, 2024
f7e0a29
Refactored and went back and forth. Things are working well. Tests no…
tig Nov 11, 2024
c7a2542
Refactored and went back and forth. Things are working well. Tests no…
tig Nov 11, 2024
e591453
Refactored again
tig Nov 12, 2024
7fae0c3
Refactored again
tig Nov 12, 2024
f922cba
Really messed stuff up
tig Nov 13, 2024
808ac92
Refixed some stuff. WIP
tig Nov 13, 2024
41a5ac7
ScrollSlider refactored and groovy
tig Nov 14, 2024
13fca41
Fightin math.
tig Nov 14, 2024
ecfa51c
We're back!
tig Nov 15, 2024
b04de75
Working??
tig Nov 15, 2024
70c30ac
Working!
tig Nov 15, 2024
a87d435
AutoHide tweaks
tig Nov 15, 2024
1cbc052
Removed dead prop
tig Nov 15, 2024
ddce5a4
Refactored View.ScrollBar
tig Nov 16, 2024
49e0cd8
Added unit tests for Viewport/FrameChanged events. Fixed bugs.
tig Nov 16, 2024
307b15a
Added todo
tig Nov 16, 2024
0900efc
Merge branch 'v2_2489-scrollbar' of tig:tig/Terminal.Gui into v2_2489…
tig Nov 16, 2024
29c2e39
Tweaked autohide logic
tig Nov 16, 2024
e7fc187
Tweaked scroll logic
tig Nov 16, 2024
095c06c
fixed scenario
tig Nov 16, 2024
0313e8f
fixed Scrlling scenario
tig Nov 16, 2024
861dfee
Code cleanup
tig Nov 16, 2024
bc46801
Code cleanup
tig Nov 16, 2024
f527e59
Scenario cleanup. scrolling.md
tig Nov 17, 2024
a9b3a3e
Charmap refactor WIP
tig Nov 17, 2024
06a636c
Little things.
tig Nov 17, 2024
902577f
Upgrade hexView
tig Nov 18, 2024
f6a82b4
Code cleanup
tig Nov 18, 2024
14dde1a
updated docs
tig Nov 18, 2024
245d78e
Removed restriction in View.Move
tig Nov 18, 2024
2f2076d
removed Showpercent
tig Nov 18, 2024
7777668
Added AllowNegativeXWhenWidthGreaterThanContentWidth
tig Nov 18, 2024
e782c0e
Added AllowNegativeXWhenWidthGreaterThanContentWidth
tig Nov 18, 2024
5c2035d
fixed ListView test wrt AllowNegativeXWhenWidthGreaterThanContentWidth
tig Nov 18, 2024
30adbd6
ListView cleanup
tig Nov 18, 2024
3e48ce2
ListView cleanup 2
tig Nov 18, 2024
93a0859
ListView cleanup 3
tig Nov 18, 2024
b37eeb2
Shortcut bug breaking hexeditor
tig Nov 18, 2024
2a79e96
reverted - Shortcut bug breaking hexeditor
tig Nov 18, 2024
6c54756
reverted - Shortcut bug breaking hexeditor 2
tig Nov 18, 2024
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
4 changes: 2 additions & 2 deletions Terminal.Gui/Drawing/Glyphs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public class GlyphDefinitions
/// <summary>Continuous block meter segment (e.g. for <see cref="ProgressBar"/>).</summary>
public Rune ContinuousMeterSegment { get; set; } = (Rune)'█';

/// <summary>Stipple pattern (e.g. for <see cref="ScrollBarView"/>). Default is Light Shade (U+2591) - ░.</summary>
/// <summary>Stipple pattern (e.g. for <see cref="ScrollBar"/>). Default is Light Shade (U+2591) - ░.</summary>
public Rune Stipple { get; set; } = (Rune)'░';

/// <summary>Diamond (e.g. for <see cref="ScrollBarView"/>. Default is Lozenge (U+25CA) - ◊.</summary>
/// <summary>Diamond. Default is Lozenge (U+25CA) - ◊.</summary>
public Rune Diamond { get; set; } = (Rune)'◊';

/// <summary>Close. Default is Heavy Ballot X (U+2718) - ✘.</summary>
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Drawing/Thickness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public Rectangle GetInside (Rectangle rect)
}

/// <summary>
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and rigth sides
/// Gets the total width of the left and right sides of the rectangle. Sets the width of the left and right sides
/// of the rectangle to half the specified value.
/// </summary>
public int Horizontal
Expand Down
89 changes: 0 additions & 89 deletions Terminal.Gui/Input/Responder.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Terminal.Gui/Terminal.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Scroll\" />
</ItemGroup>
<!-- =================================================================== -->
<!-- Nuget -->
<!-- =================================================================== -->
Expand Down
31 changes: 29 additions & 2 deletions Terminal.Gui/View/View.Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void SetViewport (Rectangle viewport)
//SetSubViewNeedsDraw();
}

OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
RaiseViewportChangedEvent (oldViewport);

return;
}
Expand All @@ -325,6 +325,10 @@ private void SetViewport (Rectangle viewport)
Size = newSize
};

// Note, setting the Frame will cause ViewportChanged to be raised.

return;

void ApplySettings (ref Rectangle newViewport)
{
if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
Expand All @@ -344,6 +348,14 @@ void ApplySettings (ref Rectangle newViewport)
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeXWhenWidthGreaterThanContentWidth))
{
if (Viewport.Width > GetContentSize ().Width)
{
newViewport.X = 0;
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
{
if (newViewport.Y >= GetContentSize ().Height)
Expand All @@ -352,6 +364,14 @@ void ApplySettings (ref Rectangle newViewport)
}
}

if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeYWhenHeightGreaterThanContentHeight))
{
if (Viewport.Height > GetContentSize ().Height)
{
newViewport.Y = 0;
}
}

// IMPORTANT: Check for negative location AFTER checking for location greater than content width
if (!ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY))
{
Expand All @@ -363,6 +383,13 @@ void ApplySettings (ref Rectangle newViewport)
}
}

private void RaiseViewportChangedEvent (Rectangle oldViewport)
{
var args = new DrawEventArgs (IsInitialized ? Viewport : Rectangle.Empty, oldViewport);
OnViewportChanged (args);
ViewportChanged?.Invoke (this, args);
}

/// <summary>
/// Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been
/// updated.
Expand All @@ -373,7 +400,7 @@ void ApplySettings (ref Rectangle newViewport)
/// Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.
/// </summary>
/// <param name="e"></param>
protected virtual void OnViewportChanged (DrawEventArgs e) { ViewportChanged?.Invoke (this, e); }
protected virtual void OnViewportChanged (DrawEventArgs e) { }

/// <summary>
/// Converts a <see cref="Viewport"/>-relative location and size to a screen-relative location and size.
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/View/View.Drawing.Clipping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void SetClip (Region? region)
if (this is Adornment adornment && adornment.Thickness != Thickness.Empty)
{
// Ensure adornments can't draw outside their thickness
frameRegion.Exclude (adornment.Thickness.GetInside (Frame));
frameRegion.Exclude (adornment.Thickness.GetInside (FrameToScreen()));
}

SetClip (frameRegion);
Expand Down
8 changes: 0 additions & 8 deletions Terminal.Gui/View/View.Drawing.Primitives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ public partial class View
/// <summary>Moves the drawing cursor to the specified <see cref="Viewport"/>-relative location in the view.</summary>
/// <remarks>
/// <para>
/// If the provided coordinates are outside the visible content area, this method does nothing.
/// </para>
/// <para>
/// The top-left corner of the visible content area is <c>ViewPort.Location</c>.
/// </para>
/// </remarks>
Expand All @@ -22,11 +19,6 @@ public bool Move (int col, int row)
return false;
}

if (col < 0 || row < 0 || col >= Viewport.Width || row >= Viewport.Height)
{
return false;
}

Point screen = ViewportToScreen (new Point (col, row));
Driver?.Move (screen.X, screen.Y);

Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/View/View.Hierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
/// <para>
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
/// Subview's
/// lifecycle to be transferred to the caller; the caller muse call <see cref="Dispose"/>.
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/>.
/// </para>
/// </remarks>
/// <returns>
Expand Down Expand Up @@ -214,7 +214,7 @@ public virtual void OnRemoved (SuperViewChangedEventArgs e)
/// <para>
/// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
/// Subview's
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose"/> on any Views that were
/// lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/> on any Views that were
/// added.
/// </para>
/// </remarks>
Expand Down
19 changes: 18 additions & 1 deletion Terminal.Gui/View/View.Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,28 @@ private bool SetFrame (in Rectangle frame)
SetNeedsLayout ();

// BUGBUG: When SetFrame is called from Frame_set, this event gets raised BEFORE OnResizeNeeded. Is that OK?
OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
OnFrameChanged (in frame);
FrameChanged?.Invoke (this, new (in frame));

if (oldViewport != Viewport)
{
RaiseViewportChangedEvent (oldViewport);
}
return true;
}

/// <summary>
/// Called when <see cref="Frame"/> changes.
/// </summary>
/// <param name="frame">The new Frame.</param>
protected virtual void OnFrameChanged (in Rectangle frame) { }

/// <summary>
/// Raised when the <see cref="Frame"/> changes. This event is raised after the <see cref="Frame"/> has been
/// updated.
/// </summary>
public event EventHandler<EventArgs<Rectangle>>? FrameChanged;

/// <summary>Gets the <see cref="Frame"/> with a screen-relative location.</summary>
/// <returns>The location and size of the view in screen-relative coordinates.</returns>
public virtual Rectangle FrameToScreen ()
Expand Down
Loading
Loading