Skip to content

Commit 570a595

Browse files
committed
- Exposed a method to colorize images based on theme
- Added two more steps to theme image adjustments
1 parent 7dffc0a commit 570a595

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎FlashDevelop/Bin/Debug/Settings/Themes/Default.fdi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FD UI THEME (5.0+)
22

3-
# Default, Bright, Dim, Dark
3+
# Bright, Default, Dim, Dark, Darker, Black
44
ImageManager.ImageSet=Default
55

66
# Default, Large

‎FlashDevelop/MainForm.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,14 @@ public IPlugin FindPlugin(String guid)
16151615
return plugin.Instance;
16161616
}
16171617

1618+
/// <summary>
1619+
/// Adjusts the image for different themes
1620+
/// </summary>
1621+
public Image ImageSetAdjust(Image image)
1622+
{
1623+
return ImageManager.AdjustImage(image);
1624+
}
1625+
16181626
/// <summary>
16191627
/// Themes the controls from the parent
16201628
/// </summary>

‎FlashDevelop/Managers/ImageManager.cs‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ class ImageManager
2222
public static Bitmap Source;
2323
public static Dictionary<String, Bitmap> Cache;
2424

25+
/// <summary>
26+
/// Static constructor
27+
/// </summary>
2528
static ImageManager()
2629
{
2730
Double scale = ScaleHelper.GetScale();
28-
String style = Globals.MainForm.GetThemeValue("ImageManager.ImageSet");
2931
Cache = new Dictionary<String, Bitmap>();
3032
if (scale >= 1.5)
3133
{
@@ -39,10 +41,21 @@ static ImageManager()
3941
Padding = 0;
4042
Source = new Bitmap(FileNameHelper.Images);
4143
}
42-
// Adjust images for different themes
43-
if (style == "Dim") Source = (Bitmap)ImageKonverter.ImageAdjust(Source, -5, -2);
44-
else if (style == "Dark") Source = (Bitmap)ImageKonverter.ImageAdjust(Source, -5, -10);
45-
else if (style == "Bright") Source = (Bitmap)ImageKonverter.ImageAdjust(Source, 20, 0);
44+
Source = (Bitmap)AdjustImage(Source);
45+
}
46+
47+
/// <summary>
48+
/// Adjusts the image for different themes
49+
/// </summary>
50+
public static Image AdjustImage(Image image)
51+
{
52+
String style = Globals.MainForm.GetThemeValue("ImageManager.ImageSet");
53+
if (style == "Bright") return ImageKonverter.ImageAdjust(Source, 20, 0);
54+
else if (style == "Dim") return ImageKonverter.ImageAdjust(Source, -5, -2);
55+
else if (style == "Dark") return ImageKonverter.ImageAdjust(Source, -5, -10);
56+
else if (style == "Darker") return ImageKonverter.ImageAdjust(Source, -20, -20);
57+
else if (style == "Black") return ImageKonverter.ImageAdjust(Source, -50, -25);
58+
else return image;
4659
}
4760

4861
/// <summary>

‎PluginCore/PluginCore/Interfaces.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public interface IMainForm : IWin32Window
125125
String GetThemeValue(String id);
126126
Color GetThemeColor(String id);
127127
IPlugin FindPlugin(String guid);
128+
Image ImageSetAdjust(Image image);
128129
Image FindImage(String data);
129130

130131
#endregion

0 commit comments

Comments
 (0)