public void Start(WidgetGroup parentGroup) { _rootWidgetGroup = new WidgetGroup(parentGroup, 0, 0, 0.0f, 0.0f); _rootWidgetGroup.SetWidgetEventListener(this); _window = new WindowWidget( _rootWidgetGroup, "Chat", m_chatWindowStyle.windowStyle, Screen.width - m_chatWindowStyle.windowStyle.WindowWidth - 3, 0); _chatText = new ScrollTextWidget( _window, m_chatWindowStyle.windowStyle.WindowWidth, m_chatWindowStyle.windowStyle.WindowHeight - m_chatWindowStyle.chatInputHeight - m_chatWindowStyle.windowStyle.TitleBarHeight, 0.0f, 0.0f, ""); _chatText.FontSize = 12; _chatInput = new TextEntryWidget( _window, m_chatWindowStyle.windowStyle.WindowWidth, m_chatWindowStyle.chatInputHeight, 0, m_chatWindowStyle.windowStyle.WindowHeight - m_chatWindowStyle.chatInputHeight, ""); _chatText.FontSize = 12; _chatInput.MaxLength = (int)IRCSession.MAX_CHAT_STRING_LENGTH; SetChatInputVisible(true); }
public void onSelectedBodyChanged(int idx) { if (government != null) { for (int i = 0; i < buttons.Count; i++) { Destroy(buttons[i]); buttons[i] = null; } buttons.Clear(); selectedBody = government.bodies[idx]; foreach (Power pow in government.powers) { foreach (Stage stage in pow.stages) { if (stage.requiredBodies.Contains(selectedBody.id)) { GameObject go = Instantiate(templateButton); //go.GetComponentInChildren<Text>().text = stage.id; go.SetActive(true); go.transform.SetParent(buttonPanel.transform); buttons.Add(go); go.GetComponent <Button>().image.sprite = SpriteLoader.getSprite(stage.icon); go.GetComponent <Tooltip>().title = pow.name + "_" + stage.name; string tooltip = stage.requirementType == Stage.RequirementType.All ? "Require all of:\n" : "Requires any of:\n"; foreach (string body in stage.requiredBodies) { tooltip += "\t" + body + "\n"; } go.GetComponent <Tooltip>().text = tooltip; go.GetComponent <Button>().onClick.AddListener( () => { GameObject window = WindowManager.openEmptyWindow("add_law"); WindowWidget wid = window.GetComponent <WindowWidget>(); if (wid == null) { Debug.LogError("Failure!"); } else { //wid.minimumSize = new Size2(200, 400); wid.content.AddComponent <AddLawWidget>(); wid.GetComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.Unconstrained; wid.minimumSize = new Size2(400, 100); wid.resizePanel.maxSize = new Vector2(2000, 400); } //window.GetComponent<WindowWidget>().setContent(content); //GameObject go = new GameObject(); //go.AddComponent<DynamicWindow>(); } ); } } } } }
public OrangeInterface() { var windowSize = new Vector2(500, 400); window = new Window(new WindowOptions { ClientSize = windowSize, FixedSize = false, Title = "Orange", #if WIN Icon = new System.Drawing.Icon(new EmbeddedResource("Orange.GUI.Resources.Orange.ico", "Orange.GUI").GetResourceStream()), #endif // WIN }); window.Closed += The.Workspace.Save; windowWidget = new ThemedInvalidableWindowWidget(window) { Id = "MainWindow", Layout = new HBoxLayout { Spacing = 6 }, Padding = new Thickness(6), Size = windowSize }; var mainVBox = new Widget { Layout = new VBoxLayout { Spacing = 6 } }; mainVBox.AddNode(CreateHeaderSection()); mainVBox.AddNode(CreateVcsSection()); mainVBox.AddNode(CreateTextView()); mainVBox.AddNode(CreateFooterSection()); windowWidget.AddNode(mainVBox); }
public ModalOperationDialog(GetCurrentStatusDelegate getCurrentStatus, string title = null) { window = new Window(new WindowOptions { FixedSize = true, Title = title ?? "Tangerine", Visible = false, Style = WindowStyle.Borderless }); rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { (statusText = new ThemedSimpleText { Padding = new Thickness(4) }) } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { statusText.Text = $"{title}\n{getCurrentStatus()}"; }); }
public AlertDialog(string text, params string[] buttons) { if (buttons.Length == 0) { buttons = new[] { "Ok" }; } window = new Window(new WindowOptions { FixedSize = true, Title = "Tangerine", Visible = false, Style = WindowStyle.Dialog }); rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { new ThemedSimpleText(text) { Padding = new Thickness(4) }, (buttonsPanel = new Widget{ Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter, 1, 0), }) } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); var cancelIndex = buttons.ToList().IndexOf("Cancel"); if (cancelIndex >= 0) { result = cancelIndex; rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { Close(cancelIndex); } }); } for (int i = 0; i < buttons.Length; i++) { var button = new ThemedButton { Text = buttons[i] }; int j = i; button.Clicked += () => Close(j); buttonsPanel.AddNode(button); if (i == 0) { button.SetFocus(); } } }
/// <summary> /// Reads an XmlSubtree an a law and prepares a GUI (with windows) to /// represent the Law. /// </summary> /// <param name="reader"></param> /// <param name="law"></param> public void prepareGui(XmlReader reader, Law law) { // TODO: Only one window and many widget? GameObject gowin = WindowManager.openEmptyWindow(law.id + "_window"); GameObject go = Instantiate(dynamicWidgetPrototype); WindowWidget window = gowin.GetComponent <WindowWidget>(); window.content = go; if (go.GetComponent <DynamicXmlWidget>() == null) { Debug.LogError("Missing DynamicXMlWindow component."); return; } DynamicXmlWidget law_widget = go.GetComponent <DynamicXmlWidget>(); //proto.moveToCanvas(); go.name = law.id + "_widget"; law_widget.target = law; law_widget.buildGui(reader); window.minimumSize = law_widget.minimumSize + WindowWidget.margin; lawGUIs[law.id] = go; }
public SaveRulerDialog() { window = new Window(new WindowOptions { FixedSize = true, Title = "Save Ruler", Visible = false, Style = WindowStyle.Dialog, }); rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { new Widget { Layout = new TableLayout{ ColCount = 2, RowCount = 1, Spacing = 8, ColDefaults = { new LayoutCell(Alignment.RightCenter, 0.5f, 0), new LayoutCell(Alignment.LeftCenter, 1, 0) } }, Nodes = { new ThemedSimpleText("Enter ruler name"), (EditBox = new ThemedEditBox()), } }, (buttonsPanel = new Widget{ Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton("Ok")), (cancelButton = new ThemedButton("Cancel")), } }) } }; cancelButton.Clicked += window.Close; okButton.AddChangeWatcher(() => EditBox.Text, (text) => okButton.Enabled = !string.IsNullOrEmpty(text)); okButton.Clicked += () => { result = EditBox.Text; window.Close(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); EditBox.SetFocus(); }
void SetupMainWindowTitle(WindowWidget windowWidget) { var title = "Tangerine"; if (Project.Current != Project.Null) { var citProjName = System.IO.Path.GetFileNameWithoutExtension(Project.Current.CitprojPath); title = $"{citProjName} - Tangerine"; } windowWidget.Window.Title = title; }
private DockManager(Vector2 windowSize) { var window = new Window(new WindowOptions { ClientSize = windowSize, FixedSize = false, Title = "Tangerine", MacWindowTabbingMode = MacWindowTabbingMode.Disallowed, #if WIN Icon = new System.Drawing.Icon(new EmbeddedResource(AppIconPath, "Tangerine").GetResourceStream()), #endif // WIN }); window.UnhandledExceptionOnUpdate += e => UnhandledExceptionOccurred?.Invoke(e); SetDropHandler(window); MainWindowWidget = new ThemedInvalidableWindowWidget(window) { Id = "MainWindow", Layout = new VBoxLayout(), Size = windowSize, RedrawMarkVisible = true }; MainWindowWidget.WidgetContext.GestureManager = new HelpModeGestureManager(MainWindowWidget.WidgetContext); ToolbarArea = new Frame { Id = "Toolbar", ClipChildren = ClipMethod.ScissorTest, Layout = new VBoxLayout { Spacing = 4 }, LayoutCell = new LayoutCell { StretchY = 0 }, }; DocumentArea = new Frame { ClipChildren = ClipMethod.ScissorTest, }; DocumentAreaDropFilesGesture = new DropFilesGesture(); DocumentArea.Gestures.Add(DocumentAreaDropFilesGesture); DocumentArea.CompoundPresenter.Add(new WidgetFlatFillPresenter(Color4.Gray)); var windowPlacement = new WindowPlacement { Size = windowSize, Position = window.ClientPosition, WindowWidget = MainWindowWidget }; DockHierarchy.Instance.Initialize(windowPlacement); window.Moved += () => Model.WindowPlacements.First().Position = window.ClientPosition; window.Resized += (deviceRotated) => Model.WindowPlacements.First().Size = window.ClientSize; MainWindowWidget.AddChangeWatcher( () => MainWindowWidget.Window.State, value => Model.WindowPlacements[0].State = value); MainWindowWidget.Components.Add(new RequestedDockingComponent()); MainWindowWidget.CompoundPostPresenter.Add(new DockingPresenter()); }
public WindowPage() : base("Window") { WindowWidget widow = new WindowWidget(new RectangleDouble(20, 20, 400, 400)); AddChild(widow); GroupBox groupBox = new GroupBox("Radio Group"); groupBox.LocalBounds = new RectangleDouble(0, 0, 300, 100); groupBox.OriginRelativeParent = new Vector2(0, 0); groupBox.AddChild(new RadioButton(0, 40, "Simple Radio Button 1")); groupBox.AddChild(new RadioButton(0, 20, "Simple Radio Button 2")); groupBox.AddChild(new RadioButton(0, 0, "Simple Radio Button 3")); widow.AddChild(groupBox); }
private WindowWidget CreateWorld() { var options = new WindowOptions { Title = ApplicationName, AsyncRendering = true }; var window = new Window(options); window.Updating += OnUpdateFrame; window.Rendering += OnRenderFrame; window.Resized += OnResize; var world = new WindowWidget(window) { Layer = RenderChain.LayerCount - 1 }; return(world); }
private DockManager(Vector2 windowSize, IMenu padsMenu) { this.padsMenu = padsMenu; var window = new Window(new WindowOptions { ClientSize = windowSize, FixedSize = false, Title = "Tangerine", #if WIN Icon = new System.Drawing.Icon(new EmbeddedResource(appIconPath, "Tangerine").GetResourceStream()), #endif // WIN }); window.UnhandledExceptionOnUpdate += HandleException; SetDropHandler(window); MainWindowWidget = new ThemedInvalidableWindowWidget(window) { Id = "MainWindow", Layout = new VBoxLayout(), Size = windowSize, RedrawMarkVisible = true }; ToolbarArea = new Frame { Id = "Toolbar", ClipChildren = ClipMethod.ScissorTest, Layout = new FlowLayout { Spacing = 4 }, LayoutCell = new LayoutCell { StretchY = 0 }, }; DocumentArea = new Frame { ClipChildren = ClipMethod.ScissorTest, }; DocumentArea.CompoundPresenter.Add(new WidgetFlatFillPresenter(Color4.Gray)); }
public ThumbnalWindow(string title) { window = new Window(new WindowOptions { FixedSize = true, ClientSize = new Vector2(100, 40), Style = WindowStyle.Borderless }); rootWidget = new ThemedInvalidableWindowWidget(window) { PostPresenter = new WidgetBoundsPresenter(Color4.Black, 1), Layout = new StackLayout(), Nodes = { new ThemedSimpleText { Text = title, ForceUncutText = false, LayoutCell = new LayoutCell(Alignment.Center), OverflowMode = TextOverflowMode.Ellipsis, HAlignment = HAlignment.Center, VAlignment = VAlignment.Center } } }; rootWidget.Updated += delta => StickToMouseCursor(); StickToMouseCursor(); }
public void Start(WidgetGroup parentGroup) { _rootWidgetGroup = new WidgetGroup(parentGroup, 0, 0, 0.0f, 0.0f); _rootWidgetGroup.SetWidgetEventListener(this); _window = new WindowWidget( _rootWidgetGroup, "Chat", m_chatWindowStyle.windowStyle, Screen.width - m_chatWindowStyle.windowStyle.WindowWidth - 3, 0); _chatText = new ScrollTextWidget( _window, m_chatWindowStyle.windowStyle.WindowWidth, m_chatWindowStyle.windowStyle.WindowHeight - m_chatWindowStyle.chatInputHeight - m_chatWindowStyle.windowStyle.TitleBarHeight, 0.0f, 0.0f, ""); _chatText.FontSize= 12; _chatInput = new TextEntryWidget( _window, m_chatWindowStyle.windowStyle.WindowWidth, m_chatWindowStyle.chatInputHeight, 0, m_chatWindowStyle.windowStyle.WindowHeight - m_chatWindowStyle.chatInputHeight, ""); _chatText.FontSize= 12; _chatInput.MaxLength = (int)IRCSession.MAX_CHAT_STRING_LENGTH; SetChatInputVisible(true); }
public AttachmentDialog(Model3D source) { Path = source.ContentsPath; this.source = source; attachment = new Model3DAttachmentParser().Parse(Path) ?? new Model3DAttachment { ScaleFactor = 1 }; window = new Window(new WindowOptions { ClientSize = new Vector2(700, 400), FixedSize = false, Title = "Attachment3D", MinimumDecoratedSize = new Vector2(500, 300) }); frame = new ThemedFrame { Padding = new Thickness(8), LayoutCell = new LayoutCell { StretchY = float.MaxValue }, Layout = new StackLayout(), }; content = new TabbedWidget(); content.AddTab("General", CreateGeneralPane(), true); content.AddTab("Material Effects", CreateMaterialEffectsPane()); content.AddTab("Mesh Options", CreateMeshOptionsPane()); content.AddTab("Animations", CreateAnimationsPane()); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { content, new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; cancelButton.Clicked += () => { window.Close(); Core.UserPreferences.Instance.Load(); }; okButton.Clicked += () => { try { CheckErrors(); window.Close(); Model3DAttachmentParser.Save(attachment, System.IO.Path.Combine(Project.Current.AssetsDirectory, Path)); } catch (Lime.Exception e) { new AlertDialog(e.Message).Show(); } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); Core.UserPreferences.Instance.Load(); } }); }
public DragBehaviour(WindowWidget mainWindow, DockPanel panel) { this.mainWidget = mainWindow; this.panel = panel; panel.TitleWidget.Tasks.Add(MainTask()); }
public AddAnimationClipDialog(IntVector2 cell, string selectedAnimationId) { window = new Window(new WindowOptions { ClientSize = new Vector2(250, 140), FixedSize = true, Title = "Add Clip", Visible = false, }); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { new Widget { Layout = new TableLayout{ Spacing = 4, RowCount = 3, ColumnCount = 2, ColumnDefaults = new List <DefaultLayoutCell>{ new DefaultLayoutCell(Alignment.RightCenter) { StretchX = 1 }, new DefaultLayoutCell(Alignment.LeftCenter) { StretchX = 2 }, } }, LayoutCell = new LayoutCell{ StretchY = 0 }, Nodes = { new ThemedSimpleText("Animation"), (animationSelector = new ThemedDropDownList()), new ThemedSimpleText("Begin Marker"), (beginMarkerSelector = new ThemedDropDownList()), new ThemedSimpleText("End Marker"), (endMarkerSelector = new ThemedDropDownList()) } }, new Widget { // Vertical stretcher }, new Widget { Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell{ StretchY = 0 }, Padding = new Thickness{ Top = 5 }, Nodes = { new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton{ Text = "Ok" }), (cancelButton = new ThemedButton{ Text = "Cancel" }), }, } } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); foreach (var a in EnumerateAnimations()) { animationSelector.Items.Add(new CommonDropDownList.Item(a.Id)); } animationSelector.Index = 0; if (selectedAnimationId != null) { animationSelector.Index = animationSelector.Items.Select(i => i.Value).ToList().IndexOf(selectedAnimationId); } animationSelector.Changed += _ => RefreshMarkers(); RefreshMarkers(); cancelButton.Clicked += () => window.Close(); okButton.Clicked += () => { var animation = Document.Current.Animation.Owner.Animations.Find(animationSelector.Text); if (!animation.AnimationEngine.AreEffectiveAnimatorsValid(animation)) { // Refreshes animation duration either animation.AnimationEngine.BuildEffectiveAnimators(animation); } if (animation.CalcDurationInFrames() == 0) { AlertDialog.Show("Please select an animation with non-zero duration", "Ok"); return; } int beginFrame = (int?)beginMarkerSelector.Value ?? 0; int endFrame = (int?)endMarkerSelector.Value ?? animation.CalcDurationInFrames(); if (beginFrame >= endFrame) { AlertDialog.Show("Please select markers in ascending order", "Ok"); return; } var track = Document.Current.Rows[cell.Y].Components.Get <Core.Components.AnimationTrackRow>().Track; Document.Current.History.DoTransaction(() => { var clip = new AnimationClip { AnimationId = animationSelector.Text, BeginFrame = cell.X, InFrame = beginFrame, DurationInFrames = endFrame - beginFrame }; AnimationClipToolbox.InsertClip(track, clip); Core.Operations.SetProperty.Perform(clip, nameof(AnimationClip.IsSelected), true); }); window.Close(); }; cancelButton.SetFocus(); window.ShowModal(); }
public PreferencesDialog() { theme = AppUserPreferences.Instance.Theme; window = new Window(new WindowOptions { ClientSize = new Vector2(600, 400), FixedSize = false, Title = "Preferences", MinimumDecoratedSize = new Vector2(400, 300) }); Frame = new ThemedFrame { Padding = new Thickness(8), LayoutCell = new LayoutCell { StretchY = float.MaxValue }, Layout = new StackLayout(), }; Content = new TabbedWidget(); Content.AddTab("General", CreateGeneralPane(), true); Content.AddTab("Appearance", CreateColorsPane()); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { Content, new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.LeftCenter), Nodes = { (resetButton = new ThemedButton { Text = "Reset To Defaults", MinMaxWidth = 150f }), new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; okButton.Clicked += () => { window.Close(); if (theme != AppUserPreferences.Instance.Theme) { AlertDialog.Show("The color theme change will take effect next time you run Tangerine."); } Core.UserPreferences.Instance.Save(); }; resetButton.Clicked += () => { if (new AlertDialog($"Are you sure you want to reset to defaults?", "Yes", "Cancel").Show() == 0) { ResetToDefaults(); } }; cancelButton.Clicked += () => { window.Close(); Core.UserPreferences.Instance.Load(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); Core.UserPreferences.Instance.Load(); } }); okButton.SetFocus(); }
public NumericScaleDialog() { window = new Window(new WindowOptions { ClientSize = new Vector2(250, 70), FixedSize = true, Title = "Numeric Scale", Visible = false, }); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { (container = new Widget { Layout = new VBoxLayout(), }), new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell { StretchY = 0 }, Padding = new Thickness { Top = 5 }, Nodes = { new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton{ Text = "Ok" }), (cancelButton = new ThemedButton{ Text = "Cancel" }), }, } } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); Scale = 1; var editor = new FloatPropertyEditor(new PropertyEditorParams(container, this, nameof(Scale), "Scale")); cancelButton.Clicked += () => { window.Close(); }; okButton.Clicked += () => { editor.Submit(); if (Scale < Mathf.ZeroTolerance) { AlertDialog.Show("Scale value too small"); window.Close(); return; } Document.Current.History.DoTransaction(() => { ScaleKeyframes(); }); window.Close(); }; cancelButton.SetFocus(); window.ShowModal(); }
public NumericMoveDialog() { window = new Window(new WindowOptions { ClientSize = new Vector2(250, 70), FixedSize = true, Title = "Numeric Move", Visible = false, }); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { (container = new Widget { Layout = new VBoxLayout(), }), new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell { StretchY = 0 }, Padding = new Thickness { Top = 5 }, Nodes = { new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton{ Text = "Ok" }), (cancelButton = new ThemedButton{ Text = "Cancel" }), }, } } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); var editor = new IntPropertyEditor(new PropertyEditorParams(container, this, nameof(Shift), "Shift")); cancelButton.Clicked += () => { window.Close(); }; okButton.Clicked += () => { editor.Submit(); if (Shift == 0) { window.Close(); return; } Document.Current.History.DoTransaction(() => { Operations.DragKeyframes.Perform(new IntVector2(Shift, 0), removeOriginals: true); Operations.ShiftGridSelection.Perform(new IntVector2(Shift, 0)); }); window.Close(); }; cancelButton.SetFocus(); window.ShowModal(); }
public PreferencesDialog() { window = new Window(new WindowOptions { ClientSize = new Vector2(800, 600), FixedSize = false, Title = "Preferences", MinimumDecoratedSize = new Vector2(400, 300), Visible = false }); Frame = new ThemedFrame { Padding = new Thickness(8), LayoutCell = new LayoutCell { StretchY = float.MaxValue }, Layout = new StackLayout(), }; Content = new ThemedTabbedWidget(); Content.AddTab("General", CreateGeneralPane(), true); Content.AddTab("Appearance", CreateColorsPane()); Content.AddTab("Theme", CreateThemePane()); Content.AddTab("Keyboard shortcuts", CreateKeyboardPane()); Content.AddTab("Toolbar", toolbarModelEditor = new ToolbarModelEditor()); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { Content, new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.LeftCenter), Padding = new Thickness { Top = 5 }, Nodes = { (resetButton = new ThemedButton { Text = "Reset To Defaults", MinMaxWidth = 150f }), new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; HotkeyRegistry.CurrentProfile.Save(); okButton.Clicked += () => { saved = true; SaveAfterEdit(); window.Close(); VisualHintsPanel.Refresh(); Core.UserPreferences.Instance.Save(); if (themeEdited) { AppUserPreferences.Instance.ColorThemeKind = ColorTheme.ColorThemeKind.Custom; } if (themeChanged) { AlertDialog.Show("Color theme changes will be applied after Tangerine restart."); } }; resetButton.Clicked += () => { if (new AlertDialog($"Are you sure you want to reset to defaults?", "Yes", "Cancel").Show() == 0) { ResetToDefaults(); } }; cancelButton.Clicked += () => { window.Close(); Core.UserPreferences.Instance.Load(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); Core.UserPreferences.Instance.Load(); } }); okButton.SetFocus(); window.Closed += () => { if (saved) { foreach (var profile in HotkeyRegistry.Profiles) { profile.Save(); } HotkeyRegistry.CurrentProfile = currentProfile; } else { foreach (var profile in HotkeyRegistry.Profiles) { profile.Load(); } HotkeyRegistry.CurrentProfile = HotkeyRegistry.CurrentProfile; } }; foreach (var command in HotkeyRegistry.CurrentProfile.Commands) { command.Command.Shortcut = new Shortcut(Key.Unknown); } window.ShowModal(); }
public OrangePluginOptionsDialog() { var uiBuidler = ((OrangeInterface)Orange.UserInterface.Instance).PluginUIBuilder; pluginPanel = (OrangePluginPanel)uiBuidler.SidePanel; window = new Window(new WindowOptions { ClientSize = new Vector2(400, 300), FixedSize = true, Title = pluginPanel.Title, MinimumDecoratedSize = new Vector2(400, 300) }); Frame = new ThemedFrame { Padding = new Thickness(8), LayoutCell = new LayoutCell { StretchY = float.MaxValue }, Layout = new StackLayout(), }; ThemedScrollView сontainer; rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { (сontainer = new ThemedScrollView { Padding = new Thickness { Right = 10 }, }), new Widget { Padding = new Thickness { Top = 10 }, Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (runButton = new ThemedButton { Text = "Build&Run" }), (closeButton = new ThemedButton { Text = "Close" }) } } } }; сontainer.Content.Layout = new VBoxLayout { Spacing = 4 }; foreach (var pluginCheckBox in pluginPanel.CheckBoxes) { var checkBoxWidget = new PluginCheckBoxWidget(pluginCheckBox); сontainer.Content.AddNode(checkBoxWidget); } runButton.Clicked += () => { ((Command)OrangeCommands.Run).Issue(); window.Close(); }; closeButton.Clicked += () => { window.Close(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); } }); runButton.SetFocus(); }
public DeleteRulerDialog() { window = new Window(new WindowOptions { ClientSize = new Vector2(300, 150), FixedSize = true, Title = "Rulers", MinimumDecoratedSize = new Vector2(200, 100) }); Frame = new ThemedFrame { Padding = new Thickness(8), LayoutCell = new LayoutCell { StretchY = float.MaxValue }, Layout = new StackLayout(), }; var collection = new ObservableCollection <RulerData>(Project.Current.Rulers); ThemedScrollView Container; rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { (Container = new ThemedScrollView { Padding = new Thickness { Right = 10 }, }), new Widget { Padding = new Thickness { Top = 10 }, Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; Container.Content.Layout = new VBoxLayout { Spacing = 4 }; var list = new Widget { Layout = new VBoxLayout(), }; Container.Content.AddNode(list); list.Components.Add(new WidgetFactoryComponent <RulerData>((w) => new RulerRowView(w, collection), collection)); okButton.Clicked += () => { window.Close(); Core.UserPreferences.Instance.Save(); var temp = Project.Current.Rulers.ToList(); foreach (var overlay in temp.Except(collection)) { Project.Current.RemoveRuler(overlay); } }; cancelButton.Clicked += () => { window.Close(); Core.UserPreferences.Instance.Load(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); Core.UserPreferences.Instance.Load(); } }); okButton.SetFocus(); }
public TextEditorDialog(string title, string text, Action <string> onSave) { window = new Window(new WindowOptions { ClientSize = new Vector2(300, 200), FixedSize = false, Title = title, Visible = false, }); rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { new Widget { Layout = new AnchorLayout(), Nodes = { (editor = new ThemedEditBox{ Anchors = Anchors.LeftRightTopBottom, Text = text, }) }, }, new Widget { Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell{ StretchY = 0 }, Padding = new Thickness{ Top = 5 }, Nodes = { new Widget { MinMaxHeight = 0 }, (okButton = new ThemedButton{ Text = "Ok" }), (cancelButton = new ThemedButton{ Text = "Cancel" }), }, } } }; // TODO: implement multiline scrollable text editor. const int maxLines = 640; editor.Editor.EditorParams.MaxLines = maxLines; editor.MinHeight = editor.TextWidget.FontHeight * maxLines; editor.TextWidget.VAlignment = VAlignment.Top; cancelButton.Clicked += () => { window.Close(); }; okButton.Clicked += () => { onSave(editor.Text); window.Close(); }; window.ShowModal(); }
public DirectoryPicker(Func <string, bool> openPath, Vector2 globalPosition, string path = null) { this.openPath = openPath; List <FilesystemItem> filesystemItems = new List <FilesystemItem>(); if (path == null) { var logicalDrives = Directory.GetLogicalDrives(); var availableRoots = GetAvailableRootsPathsFromLogicalDrives(logicalDrives); filesystemItems = GetFilesystemItems(availableRoots); } else { var internalFolders = GetInternalFoldersPaths(path); filesystemItems = GetFilesystemItems(internalFolders); } scrollView = new ThemedScrollView(); scrollView.Content.Layout = new VBoxLayout(); scrollView.Content.Padding = new Thickness(4); scrollView.Content.Nodes.AddRange(filesystemItems); // Like in Windows File Explorer const int MaxItemsOnPicker = 19; var itemsCount = Math.Min(filesystemItems.Count, MaxItemsOnPicker); var clientSize = new Vector2( FilesystemItem.ItemWidth, (FilesystemItem.IconSize + 2 * FilesystemItem.ItemPadding) * itemsCount) + new Vector2(scrollView.Content.Padding.Left * 2); scrollView.MinMaxSize = clientSize; var windowOptions = new WindowOptions { ClientSize = scrollView.MinSize, MinimumDecoratedSize = scrollView.MinSize, FixedSize = true, Style = WindowStyle.Borderless, Centered = globalPosition == Vector2.Zero, Visible = false, }; window = new Window(windowOptions); window.Deactivated += Close; rootWidget = new ThemedInvalidableWindowWidget(window) { Layout = new VBoxLayout(), LayoutBasedWindowSize = true, Nodes = { scrollView } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.AddChangeWatcher(() => WidgetContext.Current.NodeUnderMouse, (value) => Window.Current.Invalidate()); rootWidget.Presenter = new SyncDelegatePresenter <Widget>(_ => { rootWidget.PrepareRendererState(); Renderer.DrawRect(Vector2.One, rootWidget.ContentSize, Theme.Colors.DirectoryPickerBackground); }); rootWidget.CompoundPostPresenter.Add(new SyncDelegatePresenter <Widget>(_ => { rootWidget.PrepareRendererState(); Renderer.DrawRectOutline(Vector2.Zero, rootWidget.ContentSize, Theme.Colors.DirectoryPickerOutline, thickness: 1); })); window.Visible = true; if (globalPosition != Vector2.Zero) { window.ClientPosition = globalPosition; } }