2017-06-19 09:17:57 -07:00
|
|
|
|
/*
|
2018-07-12 08:17:50 -07:00
|
|
|
|
Copyright (c) 2018, Lars Brubaker, John Lewin
|
2017-06-19 09:17:57 -07:00
|
|
|
|
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;
|
2018-04-15 11:30:03 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2017-06-19 09:17:57 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
public class ThemeConfig
|
|
|
|
|
|
{
|
2018-07-12 08:17:50 -07:00
|
|
|
|
private static ImageBuffer restoreNormal;
|
|
|
|
|
|
private static ImageBuffer restoreHover;
|
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;
|
2018-04-14 13:01:16 -07:00
|
|
|
|
public int FontSize8 { get; } = 8;
|
2017-10-22 19:53:48 -07:00
|
|
|
|
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-07-12 08:17:50 -07:00
|
|
|
|
public int DefaultFontSize { get; set; } = 11;
|
2018-04-14 21:11:37 -07:00
|
|
|
|
public int DefaultContainerPadding { get; } = 10;
|
2018-07-12 08:17:50 -07:00
|
|
|
|
public int H1PointSize { get; } = 11;
|
2018-04-26 07:56:29 -07:00
|
|
|
|
|
|
|
|
|
|
public double ButtonHeight => 32 * GuiWidget.DeviceScale;
|
|
|
|
|
|
public double TabButtonHeight => 30 * GuiWidget.DeviceScale;
|
|
|
|
|
|
public double MenuGutterWidth => 35 * GuiWidget.DeviceScale;
|
2017-08-06 20:55:00 -07:00
|
|
|
|
|
2018-07-12 08:17:50 -07:00
|
|
|
|
private double microButtonHeight => 20 * GuiWidget.DeviceScale;
|
|
|
|
|
|
private double microButtonWidth => 30 * GuiWidget.DeviceScale;
|
|
|
|
|
|
private readonly int defaultScrollBarWidth = 120;
|
|
|
|
|
|
|
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>
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public bool InvertIcons => this?.Colors.IsDarkTheme ?? false;
|
2018-04-12 08:42:10 -07:00
|
|
|
|
|
2018-06-24 10:34:29 -07:00
|
|
|
|
internal void ApplyPrimaryActionStyle(GuiWidget guiWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
guiWidget.BackgroundColor = this.AccentMimimalOverlay;
|
|
|
|
|
|
|
2018-06-24 11:29:18 -07:00
|
|
|
|
Color hoverColor = new Color(this.AccentMimimalOverlay, 90);
|
|
|
|
|
|
|
|
|
|
|
|
switch (guiWidget)
|
2018-06-24 10:34:29 -07:00
|
|
|
|
{
|
2018-06-24 10:59:51 -07:00
|
|
|
|
case PopupMenuButton menuButton:
|
2018-06-24 11:29:18 -07:00
|
|
|
|
menuButton.HoverColor = hoverColor;
|
2018-06-24 10:59:51 -07:00
|
|
|
|
break;
|
2018-06-24 10:34:29 -07:00
|
|
|
|
case SimpleFlowButton flowButton:
|
2018-06-24 11:29:18 -07:00
|
|
|
|
flowButton.HoverColor = hoverColor;
|
2018-06-24 10:34:29 -07:00
|
|
|
|
break;
|
|
|
|
|
|
case SimpleButton button:
|
2018-06-24 11:29:18 -07:00
|
|
|
|
button.HoverColor = hoverColor;
|
2018-06-24 10:34:29 -07:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-24 10:59:51 -07:00
|
|
|
|
internal void RemovePrimaryActionStyle(GuiWidget guiWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
guiWidget.BackgroundColor = Color.Transparent;
|
|
|
|
|
|
|
|
|
|
|
|
switch (guiWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
case PopupMenuButton menuButton:
|
|
|
|
|
|
menuButton.HoverColor = Color.Transparent;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case SimpleFlowButton flowButton:
|
|
|
|
|
|
flowButton.HoverColor = Color.Transparent;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case SimpleButton button:
|
|
|
|
|
|
button.HoverColor = Color.Transparent;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-25 08:16:17 -07:00
|
|
|
|
public BorderDouble TextButtonPadding { get; } = new BorderDouble(14, 0);
|
|
|
|
|
|
|
2018-07-12 08:17:50 -07:00
|
|
|
|
public BorderDouble ButtonSpacing { get; } = new BorderDouble(right: 3);
|
2018-05-17 12:41:32 -07:00
|
|
|
|
|
2018-07-12 08:17:50 -07:00
|
|
|
|
public BorderDouble ToolbarPadding { get; } = 3;
|
2017-06-19 18:52:10 -07:00
|
|
|
|
|
2018-07-12 08:17:50 -07:00
|
|
|
|
public BorderDouble TabbarPadding { get; } = new BorderDouble(3, 1);
|
2018-05-17 17:12:12 -07:00
|
|
|
|
|
2018-05-21 16:43:13 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The height or width of a given vertical or horizontal splitter bar
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int SplitterWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
double splitterSize = 6 * GuiWidget.DeviceScale;
|
|
|
|
|
|
|
|
|
|
|
|
if (GuiWidget.TouchScreenMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
splitterSize *= 1.4;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (int)splitterSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public ThemeColors Colors { get; set; } = new ThemeColors();
|
2018-04-16 20:31:46 -07:00
|
|
|
|
public PresetColors PresetColors { get; set; } = new PresetColors();
|
2018-01-10 13:03:12 -08:00
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public Color SlightShade { get; set; }
|
|
|
|
|
|
public Color MinimalShade { get; set; }
|
|
|
|
|
|
public Color Shade { get; set; }
|
|
|
|
|
|
public Color DarkShade { get; set; }
|
2018-09-08 10:53:51 -07:00
|
|
|
|
|
2017-11-21 11:11:07 -08:00
|
|
|
|
public Color ActiveTabColor { get; set; }
|
2018-05-08 17:23:55 -07:00
|
|
|
|
public Color TabBarBackground { get; set; }
|
2018-04-10 07:35:22 -07:00
|
|
|
|
public Color InactiveTabColor { get; set; }
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public Color InteractionLayerOverlayColor { get; set; }
|
2018-04-17 17:13:18 -07:00
|
|
|
|
|
|
|
|
|
|
public TextWidget CreateHeading(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new TextWidget(text, pointSize: this.H1PointSize, textColor: this.Colors.PrimaryTextColor, bold: true)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(0, 5)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public Color SplitterBackground { get; set; } = new Color(0, 0, 0, 60);
|
|
|
|
|
|
public Color TabBodyBackground { get; set; }
|
2018-04-10 07:35:22 -07:00
|
|
|
|
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-04-17 09:04:56 -07:00
|
|
|
|
public Color ThumbnailBackground { get; set; }
|
|
|
|
|
|
public Color AccentMimimalOverlay { get; set; }
|
2018-05-17 12:41:32 -07:00
|
|
|
|
public BorderDouble SeparatorMargin { get; }
|
2018-04-17 09:04:56 -07:00
|
|
|
|
|
2018-06-26 08:40:28 -07:00
|
|
|
|
public ImageBuffer GeneratingThumbnailIcon { get; private set; }
|
|
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public Color LightTextColor { get; set; }
|
|
|
|
|
|
public Color BorderColor { get; set; }
|
|
|
|
|
|
public Color DisabledColor { get; set; }
|
|
|
|
|
|
public Color SplashAccentColor { get; set; }
|
|
|
|
|
|
|
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(),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-26 07:56:29 -07:00
|
|
|
|
public ThemeConfig()
|
|
|
|
|
|
{
|
2018-05-17 12:41:32 -07:00
|
|
|
|
this.SeparatorMargin = (this.ButtonSpacing * 2).Clone(left: this.ButtonSpacing.Right);
|
2018-10-13 17:58:54 -07:00
|
|
|
|
this.RebuildTheme();
|
2018-04-26 07:56:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public void SetDefaults()
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
2018-10-13 17:58:54 -07:00
|
|
|
|
this.DisabledColor = new Color(this.LightTextColor, 50);
|
|
|
|
|
|
this.SplashAccentColor = new Color(this.Colors.PrimaryAccentColor, 185).OverlayOn(Color.White).ToColor();
|
|
|
|
|
|
}
|
2017-06-19 09:17:57 -07:00
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
public void RebuildTheme()
|
|
|
|
|
|
{
|
|
|
|
|
|
int size = (int)(16 * GuiWidget.DeviceScale);
|
2018-04-26 07:56:29 -07:00
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
// On Android, use red icon as no hover events, otherwise transparent and red on hover
|
|
|
|
|
|
restoreNormal = ColorCircle(size, (AggContext.OperatingSystem == OSType.Android) ? new Color(200, 0, 0) : Color.Transparent);
|
2018-07-12 08:17:50 -07: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
|
|
|
|
|
2018-06-26 08:40:28 -07:00
|
|
|
|
this.GeneratingThumbnailIcon = AggContext.StaticData.LoadIcon("building_thumbnail_40x40.png", 40, 40, this.InvertIcons);
|
|
|
|
|
|
|
2018-10-13 17:58:54 -07:00
|
|
|
|
DefaultThumbView.ThumbColor = new Color(this.Colors.PrimaryTextColor, 30);
|
2017-11-21 11:11:07 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-15 11:30:03 -07:00
|
|
|
|
public JogControls.MoveButton CreateMoveButton(PrinterConfig printer, string label, PrinterConnection.Axis axis, double movementFeedRate, bool levelingButtons = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new JogControls.MoveButton(label, printer, axis, movementFeedRate, this)
|
|
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = this.MinimalShade,
|
|
|
|
|
|
Border = 1,
|
|
|
|
|
|
BorderColor = this.GetBorderColor(40),
|
|
|
|
|
|
VAnchor = VAnchor.Absolute,
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
|
|
|
|
|
Margin = 0,
|
|
|
|
|
|
Padding = 0,
|
|
|
|
|
|
Height = (levelingButtons ? 45 : 40) * GuiWidget.DeviceScale,
|
|
|
|
|
|
Width = (levelingButtons ? 90 : 40) * GuiWidget.DeviceScale,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JogControls.ExtrudeButton CreateExtrudeButton(PrinterConfig printer, string label, double movementFeedRate, int extruderNumber, bool levelingButtons = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new JogControls.ExtrudeButton(printer, label, movementFeedRate, extruderNumber, this)
|
|
|
|
|
|
{
|
|
|
|
|
|
BackgroundColor = this.MinimalShade,
|
|
|
|
|
|
Border = 1,
|
|
|
|
|
|
BorderColor = this.GetBorderColor(40),
|
|
|
|
|
|
VAnchor = VAnchor.Absolute,
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
|
|
|
|
|
Margin = 0,
|
|
|
|
|
|
Padding = 0,
|
|
|
|
|
|
Height = (levelingButtons ? 45 : 40) * GuiWidget.DeviceScale,
|
|
|
|
|
|
Width = (levelingButtons ? 90 : 40) * GuiWidget.DeviceScale,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 13:01:16 -07:00
|
|
|
|
public RadioTextButton CreateMicroRadioButton(string text, IList<GuiWidget> siblingRadioButtonList = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var radioButton = new RadioTextButton(text, this, this.FontSize8)
|
|
|
|
|
|
{
|
|
|
|
|
|
SiblingRadioButtonList = siblingRadioButtonList,
|
|
|
|
|
|
Padding = new BorderDouble(5, 0),
|
|
|
|
|
|
SelectedBackgroundColor = this.SlightShade,
|
|
|
|
|
|
UnselectedBackgroundColor = this.SlightShade,
|
2018-04-17 09:04:56 -07:00
|
|
|
|
HoverColor = this.AccentMimimalOverlay,
|
2018-04-14 13:01:16 -07:00
|
|
|
|
Margin = new BorderDouble(right: 1),
|
|
|
|
|
|
HAnchor = HAnchor.Absolute,
|
2018-07-12 08:17:50 -07:00
|
|
|
|
Height = this.microButtonHeight,
|
|
|
|
|
|
Width = this.microButtonWidth
|
2018-04-14 13:01:16 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Add to sibling list if supplied
|
|
|
|
|
|
siblingRadioButtonList?.Add(radioButton);
|
|
|
|
|
|
|
|
|
|
|
|
return radioButton;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-11 15:08:07 -07:00
|
|
|
|
public TextButton CreateLightDialogButton(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CreateDialogButton(text, new Color(Color.White, 15), new Color(Color.White, 25));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 20:51:01 -07:00
|
|
|
|
public TextButton CreateDialogButton(string text)
|
|
|
|
|
|
{
|
2018-07-11 15:08:07 -07:00
|
|
|
|
return CreateDialogButton(text, this.MinimalShade, this.SlightShade);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TextButton CreateDialogButton(string text, Color backgroundColor, Color hoverColor)
|
|
|
|
|
|
{
|
2018-04-14 22:01:29 -07:00
|
|
|
|
#if !__ANDROID__
|
|
|
|
|
|
return new TextButton(text, this)
|
|
|
|
|
|
{
|
2018-07-11 15:08:07 -07:00
|
|
|
|
BackgroundColor = backgroundColor,
|
|
|
|
|
|
HoverColor = hoverColor
|
2018-04-14 22:01:29 -07:00
|
|
|
|
};
|
|
|
|
|
|
#else
|
|
|
|
|
|
var button = new TextButton(text, this, this.FontSize14)
|
2018-04-14 20:51:01 -07:00
|
|
|
|
{
|
2018-07-11 15:08:07 -07:00
|
|
|
|
BackgroundColor = backgroundColor,
|
|
|
|
|
|
HoverColor = hoverColor,
|
2018-04-14 20:51:01 -07:00
|
|
|
|
// Enlarge button height and margin on Android
|
|
|
|
|
|
Height = 34 * GuiWidget.DeviceScale,
|
|
|
|
|
|
};
|
2018-04-14 22:01:29 -07:00
|
|
|
|
button.Padding = button.Padding * 1.2;
|
2018-04-14 20:51:01 -07:00
|
|
|
|
|
|
|
|
|
|
return button;
|
2018-04-14 22:01:29 -07:00
|
|
|
|
#endif
|
2018-04-14 20:51:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 09:26:39 -07:00
|
|
|
|
public Color GetBorderColor(int alpha)
|
|
|
|
|
|
{
|
2018-10-13 17:58:54 -07:00
|
|
|
|
return new Color(this.BorderColor, 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)
|
|
|
|
|
|
{
|
2018-06-24 17:19:22 -07:00
|
|
|
|
return new BlenderBGRA().Blend(background, overlay);
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-08 07:11:43 -07:00
|
|
|
|
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable<NamedAction> menuActions, bool emptyMenu = true)
|
2017-08-12 00:23:26 -07:00
|
|
|
|
{
|
2018-08-08 07:11:43 -07:00
|
|
|
|
// Retain past behavior, where menu is cleared each call. More recent callers many pass in a newly populated menu and
|
|
|
|
|
|
// not require the clear
|
|
|
|
|
|
if (emptyMenu)
|
|
|
|
|
|
{
|
|
|
|
|
|
popupMenu.CloseAllChildren();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-12 00:23:26 -07:00
|
|
|
|
// Create menu items in the DropList for each element in this.menuActions
|
|
|
|
|
|
foreach (var menuAction in menuActions)
|
|
|
|
|
|
{
|
2018-08-08 07:03:37 -07:00
|
|
|
|
if (menuAction is ActionSeparator)
|
2017-08-12 00:23:26 -07:00
|
|
|
|
{
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-01 15:05:39 -07:00
|
|
|
|
public Button CreateSmallResetButton()
|
2017-06-19 09:17:57 -07:00
|
|
|
|
{
|
|
|
|
|
|
return new Button(
|
|
|
|
|
|
new ButtonViewStates(
|
2018-07-12 08:17:50 -07:00
|
|
|
|
new ImageWidget(restoreNormal),
|
|
|
|
|
|
new ImageWidget(restoreHover),
|
2017-06-19 09:17:57 -07:00
|
|
|
|
new ImageWidget(restorePressed),
|
2018-07-12 08:17:50 -07: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,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2018-01-14 10:13:42 -08:00
|
|
|
|
|
2018-07-15 10:07:30 -07:00
|
|
|
|
public void ApplyBottomBorder(GuiWidget widget, bool shadedBorder = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
widget.BorderColor = shadedBorder ? this.MinimalShade : this.GetBorderColor(20);
|
|
|
|
|
|
|
|
|
|
|
|
this.ApplyBorder(widget, new BorderDouble(bottom: 1), shadedBorder);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ApplyBorder(GuiWidget widget, BorderDouble border, bool shadedBorder = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
widget.BorderColor = shadedBorder ? this.MinimalShade : this.GetBorderColor(20);
|
|
|
|
|
|
widget.Border = border;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 20:52:35 -07:00
|
|
|
|
public SectionWidget ApplyBoxStyle(SectionWidget sectionWidget)
|
2018-01-14 10:13:42 -08:00
|
|
|
|
{
|
2018-04-14 20:52:35 -07:00
|
|
|
|
return ApplyBoxStyle(
|
|
|
|
|
|
sectionWidget,
|
|
|
|
|
|
this.MinimalShade,
|
|
|
|
|
|
margin: new BorderDouble(this.DefaultContainerPadding, 0, this.DefaultContainerPadding, this.DefaultContainerPadding));
|
2018-01-14 10:13:42 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 20:52:35 -07:00
|
|
|
|
public SectionWidget ApplyBoxStyle(SectionWidget sectionWidget, BorderDouble margin)
|
2018-02-09 22:51:18 -08:00
|
|
|
|
{
|
2018-04-14 20:52:35 -07:00
|
|
|
|
return ApplyBoxStyle(sectionWidget, this.MinimalShade, margin);
|
2018-02-09 22:51:18 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-14 20:52:35 -07:00
|
|
|
|
public SectionWidget ApplyBoxStyle(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;
|
|
|
|
|
|
|
2018-04-12 21:20:31 -07:00
|
|
|
|
sectionWidget.BorderColor = Color.Transparent;
|
2018-01-14 10:13:42 -08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-16 20:31:46 -07:00
|
|
|
|
|
|
|
|
|
|
public class PresetColors
|
|
|
|
|
|
{
|
|
|
|
|
|
public Color MaterialPreset { get; set; } = Color.Orange;
|
|
|
|
|
|
public Color QualityPreset { get; set; } = Color.Yellow;
|
|
|
|
|
|
public Color UserOverride { get; set; } = new Color(68, 95, 220, 150);
|
|
|
|
|
|
}
|
2017-06-19 09:17:57 -07:00
|
|
|
|
}
|