Skip to content

Commit cb41827

Browse files
committed
Improved ScrollBarEx update 5
Removed user settings option for turning on/off custom scroll bars.
1 parent 81f54ad commit cb41827

File tree

10 files changed

+73
-179
lines changed

10 files changed

+73
-179
lines changed

FlashDevelop/Settings/Accessors.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,6 @@ public Int32 HighlightMatchingWordsDelay
382382
set { this.highlightMatchingWordsDelay = value; }
383383
}
384384

385-
[DefaultValue(ScrollBarMode.Auto)]
386-
[DisplayName("Use Custom Scroll Bar")]
387-
[LocalizedCategory("FlashDevelop.Category.Editor")]
388-
[LocalizedDescription("FlashDevelop.Description.UseCustomScrollBar")]
389-
public ScrollBarMode UseCustomScrollBar
390-
{
391-
get { return this.useCustomScrollBar; }
392-
set
393-
{
394-
if (this.useCustomScrollBar == value) return;
395-
this.useCustomScrollBar = value;
396-
ScrollBarEx.NotifySettingsChanged(this.useCustomScrollBar);
397-
}
398-
}
399-
400385
#endregion
401386

402387
#region Locale

FlashDevelop/Settings/Properties.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public partial class SettingObject : ISettings
104104
private Boolean uiWrapList = false;
105105
private Boolean uiDisableSmartMatch = false;
106106
private String uiInsertionTriggers = "";
107-
private ScrollBarMode useCustomScrollBar = ScrollBarMode.Auto;
108107
}
109108

110109
}

PluginCore/PluginCore/Controls/ScrollBarEx.cs

Lines changed: 53 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,11 @@ public class ScrollBarEx : Control
2020
{
2121
#region scroll bar settings
2222

23-
public delegate void SettingsChangedEventHandler(ScrollBarMode value);
24-
public static event SettingsChangedEventHandler SettingsChanged;
25-
26-
public static ScrollBarMode SettingsMode
27-
{
28-
get { return PluginBase.MainForm.Settings.UseCustomScrollBar; }
29-
}
30-
3123
public static bool UseCustom
3224
{
3325
get { return PluginBase.MainForm.GetThemeValue("ScrollBar.UseCustom", "false").ToLower() == "true"; }
3426
}
3527

36-
public static void NotifySettingsChanged(ScrollBarMode value)
37-
{
38-
if (SettingsChanged != null) SettingsChanged.Invoke(value);
39-
}
40-
4128
#endregion
4229

4330
#region drawing
@@ -53,7 +40,7 @@ public static void NotifySettingsChanged(ScrollBarMode value)
5340
private Color backColorDisabled/* = SystemColors.ControlLight*/;
5441
private Color borderColor/* = SystemColors.ActiveBorder*/;
5542
private Color borderColorDisabled/* = SystemColors.Control*/;
56-
private bool colorsInvalidated;
43+
private Boolean colorsInvalidated = false;
5744

5845
/// <summary>
5946
/// Resets the component colors to default values.
@@ -86,14 +73,14 @@ public void ValidateColors()
8673
// Reset any unassigned colors to default.
8774
InitializeColors();
8875

89-
// If no colors are explicitly defined, not fallback colors are required.
76+
// If no colors are explicitly defined, no fallback colors are required.
9077
if (!colorsInvalidated) return;
9178

9279
// Newly introduced color options - do not assign default colors. Instead fall back to associated colors.
93-
foreColorHot = PluginBase.MainForm.GetThemeColor("ScrollBar.HotForeColor", foreColor);
94-
arrowColor = PluginBase.MainForm.GetThemeColor("ScrollBar.ArrowColor", foreColor);
95-
arrowColorHot = PluginBase.MainForm.GetThemeColor("ScrollBar.HotArrowColor", arrowColor);
96-
arrowColorPressed = PluginBase.MainForm.GetThemeColor("ScrollBar.ActiveArrowColor", foreColorPressed);
80+
if (foreColorHot.IsEmpty) foreColorHot = PluginBase.MainForm.GetThemeColor("ScrollBar.HotForeColor", foreColor);
81+
if (arrowColor.IsEmpty) arrowColor = PluginBase.MainForm.GetThemeColor("ScrollBar.ArrowColor", foreColor);
82+
if (arrowColorHot.IsEmpty) arrowColorHot = PluginBase.MainForm.GetThemeColor("ScrollBar.HotArrowColor", arrowColor);
83+
if (arrowColorPressed.IsEmpty) arrowColorPressed = PluginBase.MainForm.GetThemeColor("ScrollBar.ActiveArrowColor", foreColorPressed);
9784

9885
colorsInvalidated = false;
9986
}
@@ -117,6 +104,7 @@ private void ResetColors()
117104
backColor =
118105
backColorDisabled =
119106
Color.Empty;
107+
120108
colorsInvalidated = true;
121109
}
122110

