<commit_before>﻿/*
Copyright (c) 2017, <NAME>, <NAME>
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
{
	using System.Collections.Generic;
	using Agg.Image;
	using CustomWidgets;
	using MatterHackers.Agg.Platform;
	using MatterHackers.MatterControl.PartPreviewWindow;
	using MatterHackers.VectorMath;

	public class ThemeConfig
	{
		protected static readonly int DefaultScrollBarWidth = 120;

		private static ImageBuffer restoreNormal;
		private static ImageBuffer restoreHover;
		private static ImageBuffer restorePressed;

		private readonly int fizedHeightA = (int)(25 * GuiWidget.DeviceScale + .5);
		private readonly double fizedHeightB = 34 * GuiWidget.DeviceScale;

		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;

		public int DefaultFontSize { get; } = 12;

		internal int shortButtonHeight = 25;
		private int sideBarButtonWidth;

		public int H1PointSize { get; set; } = 13;

		public LinkButtonFactory LinkButtonFactory { get; private set; }
		public LinkButtonFactory HelpLinkFactory { get; private set; }

		public TextImageButtonFactory ExpandMenuOptionFactory;
		public TextImageButtonFactory WhiteButtonFactory;

		private readonly int borderWidth = 1;

		public TextImageButtonFactory ButtonFactory { get; private set; }
		public TextImageButtonFactory SmallMarginButtonFactory { get; private set; }
		public TextImageButtonFactory RadioButtons { get; private set; }
		public TextImageButtonFactory WizardButtons { get; private set; }

		/// <summary>
		/// Used to make buttons in menu rows where the background color is consistently white
		/// </summary>
		public TextImageButtonFactory MenuButtonFactory { get; private set; }

		/// <summary>
		/// Used in the Update wizard to show high contrast, primary action buttons
		/// </summary>
		public TextImageButtonFactory GrayButtonFactory { get; private set; }

		public TextImageButtonFactory imageConverterExpandMenuOptionFactory;

		public TextImageButtonFactory imageConverterButtonFactory;

		public Color TabBodyBackground => new Color(ActiveTheme.Instance.TertiaryBackgroundColor, 175);

		public TextImageButtonFactory ViewControlsButtonFactory { get; private set; }

		public Color SplitterBackground { get; private set; } = new Color(0, 0, 0, 60);

		public int SplitterWidth => (int)(6 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4));

		public Color SlightShade { get; } = new Color(0, 0, 0, 40);
		public Color MinimalShade { get; } = new Color(0, 0, 0, 15);
		public Color Shade { get; } = new Color(0, 0, 0, 120);
		public Color DarkShade { get; } = new Color(0, 0, 0, 190);

		public Color ActiveTabColor { get; set; }
		public Color InactiveTabColor { get; set; }

		public TextImageButtonFactory DisableableControlBase { get; private set; }
		public TextImageButtonFactory HomingButtons { get; private set; }
		public TextImageButtonFactory MicroButton { get; private set; }
		public TextImageButtonFactory MicroButtonMenu { get; private set; }

		public BorderDouble ButtonSpacing { get; set; } = new BorderDouble(3, 0, 0, 0);
		public TextImageButtonFactory NoMarginWhite { get; private set; }
		public BorderDouble ToolbarPadding { get; set; } = 3;
		public double ButtonHeight { get; internal set; } = 32;

		public int OverlayAlpha { get; set; } = 50;

		public Color InteractionLayerOverlayColor { get; private set; }

		private EventHandler unregisterEvents;

		static ThemeConfig()
		{
			// EnsureRestoreButtonImages
			int size = (int)(16 * GuiWidget.DeviceScale);

			if (AggContext.OperatingSystem == OSType.Android)
			{
				restoreNormal = ColorCircle(size, new Color(200, 0, 0));
			}
			else
			{
				restoreNormal = ColorCircle(size, Color.Transparent);
			}
			restoreHover = ColorCircle(size, new Color("#DB4437"));
			restorePressed = ColorCircle(size, new Color(255, 0, 0));
		}

		public ThemeConfig()
		{
			ActiveTheme.ThemeChanged.RegisterEvent((s, e) => RebuildTheme(), ref unregisterEvents);
			RebuildTheme();
		}

		public void RebuildTheme()
		{
			var theme = ActiveTheme.Instance;

			DefaultThumbView.ThumbColor = new Color(theme.PrimaryTextColor, 30);

			var commonOptions = new ButtonFactoryOptions();
			commonOptions.NormalTextColor = theme.PrimaryTextColor;
			commonOptions.HoverTextColor = theme.PrimaryTextColor;
			commonOptions.PressedTextColor = theme.PrimaryTextColor;
			commonOptions.DisabledTextColor = theme.TertiaryBackgroundColor;
			commonOptions.Margin = new BorderDouble(14, 0);
			commonOptions.FontSize = 11;
			commonOptions.ImageSpacing = 8;
			commonOptions.BorderWidth = 0;
			commonOptions.FixedHeight = 32;

			this.ActiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.Black, this.SlightShade.alpha));

			// Active tab color with slight transparency
			this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 200);

			float alpha0to1 = (ActiveTheme.Instance.IsDarkTheme ? 20 : 60) / 255.0f;

			this.InactiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.White, this.SlightShade.alpha));

			this.SplitterBackground = this.ActiveTabColor;

			this.ButtonFactory = new TextImageButtonFactory(commonOptions);
<commit_msg>Increase SplitterBar contrast<commit_after>﻿/*
Copyright (c) 2017, <NAME>, <NAME>
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
{
	using System.Collections.Generic;
	using Agg.Image;
	using CustomWidgets;
	using MatterHackers.Agg.Platform;
	using MatterHackers.MatterControl.PartPreviewWindow;
	using MatterHackers.VectorMath;

	public class ThemeConfig
	{
		protected static readonly int DefaultScrollBarWidth = 120;

		private static ImageBuffer restoreNormal;
		private static ImageBuffer restoreHover;
		private static ImageBuffer restorePressed;

		private readonly int fizedHeightA = (int)(25 * GuiWidget.DeviceScale + .5);
		private readonly double fizedHeightB = 34 * GuiWidget.DeviceScale;

		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;

		public int DefaultFontSize { get; } = 12;

		internal int shortButtonHeight = 25;
		private int sideBarButtonWidth;

		public int H1PointSize { get; set; } = 13;

		public LinkButtonFactory LinkButtonFactory { get; private set; }
		public LinkButtonFactory HelpLinkFactory { get; private set; }

		public TextImageButtonFactory ExpandMenuOptionFactory;
		public TextImageButtonFactory WhiteButtonFactory;

		private readonly int borderWidth = 1;

		public TextImageButtonFactory ButtonFactory { get; private set; }
		public TextImageButtonFactory SmallMarginButtonFactory { get; private set; }
		public TextImageButtonFactory RadioButtons { get; private set; }
		public TextImageButtonFactory WizardButtons { get; private set; }

		/// <summary>
		/// Used to make buttons in menu rows where the background color is consistently white
		/// </summary>
		public TextImageButtonFactory MenuButtonFactory { get; private set; }

		/// <summary>
		/// Used in the Update wizard to show high contrast, primary action buttons
		/// </summary>
		public TextImageButtonFactory GrayButtonFactory { get; private set; }

		public TextImageButtonFactory imageConverterExpandMenuOptionFactory;

		public TextImageButtonFactory imageConverterButtonFactory;

		public Color TabBodyBackground => new Color(ActiveTheme.Instance.TertiaryBackgroundColor, 175);

		public TextImageButtonFactory ViewControlsButtonFactory { get; private set; }

		public Color SplitterBackground { get; private set; } = new Color(0, 0, 0, 60);

		public int SplitterWidth => (int)(6 * (GuiWidget.DeviceScale <= 1 ? GuiWidget.DeviceScale : GuiWidget.DeviceScale * 1.4));

		public Color SlightShade { get; } = new Color(0, 0, 0, 40);
		public Color MinimalShade { get; } = new Color(0, 0, 0, 15);
		public Color Shade { get; } = new Color(0, 0, 0, 120);
		public Color DarkShade { get; } = new Color(0, 0, 0, 190);

		public Color ActiveTabColor { get; set; }
		public Color InactiveTabColor { get; set; }

		public TextImageButtonFactory DisableableControlBase { get; private set; }
		public TextImageButtonFactory HomingButtons { get; private set; }
		public TextImageButtonFactory MicroButton { get; private set; }
		public TextImageButtonFactory MicroButtonMenu { get; private set; }

		public BorderDouble ButtonSpacing { get; set; } = new BorderDouble(3, 0, 0, 0);
		public TextImageButtonFactory NoMarginWhite { get; private set; }
		public BorderDouble ToolbarPadding { get; set; } = 3;
		public double ButtonHeight { get; internal set; } = 32;

		public int OverlayAlpha { get; set; } = 50;

		public Color InteractionLayerOverlayColor { get; private set; }

		private EventHandler unregisterEvents;

		static ThemeConfig()
		{
			// EnsureRestoreButtonImages
			int size = (int)(16 * GuiWidget.DeviceScale);

			if (AggContext.OperatingSystem == OSType.Android)
			{
				restoreNormal = ColorCircle(size, new Color(200, 0, 0));
			}
			else
			{
				restoreNormal = ColorCircle(size, Color.Transparent);
			}
			restoreHover = ColorCircle(size, new Color("#DB4437"));
			restorePressed = ColorCircle(size, new Color(255, 0, 0));
		}

		public ThemeConfig()
		{
			ActiveTheme.ThemeChanged.RegisterEvent((s, e) => RebuildTheme(), ref unregisterEvents);
			RebuildTheme();
		}

		public void RebuildTheme()
		{
			var theme = ActiveTheme.Instance;

			DefaultThumbView.ThumbColor = new Color(theme.PrimaryTextColor, 30);

			var commonOptions = new ButtonFactoryOptions();
			commonOptions.NormalTextColor = theme.PrimaryTextColor;
			commonOptions.HoverTextColor = theme.PrimaryTextColor;
			commonOptions.PressedTextColor = theme.PrimaryTextColor;
			commonOptions.DisabledTextColor = theme.TertiaryBackgroundColor;
			commonOptions.Margin = new BorderDouble(14, 0);
			commonOptions.FontSize = 11;
			commonOptions.ImageSpacing = 8;
			commonOptions.BorderWidth = 0;
			commonOptions.FixedHeight = 32;

			this.ActiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.Black, this.SlightShade.alpha));

			// Active tab color with slight transparency
			this.InteractionLayerOverlayColor = new Color(this.ActiveTabColor, 200);

			float alpha0to1 = (ActiveTheme.Instance.IsDarkTheme ? 20 : 60) / 255.0f;

			this.InactiveTabColor = ResolveColor(theme.PrimaryBackgroundColor, new Color(Color.White, this.SlightShade.alpha));

			this.SplitterBackground = this.ActiveTabColor.AdjustLightness(0.87).ToColor();

			this.ButtonFactory = new TextImageButtonFactory(commonOptions);

{'fraction_non_alphanumeric': 0.07800751879699248, 'fraction_numerical': 0.01829091960670908, 'mean_word_length': 4.711395540875309, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1052620', 'n_tokens_mistral': 4396, 'n_tokens_neox': 3730, 'n_words': 1346}