2017-06-19 09:17:57 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2017, Lars Brubaker, John Lewin
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
2017-08-12 00:23:26 -07:00
|
|
|
|
using System.Collections.Generic;
|
2017-06-19 09:17:57 -07:00
|
|
|
|
using Agg.Image;
|
|
|
|
|
|
using CustomWidgets;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2018-01-10 23:21:46 -08:00
|
|
|
|
using MatterHackers.Localizations;
|
2017-08-17 18:18:41 -07:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2017-06-19 09:17:57 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
public class ThemeConfig
|
|
|
|
|
|
{
|
2018-02-12 15:28:26 -08:00
|
|
|
|
public static ImageBuffer RestoreNormal { get; private set; }
|
|
|
|
|
|
public static ImageBuffer RestoreHover { get; private set; }
|
2017-06-19 09:17:57 -07:00
|
|
|
|
private static ImageBuffer restorePressed;
|
|
|
|
|
|
|
2017-10-22 19:53:48 -07:00
|
|
|
|
public int FontSize7 { get; } = 7;
|
|
|
|
|
|
public int FontSize9 { get; } = 9;
|
|
|
|
|
|
public int FontSize10 { get; } = 10;
|
|
|
|
|
|
public int FontSize11 { get; } = 11;
|
|
|
|
|
|
public int FontSize12 { get; } = 12;
|
|
|
|
|
|
public int FontSize14 { get; } = 14;
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-04-10 07:35:22 -07:00
|
|
|
|
internal readonly int shortButtonHeight = 30;
|
|
|
|
|
|
private readonly int defaultScrollBarWidth = 120;
|
|
|
|
|
|
private readonly int sideBarButtonWidth = 138;
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public int DefaultFontSize { get; } = 11;
|
2018-02-21 16:41:31 -08:00
|
|
|
|
public int H1PointSize { get; set; } = 11;
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public double ButtonHeight { get; internal set; } = 32;
|
2017-08-06 20:55:00 -07:00
|
|
|
|
|
2018-04-12 08:42:10 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Indicates if icons should be inverted due to black source images on a dark theme
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool InvertIcons => this.Colors.IsDarkTheme;
|
|
|
|
|
|
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public BorderDouble ButtonSpacing { get; set; } = new BorderDouble(3, 0, 0, 0);
|
|
|
|
|
|
public BorderDouble ToolbarPadding { get; set; } = 3;
|
2017-06-19 18:52:10 -07:00
|
|
|
|
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public LinkButtonFactory LinkButtonFactory { get; private set; }
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public TextImageButtonFactory WhiteButtonFactory { get; private set; }
|
2017-08-03 07:41:19 -07:00
|
|
|
|
public TextImageButtonFactory ButtonFactory { get; private set; }
|
2017-08-20 14:23:15 -07:00
|
|
|
|
public TextImageButtonFactory WizardButtons { get; private set; }
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public TextImageButtonFactory MicroButton { get; private set; }
|
|
|
|
|
|
public TextImageButtonFactory MicroButtonMenu { get; private set; }
|
2017-08-01 09:29:49 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used to make buttons in menu rows where the background color is consistently white
|
|
|
|
|
|
/// </summary>
|
2017-08-03 07:41:19 -07:00
|
|
|
|
public TextImageButtonFactory MenuButtonFactory { get; private set; }
|
2017-08-01 09:29:49 -07:00
|
|
|
|
|
2017-11-10 16:31:47 -08:00
|
|
|
|
public int SplitterWidth => (int)(6 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4));
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-01-10 13:03:12 -08:00
|
|
|
|
public IThemeColors Colors { get; set; }
|
|
|
|
|
|
|
2017-10-31 11:43:25 -07:00
|
|
|
|
public Color SlightShade { get; } = new Color(0, 0, 0, 40);
|
|
|
|
|
|
public Color MinimalShade { get; } = new Color(0, 0, 0, 15);
|
2017-11-07 12:06:43 -08:00
|
|
|
|
public Color Shade { get; } = new Color(0, 0, 0, 120);
|
|
|
|
|
|
public Color DarkShade { get; } = new Color(0, 0, 0, 190);
|
2017-08-03 18:33:14 -07:00
|
|
|
|
|
2017-11-21 11:11:07 -08:00
|
|
|
|
public Color ActiveTabColor { get; set; }
|
2018-01-08 14:28:52 -08:00
|
|
|
|
public Color ActiveTabBarBackground { get; set; }
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public Color InactiveTabColor { get; set; }
|
|
|
|
|
|
public Color InteractionLayerOverlayColor { get; private set; }
|
|
|
|
|
|
public Color SplitterBackground { get; private set; } = new Color(0, 0, 0, 60);
|
|
|
|
|
|
public Color TabBodyBackground { get; private set; }
|
|
|
|
|
|
public Color ToolbarButtonBackground { get; set; } = Color.Transparent;
|
|
|
|
|
|
public Color ToolbarButtonHover => this.SlightShade;
|
|
|
|
|
|
public Color ToolbarButtonDown => this.MinimalShade;
|
2017-10-19 09:01:07 -07:00
|
|
|
|
|
2018-01-10 23:21:46 -08:00
|
|
|
|
public GuiWidget CreateSearchButton()
|
|
|
|
|
|
{
|
2018-04-12 08:42:10 -07:00
|
|
|
|
return new IconButton(AggContext.StaticData.LoadIcon("icon_search_24x24.png", 16, 16, this.InvertIcons), this)
|
2018-01-10 23:21:46 -08:00
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = "Search".Localize(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-06-19 09:17:57 -07:00
|
|
|
|
static ThemeConfig()
|
|
|
|
|
|
{
|
|
|
|
|
|
// EnsureRestoreButtonImages
|
|
|
|
|
|
int size = (int)(16 * GuiWidget.DeviceScale);
|
|
|
|
|
|
|
2017-08-20 02:34:39 -07:00
|
|
|
|
if (AggContext.OperatingSystem == OSType.Android)
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2018-02-12 15:28:26 -08:00
|
|
|
|
RestoreNormal = ColorCircle(size, new Color(200, 0, 0));
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-02-12 15:28:26 -08:00
|
|
|
|
RestoreNormal = ColorCircle(size, Color.Transparent);
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
2018-02-12 15:28:26 -08:00
|
|
|
|
RestoreHover = ColorCircle(size, new Color("#DB4437"));
|
2017-10-31 11:43:25 -07:00
|
|
|
|
restorePressed = ColorCircle(size, new Color(255, 0, 0));
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ThemeConfig()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-07 12:17:23 -07:00
|
|
|
|
public void RebuildTheme(IThemeColors colors)
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2018-04-07 12:17:23 -07:00
|
|
|
|
this.Colors = colors;
|
2017-06-20 06:09:01 -07:00
|
|
|
|
|
2018-01-12 16:42:55 -08:00
|
|
|
|
DefaultThumbView.ThumbColor = new Color(colors.PrimaryTextColor, 30);
|
2017-07-27 18:20:16 -07:00
|
|
|
|
|
2017-08-03 14:43:06 -07:00
|
|
|
|
var commonOptions = new ButtonFactoryOptions();
|
2018-01-12 16:42:55 -08:00
|
|
|
|
commonOptions.NormalTextColor = colors.PrimaryTextColor;
|
|
|
|
|
|
commonOptions.HoverTextColor = colors.PrimaryTextColor;
|
|
|
|
|
|
commonOptions.PressedTextColor = colors.PrimaryTextColor;
|
|
|
|
|
|
commonOptions.DisabledTextColor = colors.TertiaryBackgroundColor;
|
2017-08-13 14:21:28 -07:00
|
|
|
|
commonOptions.Margin = new BorderDouble(14, 0);
|
2018-01-12 08:26:12 -08:00
|
|
|
|
commonOptions.FontSize = this.DefaultFontSize;
|
2017-08-13 14:21:28 -07:00
|
|
|
|
commonOptions.ImageSpacing = 8;
|
2017-08-03 14:43:06 -07:00
|
|
|
|
commonOptions.BorderWidth = 0;
|
|
|
|
|
|
commonOptions.FixedHeight = 32;
|
|
|
|
|
|
|
2018-01-02 22:24:17 -08:00
|
|
|
|
this.TabBodyBackground = this.ResolveColor(
|
2018-04-07 11:29:56 -07:00
|
|
|
|
colors.TertiaryBackgroundColor,
|
2018-01-02 22:24:17 -08:00
|
|
|
|
new Color(
|
2018-04-07 11:29:56 -07:00
|
|
|
|
Color.White,
|
2018-01-12 16:42:55 -08:00
|
|
|
|
(colors.IsDarkTheme) ? 3 : 25));
|
2018-01-01 11:22:31 -08:00
|
|
|
|
|
2018-01-08 14:28:52 -08:00
|
|
|
|
this.ActiveTabColor = this.TabBodyBackground;
|
|
|
|
|
|
this.ActiveTabBarBackground = this.ActiveTabColor.AdjustLightness(0.85).ToColor();
|
|
|
|
|
|
|
2017-11-27 16:41:52 -08:00
|
|
|
|
// Active tab color with slight transparency
|
2018-01-11 01:16:41 -08:00
|
|
|
|
this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 240);
|
2017-11-27 16:41:52 -08:00
|
|
|
|
|
2018-01-12 16:42:55 -08:00
|
|
|
|
float alpha0to1 = (colors.IsDarkTheme ? 20 : 60) / 255.0f;
|
2017-11-21 11:11:07 -08:00
|
|
|
|
|
2018-01-12 16:42:55 -08:00
|
|
|
|
this.InactiveTabColor = ResolveColor(colors.PrimaryBackgroundColor, new Color(Color.White, this.SlightShade.alpha));
|
2017-11-21 11:11:07 -08:00
|
|
|
|
|
2017-11-27 17:48:03 -08:00
|
|
|
|
this.SplitterBackground = this.ActiveTabColor.AdjustLightness(0.87).ToColor();
|
2017-11-21 11:11:07 -08:00
|
|
|
|
|
2017-08-03 14:43:06 -07:00
|
|
|
|
this.ButtonFactory = new TextImageButtonFactory(commonOptions);
|
|
|
|
|
|
|
2017-08-20 14:23:15 -07:00
|
|
|
|
this.WizardButtons = new TextImageButtonFactory(new ButtonFactoryOptions(commonOptions)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if __ANDROID__
|
2017-10-23 09:36:16 -07:00
|
|
|
|
FontSize = this.FontSize14,
|
2018-04-07 11:29:56 -07:00
|
|
|
|
FixedHeight = 34 * GuiWidget.DeviceScale,
|
2017-08-20 14:23:15 -07:00
|
|
|
|
Margin = commonOptions.Margin * 1.2
|
|
|
|
|
|
#endif
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2017-08-17 13:05:30 -07:00
|
|
|
|
var commonGray = new ButtonFactoryOptions(commonOptions)
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2017-10-31 11:43:25 -07:00
|
|
|
|
NormalTextColor = Color.Black,
|
|
|
|
|
|
NormalFillColor = Color.LightGray,
|
|
|
|
|
|
HoverTextColor = Color.Black,
|
|
|
|
|
|
PressedTextColor = Color.Black,
|
|
|
|
|
|
PressedFillColor = Color.LightGray,
|
2017-08-17 13:05:30 -07:00
|
|
|
|
};
|
2017-08-04 09:00:20 -07:00
|
|
|
|
|
2017-08-17 13:05:30 -07:00
|
|
|
|
this.MenuButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions(commonGray)
|
2017-08-04 09:00:20 -07:00
|
|
|
|
{
|
2017-08-17 13:05:30 -07:00
|
|
|
|
Margin = new BorderDouble(8, 0)
|
|
|
|
|
|
});
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2017-08-04 09:00:20 -07:00
|
|
|
|
this.MicroButton = new TextImageButtonFactory(new ButtonFactoryOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
FixedHeight = 20 * GuiWidget.DeviceScale,
|
|
|
|
|
|
FixedWidth = 30 * GuiWidget.DeviceScale,
|
|
|
|
|
|
FontSize = 8,
|
|
|
|
|
|
Margin = 0,
|
2018-01-12 16:42:55 -08:00
|
|
|
|
CheckedBorderColor = colors.PrimaryTextColor
|
2017-08-04 09:00:20 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
2017-08-17 13:05:30 -07:00
|
|
|
|
this.MicroButtonMenu = new TextImageButtonFactory(new ButtonFactoryOptions(commonGray)
|
2017-08-04 09:00:20 -07:00
|
|
|
|
{
|
2017-08-17 13:05:30 -07:00
|
|
|
|
FixedHeight = 20 * GuiWidget.DeviceScale,
|
|
|
|
|
|
FixedWidth = 30 * GuiWidget.DeviceScale,
|
|
|
|
|
|
FontSize = 8,
|
|
|
|
|
|
Margin = 0,
|
|
|
|
|
|
BorderWidth = 1,
|
2017-10-31 11:43:25 -07:00
|
|
|
|
CheckedBorderColor = Color.Black
|
2017-08-17 13:05:30 -07:00
|
|
|
|
});
|
2017-08-04 09:00:20 -07:00
|
|
|
|
|
2017-08-20 14:23:15 -07:00
|
|
|
|
#region PartPreviewWidget
|
2018-04-07 11:29:56 -07:00
|
|
|
|
|
2017-08-17 13:05:30 -07:00
|
|
|
|
WhiteButtonFactory = new TextImageButtonFactory(new ButtonFactoryOptions(commonOptions)
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2017-08-17 13:05:30 -07:00
|
|
|
|
FixedWidth = sideBarButtonWidth,
|
|
|
|
|
|
FixedHeight = shortButtonHeight,
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2017-10-31 11:43:25 -07:00
|
|
|
|
NormalTextColor = Color.Black,
|
|
|
|
|
|
NormalFillColor = Color.White,
|
2018-01-12 16:42:55 -08:00
|
|
|
|
NormalBorderColor = new Color(colors.PrimaryTextColor, 200),
|
2017-08-03 14:43:06 -07:00
|
|
|
|
|
2017-10-31 11:43:25 -07:00
|
|
|
|
HoverTextColor = Color.Black,
|
|
|
|
|
|
HoverFillColor = new Color(255, 255, 255, 200),
|
2018-01-12 16:42:55 -08:00
|
|
|
|
HoverBorderColor = new Color(colors.PrimaryTextColor, 200),
|
2017-08-03 12:40:10 -07:00
|
|
|
|
|
2017-08-17 13:05:30 -07:00
|
|
|
|
BorderWidth = 1,
|
|
|
|
|
|
});
|
2017-08-20 14:23:15 -07:00
|
|
|
|
#endregion
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2017-06-20 05:33:49 -07:00
|
|
|
|
this.LinkButtonFactory = new LinkButtonFactory()
|
2017-06-19 18:52:10 -07:00
|
|
|
|
{
|
2017-10-22 19:53:48 -07:00
|
|
|
|
fontSize = FontSize11,
|
2018-01-12 16:42:55 -08:00
|
|
|
|
textColor = colors.PrimaryTextColor
|
2017-06-19 18:52:10 -07:00
|
|
|
|
};
|
2017-11-21 11:11:07 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 09:26:39 -07:00
|
|
|
|
public Color GetBorderColor(int alpha)
|
|
|
|
|
|
{
|
2018-04-07 12:08:54 -07:00
|
|
|
|
return new Color(this.Colors.SecondaryTextColor, alpha);
|
2018-04-01 09:26:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-11-21 11:11:07 -08:00
|
|
|
|
// Compute a fixed color from a source and a target alpha
|
|
|
|
|
|
public Color ResolveColor(Color background, Color overlay)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new BlenderRGBA().Blend(background, overlay);
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-21 21:07:14 -08:00
|
|
|
|
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable<NamedAction> menuActions)
|
2017-08-12 00:23:26 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Create menu items in the DropList for each element in this.menuActions
|
2018-02-02 14:35:01 -08:00
|
|
|
|
popupMenu.CloseAllChildren();
|
2017-08-12 00:23:26 -07:00
|
|
|
|
foreach (var menuAction in menuActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (menuAction.Title == "----")
|
|
|
|
|
|
{
|
2017-11-10 13:12:02 -08:00
|
|
|
|
popupMenu.CreateHorizontalLine();
|
2017-08-12 00:23:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-01-03 15:24:55 -08:00
|
|
|
|
PopupMenu.MenuItem menuItem;
|
|
|
|
|
|
|
|
|
|
|
|
if (menuAction is NamedBoolAction boolAction)
|
|
|
|
|
|
{
|
|
|
|
|
|
menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-02-06 13:31:25 -08:00
|
|
|
|
menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut);
|
2018-01-03 15:24:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-12 00:23:26 -07:00
|
|
|
|
menuItem.Name = $"{menuAction.Title} Menu Item";
|
|
|
|
|
|
|
2017-11-29 13:50:25 -08:00
|
|
|
|
menuItem.Enabled = menuAction.Action != null
|
|
|
|
|
|
&& menuAction.IsEnabled?.Invoke() != false;
|
|
|
|
|
|
|
2017-11-10 13:12:02 -08:00
|
|
|
|
menuItem.ClearRemovedFlag();
|
2017-08-12 00:23:26 -07:00
|
|
|
|
|
2017-11-10 13:12:02 -08:00
|
|
|
|
if (menuItem.Enabled)
|
2017-08-12 00:23:26 -07:00
|
|
|
|
{
|
2017-11-10 13:12:02 -08:00
|
|
|
|
menuItem.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
menuAction.Action();
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2017-08-12 00:23:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-11-09 18:26:32 -08:00
|
|
|
|
return popupMenu;
|
2017-08-12 00:23:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-31 11:43:25 -07:00
|
|
|
|
private static ImageBuffer ColorCircle(int size, Color color)
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
|
|
|
|
|
ImageBuffer imageBuffer = new ImageBuffer(size, size);
|
|
|
|
|
|
Graphics2D normalGraphics = imageBuffer.NewGraphics2D();
|
|
|
|
|
|
Vector2 center = new Vector2(size / 2.0, size / 2.0);
|
2017-11-11 17:28:03 -08:00
|
|
|
|
|
|
|
|
|
|
Color barColor;
|
|
|
|
|
|
if (color != Color.Transparent)
|
|
|
|
|
|
{
|
|
|
|
|
|
normalGraphics.Circle(center, size / 2.0, color);
|
|
|
|
|
|
barColor = Color.White;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
barColor = new Color("#999");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
normalGraphics.Line(center + new Vector2(-size / 4.0, -size / 4.0), center + new Vector2(size / 4.0, size / 4.0), barColor, 2 * GuiWidget.DeviceScale);
|
|
|
|
|
|
normalGraphics.Line(center + new Vector2(-size / 4.0, size / 4.0), center + new Vector2(size / 4.0, -size / 4.0), barColor, 2 * GuiWidget.DeviceScale);
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
|
|
|
|
|
return imageBuffer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal Button CreateSmallResetButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Button(
|
|
|
|
|
|
new ButtonViewStates(
|
2018-02-12 15:28:26 -08:00
|
|
|
|
new ImageWidget(RestoreNormal),
|
|
|
|
|
|
new ImageWidget(RestoreHover),
|
2017-06-19 09:17:57 -07:00
|
|
|
|
new ImageWidget(restorePressed),
|
2018-02-12 15:28:26 -08:00
|
|
|
|
new ImageWidget(RestoreNormal)))
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2017-08-07 15:47:27 -07:00
|
|
|
|
VAnchor = VAnchor.Center,
|
2017-06-19 09:17:57 -07:00
|
|
|
|
Margin = new BorderDouble(0, 0, 5, 0)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2017-07-05 14:34:38 -07:00
|
|
|
|
|
2017-07-05 14:47:52 -07:00
|
|
|
|
public SolidSlider CreateSolidSlider(GuiWidget wordOptionContainer, string header, double min = 0, double max = .5)
|
2017-07-05 14:34:38 -07:00
|
|
|
|
{
|
|
|
|
|
|
double scrollBarWidth = 10;
|
|
|
|
|
|
|
2018-01-10 13:03:12 -08:00
|
|
|
|
wordOptionContainer.AddChild(new TextWidget(header, textColor: this.Colors.PrimaryTextColor)
|
2017-07-05 14:34:38 -07:00
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(10, 3, 3, 5),
|
2017-08-07 15:47:27 -07:00
|
|
|
|
HAnchor = HAnchor.Left
|
2017-10-21 10:48:01 -07:00
|
|
|
|
});
|
2017-07-05 14:34:38 -07:00
|
|
|
|
|
2017-10-21 10:48:01 -07:00
|
|
|
|
var namedSlider = new SolidSlider(new Vector2(), scrollBarWidth, 0, 1)
|
2017-07-05 14:34:38 -07:00
|
|
|
|
{
|
2018-04-10 07:35:22 -07:00
|
|
|
|
TotalWidthInPixels = defaultScrollBarWidth,
|
2017-07-05 14:34:38 -07:00
|
|
|
|
Minimum = min,
|
|
|
|
|
|
Maximum = max,
|
2017-10-21 10:48:01 -07:00
|
|
|
|
Margin = new BorderDouble(12, 4),
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
2017-07-05 14:34:38 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wordOptionContainer.AddChild(namedSlider);
|
|
|
|
|
|
|
|
|
|
|
|
return namedSlider;
|
|
|
|
|
|
}
|
2017-07-05 14:38:36 -07:00
|
|
|
|
|
2017-07-05 14:47:52 -07:00
|
|
|
|
public MenuItem CreateCheckboxMenuItem(string text, string itemValue, bool itemChecked, BorderDouble padding, EventHandler eventHandler)
|
2017-07-05 14:38:36 -07:00
|
|
|
|
{
|
|
|
|
|
|
var checkbox = new CheckBox(text)
|
|
|
|
|
|
{
|
|
|
|
|
|
Checked = itemChecked
|
|
|
|
|
|
};
|
|
|
|
|
|
checkbox.CheckedStateChanged += eventHandler;
|
|
|
|
|
|
|
|
|
|
|
|
return new MenuItem(checkbox, itemValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
Padding = padding,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
|
|
|
|
|
public static class ThemeExtensionMethods
|
|
|
|
|
|
{
|
|
|
|
|
|
public static SectionWidget ApplyBoxStyle(this SectionWidget sectionWidget)
|
|
|
|
|
|
{
|
2018-02-10 00:11:20 -08:00
|
|
|
|
return ApplyBoxStyle(sectionWidget, ApplicationController.Instance.Theme.MinimalShade, margin: new BorderDouble(10, 0, 10, 10));
|
2018-01-14 10:13:42 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-10 00:11:20 -08:00
|
|
|
|
public static SectionWidget ApplyBoxStyle(this SectionWidget sectionWidget, BorderDouble margin)
|
2018-02-09 22:51:18 -08:00
|
|
|
|
{
|
2018-02-10 00:11:20 -08:00
|
|
|
|
return ApplyBoxStyle(sectionWidget, ApplicationController.Instance.Theme.MinimalShade, margin);
|
2018-02-09 22:51:18 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-10 00:11:20 -08:00
|
|
|
|
public static SectionWidget ApplyBoxStyle(this SectionWidget sectionWidget, Color backgroundColor, BorderDouble margin)
|
2018-01-14 10:13:42 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Enforce panel padding
|
|
|
|
|
|
// sectionWidget.ContentPanel.Padding = new BorderDouble(10, 0, 10, 2);
|
|
|
|
|
|
//sectionWidget.ContentPanel.Padding = 0;
|
|
|
|
|
|
|
|
|
|
|
|
sectionWidget.SeperatorColor = Color.Transparent;
|
|
|
|
|
|
sectionWidget.BorderRadius = 5;
|
2018-02-10 00:11:20 -08:00
|
|
|
|
sectionWidget.Margin = margin;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
sectionWidget.BackgroundColor = backgroundColor;
|
|
|
|
|
|
|
|
|
|
|
|
return sectionWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|