@@ -128,21 +116,18 @@ private void ResetColors()
128116
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
129117
private void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation orientation)
130118
{
131-
if (g == null)
132-
{
133-
throw new ArgumentNullException("g");
134-
}
119+
if (g == null) throw new ArgumentNullException("g");
120+
135121
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect))
136-
{
137122
return;
138-
}
139-
if (orientation == ScrollBarOrientation.Vertical)
140-
{
141-
DrawBackgroundVertical(g, rect);
142-
}
143-
else
144-
{
145-
DrawBackgroundHorizontal(g, rect);
123+
124+
switch (orientation) {
125+
case ScrollBarOrientation.Vertical:
126+
DrawBackgroundVertical(g, rect);
127+
break;
128+
default:
129+
DrawBackgroundHorizontal(g, rect);
130+
break;
146131
}
147132
}
148133

@@ -155,16 +140,12 @@ private void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation ori
155140
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
156141
private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation)
157142
{
158-
if (g == null)
159-
{
160-
throw new ArgumentNullException("g");
161-
}
143+
if (g == null) throw new ArgumentNullException("g");
144+
162145
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect) || state == ScrollBarState.Disabled)
163-
{
164146
return;
165-
}
166147

167-
Color color = foreColor;
148+
Color color;
168149
switch (state)
169150
{
170151
case ScrollBarState.Hot:
@@ -173,15 +154,18 @@ private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollB
173154
case ScrollBarState.Pressed:
174155
color = foreColorPressed;
175156
break;
157+
default:
158+
color = foreColor;
159+
break;
176160
}
177161

178-
if (orientation == ScrollBarOrientation.Vertical)
179-
{
180-
DrawThumbVertical(g, rect, color);
181-
}
182-
else
183-
{
184-
DrawThumbHorizontal(g, rect, color);
162+
switch (orientation) {
163+
case ScrollBarOrientation.Vertical:
164+
DrawThumbVertical(g, rect, color);
165+
break;
166+
default:
167+
DrawThumbHorizontal(g, rect, color);
168+
break;
185169
}
186170
}
187171

@@ -195,16 +179,12 @@ private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollB
195179
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
196180
private void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation)
197181
{
198-
if (g == null)
199-
{
200-
throw new ArgumentNullException("g");
201-
}
182+
if (g == null) throw new ArgumentNullException("g");
183+
202184
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect))
203-
{
204185
return;
205-
}
206186

207-
Color color = arrowColor;
187+
Color color;
208188

209189
switch (state)
210190
{
@@ -216,15 +196,18 @@ private void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonSta
216196
case ScrollBarArrowButtonState.DownPressed:
217197
color = arrowColorPressed;
218198
break;
199+
default:
200+
color = arrowColor;
201+
break;
219202
}
220203

