Refactoring UI 'Options' position and content
Made an Options menu Made language apply on select Made touchscreen a toggle
This commit is contained in:
parent
3cd0cc1374
commit
ba7f2aec80
8 changed files with 47 additions and 80 deletions
|
|
@ -100,14 +100,6 @@ namespace MatterHackers.MatterControl
|
|||
ActiveTheme.Instance.TabLabelUnselected,
|
||||
new RGBA_Bytes()));
|
||||
|
||||
|
||||
newTabControl.AddTab(
|
||||
new SimpleTextTabWidget(
|
||||
new TabPage(new PrinterConfigurationScrollWidget(), "Options".Localize().ToUpper()),
|
||||
"Options Tab",
|
||||
newTabControl.TextPointSize,
|
||||
ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()));
|
||||
|
||||
newTabControl.SelectedTabIndex = ApplicationController.Instance.ActiveAdvancedControlsTab;
|
||||
|
||||
return newTabControl;
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ namespace MatterHackers.MatterControl
|
|||
// put in the file menu
|
||||
this.AddChild(new MenuOptionFile());
|
||||
|
||||
this.AddChild(new MenuOptionSettings());
|
||||
|
||||
// put in the action menu
|
||||
if (ActiveSliceSettings.Instance?.ActionMacros().Any() == true)
|
||||
{
|
||||
|
|
@ -77,6 +75,8 @@ namespace MatterHackers.MatterControl
|
|||
// put in the help menu
|
||||
this.AddChild(new MenuOptionHelp());
|
||||
|
||||
this.AddChild(new MenuOptionSettings());
|
||||
|
||||
//linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||
linkButtonFactory.fontSize = 10;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,24 +9,27 @@ using MatterHackers.VectorMath;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class MenuOptionSettings : MenuBase
|
||||
|
||||
public class MenuOptionSettings : PopupButton
|
||||
{
|
||||
static public PopOutTextTabWidget sliceSettingsPopOut = null;
|
||||
|
||||
public MenuOptionSettings() : base("View".Localize())
|
||||
public MenuOptionSettings()
|
||||
: base(new TextWidget("Options".Localize().ToUpper(), 0, 0, 10, textColor: ActiveTheme.Instance.PrimaryTextColor))
|
||||
{
|
||||
}
|
||||
Margin = new BorderDouble(0);
|
||||
Padding = new BorderDouble(4);
|
||||
VAnchor = VAnchor.ParentCenter;
|
||||
OpenOffset = new Vector2(-3, -5);
|
||||
|
||||
protected override IEnumerable<MenuItemAction> GetMenuActions()
|
||||
{
|
||||
return new List<MenuItemAction>
|
||||
var container = new GuiWidget(640, 600)
|
||||
{
|
||||
new MenuItemAction("Settings".Localize(), () => sliceSettingsPopOut?.ShowInWindow()),
|
||||
new MenuItemAction("Terminal".Localize(), () => UiThread.RunOnIdle(TerminalWindow.Show)),
|
||||
BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor,
|
||||
};
|
||||
container.AddChild(new PrinterConfigurationScrollWidget());
|
||||
this.PopupContent = container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -256,27 +256,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
buttonRow.HAnchor = HAnchor.ParentLeftRight;
|
||||
buttonRow.Margin = new BorderDouble(top: 4);
|
||||
|
||||
TextWidget settingsLabel = new TextWidget("Display Mode".Localize());
|
||||
TextWidget settingsLabel = new TextWidget("Touch Screen Mode".Localize());
|
||||
settingsLabel.AutoExpandBoundsToText = true;
|
||||
settingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
settingsLabel.VAnchor = VAnchor.ParentTop;
|
||||
|
||||
Button displayControlRestartButton = textImageButtonFactory.Generate("Restart".Localize());
|
||||
displayControlRestartButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
displayControlRestartButton.Visible = false;
|
||||
displayControlRestartButton.Margin = new BorderDouble(right: 6);
|
||||
displayControlRestartButton.Click += (s, e) =>
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(null, cannotRestartWhilePrintIsActiveMessage, cannotRestartWhileActive);
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartApplication();
|
||||
}
|
||||
};
|
||||
|
||||
FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
optionsContainer.Margin = new BorderDouble(bottom: 6);
|
||||
|
||||
|
|
@ -286,32 +270,29 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
optionsContainer.AddChild(interfaceOptionsDropList);
|
||||
optionsContainer.Width = 200;
|
||||
|
||||
interfaceOptionsDropList.AddItem("Normal".Localize(), "responsive");
|
||||
interfaceOptionsDropList.AddItem("Touchscreen".Localize(), "touchscreen");
|
||||
|
||||
List<string> acceptableUpdateFeedTypeValues = new List<string>() { "responsive", "touchscreen" };
|
||||
string currentDisplayModeType = UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode);
|
||||
|
||||
if (acceptableUpdateFeedTypeValues.IndexOf(currentDisplayModeType) == -1)
|
||||
CheckBox touchScreenModeSwitch = ImageButtonFactory.CreateToggleSwitch(currentDisplayModeType == acceptableUpdateFeedTypeValues[1]);
|
||||
touchScreenModeSwitch.VAnchor = VAnchor.ParentCenter;
|
||||
touchScreenModeSwitch.CheckedStateChanged += (sender, e) =>
|
||||
{
|
||||
UserSettings.Instance.set(UserSettingsKey.ApplicationDisplayMode, "responsive");
|
||||
}
|
||||
|
||||
interfaceOptionsDropList.SelectedValue = UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode);
|
||||
interfaceOptionsDropList.SelectionChanged += (s, e) =>
|
||||
{
|
||||
string displayMode = ((DropDownList)s).SelectedValue;
|
||||
string displayMode = acceptableUpdateFeedTypeValues[0];
|
||||
if(touchScreenModeSwitch.Checked)
|
||||
{
|
||||
displayMode = acceptableUpdateFeedTypeValues[1];
|
||||
}
|
||||
if (displayMode != UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode))
|
||||
{
|
||||
UserSettings.Instance.set(UserSettingsKey.ApplicationDisplayMode, displayMode);
|
||||
displayControlRestartButton.Visible = true;
|
||||
ApplicationController.Instance.ReloadAll();
|
||||
}
|
||||
};
|
||||
|
||||
buttonRow.AddChild(settingsLabel);
|
||||
buttonRow.AddChild(new HorizontalSpacer());
|
||||
buttonRow.AddChild(displayControlRestartButton);
|
||||
buttonRow.AddChild(optionsContainer);
|
||||
buttonRow.AddChild(touchScreenModeSwitch);
|
||||
|
||||
return buttonRow;
|
||||
}
|
||||
|
||||
|
|
@ -433,38 +414,26 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
FlowLayoutWidget optionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
optionsContainer.Margin = new BorderDouble(bottom: 6);
|
||||
|
||||
Button languageRestartButton = textImageButtonFactory.Generate("Apply".Localize());
|
||||
languageRestartButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
languageRestartButton.Visible = false;
|
||||
languageRestartButton.Margin = new BorderDouble(right: 6);
|
||||
|
||||
languageRestartButton.Click += (sender, e) =>
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(null, cannotRestartWhilePrintIsActiveMessage, cannotRestartWhileActive);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalizedString.ResetTranslationMap();
|
||||
ApplicationController.Instance.ReloadAll();
|
||||
}
|
||||
};
|
||||
|
||||
LanguageSelector languageSelector = new LanguageSelector();
|
||||
languageSelector.SelectionChanged += (s, e) =>
|
||||
{
|
||||
string languageCode = languageSelector.SelectedValue;
|
||||
if (languageCode != UserSettings.Instance.get("Language"))
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
UserSettings.Instance.set("Language", languageCode);
|
||||
languageRestartButton.Visible = true;
|
||||
|
||||
if (languageCode == "L10N")
|
||||
string languageCode = languageSelector.SelectedValue;
|
||||
if (languageCode != UserSettings.Instance.get("Language"))
|
||||
{
|
||||
GenerateLocalizationValidationFile();
|
||||
UserSettings.Instance.set("Language", languageCode);
|
||||
|
||||
if (languageCode == "L10N")
|
||||
{
|
||||
GenerateLocalizationValidationFile();
|
||||
}
|
||||
|
||||
LocalizedString.ResetTranslationMap();
|
||||
ApplicationController.Instance.ReloadAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
languageSelector.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
|
@ -474,7 +443,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
|
||||
buttonRow.AddChild(settingsLabel);
|
||||
buttonRow.AddChild(new HorizontalSpacer());
|
||||
buttonRow.AddChild(languageRestartButton);
|
||||
buttonRow.AddChild(optionsContainer);
|
||||
return buttonRow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class PrinterConfigurationScrollWidget : ScrollableWidget
|
||||
public class PrinterConfigurationScrollWidget : ScrollableWidget, IIgnoredPopupChild
|
||||
{
|
||||
public PrinterConfigurationScrollWidget()
|
||||
: base(true)
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public IPopupLayoutEngine PopupLayoutEngine { get; set; }
|
||||
public Direction PopDirection { get; set; } = Direction.Down;
|
||||
public bool MakeScrollable { get; set; } = true;
|
||||
public Vector2 OpenOffset { get; set; } = Vector2.Zero;
|
||||
|
||||
public GuiWidget PopupContent { get; set; }
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (PopupLayoutEngine == null)
|
||||
{
|
||||
PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, Vector2.Zero, this.PopDirection, 0, this.AlignToRightEdge);
|
||||
PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, OpenOffset, this.PopDirection, 0, this.AlignToRightEdge);
|
||||
}
|
||||
menuVisible = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -6247,3 +6247,6 @@ Translated:Lower / Deploy
|
|||
English:Raise / Stow
|
||||
Translated:Raise / Stow
|
||||
|
||||
English:Touch Screen Mode
|
||||
Translated:Touch Screen Mode
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9fed1dfbc62ed687a752c665a34e887fc9b2e7a2
|
||||
Subproject commit 7e4effb1bbcd9307add0049c5519aeef2d50d082
|
||||
Loading…
Add table
Add a link
Reference in a new issue