From 4cb27fc2934f937d96f97a6c3ccf520ae69c6de5 Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 24 May 2024 16:45:12 +0100 Subject: [PATCH] Rename to Scroll_ prefix on the Scroll event methods. --- Terminal.Gui/Views/Scroll.cs | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Terminal.Gui/Views/Scroll.cs b/Terminal.Gui/Views/Scroll.cs index c4afab231..09dd4925b 100644 --- a/Terminal.Gui/Views/Scroll.cs +++ b/Terminal.Gui/Views/Scroll.cs @@ -28,9 +28,9 @@ public class Scroll : View Added += Scroll_Added; Removed += Scroll_Removed; Initialized += Scroll_Initialized; - DrawContent += SubViews_DrawContent; - MouseEvent += SliderContainer_MouseEvent; - _slider.DrawContent += SubViews_DrawContent; + DrawContent += Scroll_DrawContent; + MouseEvent += Scroll_MouseEvent; + _slider.DrawContent += Scroll_DrawContent; _slider.MouseEvent += Slider_MouseEvent; } @@ -118,9 +118,9 @@ public class Scroll : View { Added -= Scroll_Added; Initialized -= Scroll_Initialized; - DrawContent -= SubViews_DrawContent; - MouseEvent -= SliderContainer_MouseEvent; - _slider.DrawContent -= SubViews_DrawContent; + DrawContent -= Scroll_DrawContent; + MouseEvent -= Scroll_MouseEvent; + _slider.DrawContent -= Scroll_DrawContent; _slider.MouseEvent -= Slider_MouseEvent; base.Dispose (disposing); @@ -215,8 +215,30 @@ public class Scroll : View parent.MouseLeave += Parent_MouseLeave; } + private void Scroll_DrawContent (object sender, DrawEventArgs e) { SetColorSchemeWithSuperview (sender as View); } + private void Scroll_Initialized (object sender, EventArgs e) { SetWidthHeight (); } + private void Scroll_MouseEvent (object sender, MouseEventEventArgs e) + { + MouseEvent me = e.MouseEvent; + int location = Orientation == Orientation.Vertical ? me.Position.Y : me.Position.X; + int barSize = Orientation == Orientation.Vertical ? Frame.Height : Frame.Width; + + (int topLeft, int bottomRight) sliderPos = _orientation == Orientation.Vertical + ? new (_slider.Frame.Y, _slider.Frame.Bottom - 1) + : new (_slider.Frame.X, _slider.Frame.Right - 1); + + if (me.Flags == MouseFlags.Button1Pressed && location < sliderPos.topLeft) + { + Position = Math.Max (Position - barSize, 0); + } + else if (me.Flags == MouseFlags.Button1Pressed && location > sliderPos.bottomRight) + { + Position = Math.Min (Position + barSize, Size - barSize); + } + } + private void Scroll_Removed (object sender, SuperViewChangedEventArgs e) { if (e.Parent is { }) @@ -330,26 +352,4 @@ public class Scroll : View e.Handled = true; } - - private void SliderContainer_MouseEvent (object sender, MouseEventEventArgs e) - { - MouseEvent me = e.MouseEvent; - int location = Orientation == Orientation.Vertical ? me.Position.Y : me.Position.X; - int barSize = Orientation == Orientation.Vertical ? Frame.Height : Frame.Width; - - (int topLeft, int bottomRight) sliderPos = _orientation == Orientation.Vertical - ? new (_slider.Frame.Y, _slider.Frame.Bottom - 1) - : new (_slider.Frame.X, _slider.Frame.Right - 1); - - if (me.Flags == MouseFlags.Button1Pressed && location < sliderPos.topLeft) - { - Position = Math.Max (Position - barSize, 0); - } - else if (me.Flags == MouseFlags.Button1Pressed && location > sliderPos.bottomRight) - { - Position = Math.Min (Position + barSize, Size - barSize); - } - } - - private void SubViews_DrawContent (object sender, DrawEventArgs e) { SetColorSchemeWithSuperview (sender as View); } }