221-
if (orientation == ScrollBarOrientation.Vertical)
222-
{
223-
DrawArrowButtonVertical(g, rect, color, arrowUp);
224-
}
225-
else
226-
{
227-
DrawArrowButtonHorizontal(g, rect, color, arrowUp);
204+
switch (orientation) {
205+
case ScrollBarOrientation.Vertical:
206+
DrawArrowButtonVertical(g, rect, color, arrowUp);
207+
break;
208+
default:
209+
DrawArrowButtonHorizontal(g, rect, color, arrowUp);
210+
break;
228211
}
229212
}
230213

@@ -235,7 +218,7 @@ private void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonSta
235218
/// <param name="rect">The rectangle in which to paint.</param>
236219
private void DrawBackgroundVertical(Graphics g, Rectangle rect)
237220
{
238-
using (SolidBrush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
221+
using (Brush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
239222
{
240223
g.FillRectangle(brush, rect);
241224
}
@@ -248,7 +231,7 @@ private void DrawBackgroundVertical(Graphics g, Rectangle rect)
248231
/// <param name="rect">The rectangle in which to paint.</param>
249232
private void DrawBackgroundHorizontal(Graphics g, Rectangle rect)
250233
{
251-
using (SolidBrush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
234+
using (Brush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
252235
{
253236
g.FillRectangle(brush, rect);
254237
}
@@ -262,10 +245,11 @@ private void DrawBackgroundHorizontal(Graphics g, Rectangle rect)
262245
/// <param name="color">The color to draw the thumb with.</param>
263246
private static void DrawThumbVertical(Graphics g, Rectangle rect, Color color)
264247
{
265-
var innerRect = new Rectangle(rect.Left + ScaleHelper.Scale(2), rect.Top, rect.Width - ScaleHelper.Scale(4), rect.Height);
248+
rect.X += ScaleHelper.Scale(2);
249+
rect.Width -= ScaleHelper.Scale(4);
266250
using (Brush brush = new SolidBrush(color))
267251
{
268-
g.FillRectangle(brush, innerRect);
252+
g.FillRectangle(brush, rect);
269253
}
270254
}
271255

@@ -277,10 +261,11 @@ private static void DrawThumbVertical(Graphics g, Rectangle rect, Color color)
277261
/// <param name="color">The color to draw the thumb with.</param>
278262
private static void DrawThumbHorizontal(Graphics g, Rectangle rect, Color color)
279263
{
280-
var innerRect = new Rectangle(rect.Left, rect.Top + ScaleHelper.Scale(2), rect.Width, rect.Height - ScaleHelper.Scale(4));
264+
rect.Y += ScaleHelper.Scale(2);
265+
rect.Height -= ScaleHelper.Scale(4);
281266
using (Brush brush = new SolidBrush(color))
282267
{
283-
g.FillRectangle(brush, innerRect);
268+
g.FillRectangle(brush, rect);
284269
}
285270
}
286271

@@ -317,7 +302,7 @@ private static void DrawArrowButtonVertical(Graphics g, Rectangle rect, Color co
317302
{
318303
new Point(middle.X - pad, middle.Y - 1),
319304
new Point(middle.X + pad + 1, middle.Y - 1),
320-
new Point(middle.X, middle.Y + pad)
305+
new Point(middle.X, middle.Y + pad)
321306
};
322307
break;
323308
}
@@ -2238,28 +2223,7 @@ public enum ScrollBarOrientation
22382223
/// </summary>
22392224
Vertical
22402225
}
2241-
2242-
/// <summary>
2243-
/// Enum for scrollbar usage settings.
2244-
/// </summary>
2245-
public enum ScrollBarMode
2246-
{
2247-
/// <summary>
2248-
/// Turn off the usage of <see cref="ScrollBarEx"/> completely.
2249-
/// </summary>
2250-
Off,
2251-
2252-
/// <summary>
2253-
/// Use <see cref="ScrollBarEx"/> only when explicit theme is defined for scroll bars.
2254-
/// </summary>
2255-
Auto,
2256-
2257-
/// <summary>
2258-
/// Always use <see cref="ScrollBarEx"/> instead of the system scroll bar.
2259-
/// </summary>
2260-
On
2261-
}
2262-
2226+
22632227
/// <summary>
22642228
/// The scrollbar states.
22652229
/// </summary>

PluginCore/PluginCore/Interfaces.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ public interface ISettings
289289
Boolean DisableSmartMatch { get; set; }
290290
Boolean SaveUnicodeWithBOM { get; set; }
291291
String InsertionTriggers { get; set; }
292-
ScrollBarMode UseCustomScrollBar { get; set; }
293292

294293
#endregion
295294
}

PluginCore/PluginCore/Resources/de_DE.resX

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5964,8 +5964,4 @@ Eigene Sprachumgebungen müssen eine Erweiterung der Standard-Sprachumgebung sei
59645964
<value>Highlight word:</value>
59655965
<comment>Added after 5.0.2</comment>
59665966
</data>
5967-
<data name="FlashDevelop.Description.UseCustomScrollBar" xml:space="preserve">
5968-
<value>Whether to use the custom scroll bar for text editors. Set to 'Auto' to use the custom scroll bars only when the current theme has custom scroll bars enabled.</value>
5969-
<comment>REQUIRES TRANSLATION</comment>
5970-
</data>
59715967
</root>

PluginCore/PluginCore/Resources/en_US.resX

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5980,7 +5980,4 @@ Custom locales must be an extension of a default locale, e.g. en-US.</value>
59805980
<value>Highlight word:</value>
59815981
<comment>Added after 5.0.2</comment>
59825982
</data>
5983-
<data name="FlashDevelop.Description.UseCustomScrollBar" xml:space="preserve">
5984-
<value>Whether to use the custom scroll bar for text editors. Set to 'Auto' to use the custom scroll bars only when the current theme has custom scroll bars enabled.</value>
5985-
</data>
59865983
</root>

PluginCore/PluginCore/Resources/eu_ES.resX

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5961,8 +5961,4 @@ Lokalizazio pertsonalizatuek lehenetsiaren luzapen bat izan behar dute, adb. en-
59615961
<value>Highlight word:</value>
59625962
<comment>Added after 5.0.2</comment>
59635963
</data>
5964-
<data name="FlashDevelop.Description.UseCustomScrollBar" xml:space="preserve">
5965-
<value>Whether to use the custom scroll bar for text editors. Set to 'Auto' to use the custom scroll bars only when the current theme has custom scroll bars enabled.</value>
5966-
<comment>REQUIRES TRANSLATION</comment>
5967-
</data>
59685964
</root>

PluginCore/PluginCore/Resources/ja_JP.resX

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6022,8 +6022,4 @@ UseData:"</value>
60226022
<value>Highlight word:</value>
60236023
<comment>Added after 5.0.2</comment>
60246024
</data>
6025-
<data name="FlashDevelop.Description.UseCustomScrollBar" xml:space="preserve">
6026-
<value>Whether to use the custom scroll bar for text editors. Set to 'Auto' to use the custom scroll bars only when the current theme has custom scroll bars enabled.</value>
6027-
<comment>REQUIRES TRANSLATION</comment>
6028-
</data>
60296025
</root>

PluginCore/PluginCore/Resources/zh_CN.resx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5974,8 +5974,4 @@
59745974
<value>Highlight word:</value>
59755975
<comment>Added after 5.0.2</comment>
59765976
</data>
5977-
<data name="FlashDevelop.Description.UseCustomScrollBar" xml:space="preserve">
5978-
<value>Whether to use the custom scroll bar for text editors. Set to 'Auto' to use the custom scroll bars only when the current theme has custom scroll bars enabled.</value>
5979-
<comment>REQUIRES TRANSLATION</comment>
5980-
</data>
59815977
</root>

0 commit comments

Comments
 (0)