private Widget CreateFooterSection() { var container = new Widget { Layout = new HBoxLayout { Spacing = 5 }, }; actionPicker = new ThemedDropDownList(); foreach (var menuItem in The.MenuController.GetVisibleAndSortedItems()) { actionPicker.Items.Add(new CommonDropDownList.Item(menuItem.Label, menuItem.Action)); } actionPicker.Index = 0; container.AddNode(actionPicker); goButton = new ThemedButton("Go"); goButton.Clicked += () => Execute((Func <string>)actionPicker.Value); container.AddNode(goButton); abortButton = new ThemedButton("Abort") { Enabled = false, Visible = false }; abortButton.Clicked += () => AssetCooker.CancelCook(); container.AddNode(abortButton); return(container); }
private void UpdateProfiles(ThemedDropDownList profilePicker) { profilePicker.Items.Clear(); foreach (var profile in HotkeyRegistry.Profiles) { profilePicker.Items.Add(new CommonDropDownList.Item(profile.Name, profile)); } profilePicker.Value = HotkeyRegistry.CurrentProfile; }
private ThemedDropDownList CreateCategoryList() { categoryList = new ThemedDropDownList(); categoryList.Items.Add(new CommonDropDownList.Item("All", CommandRegistry.AllCommands)); foreach (var categoryInfo in CommandRegistry.RegisteredCategories()) { categoryList.Items.Add(new CommonDropDownList.Item(categoryInfo.Title, categoryInfo)); } categoryList.Index = 0; categoryList.Changed += e => RefreshAvailableCommands(); return(categoryList); }
private Widget CreateSortOrderDropDownList() { var list = new ThemedDropDownList { Items = { new ThemedDropDownList.Item("Ascending", OrderType.Ascending), new ThemedDropDownList.Item("Descending", OrderType.Descending) }, Layout = new HBoxLayout(), MinMaxWidth = FontPool.Instance.DefaultFont.MeasureTextLine("Descending", Theme.Metrics.TextHeight, 0).X + 30, Index = 0 }; list.Changed += args => { view.SortByType(view.SortType, (OrderType)args.Value); }; return(list); }
private Widget CreateSortDropDownList() { var list = new ThemedDropDownList { Items = { new ThemedDropDownList.Item("Name", SortType.Name), new ThemedDropDownList.Item("Extension", SortType.Extension), new ThemedDropDownList.Item("Size", SortType.Size), new ThemedDropDownList.Item("Date", SortType.Date) }, Index = 0 }; list.Changed += args => { view.SortByType((SortType)args.Value, view.OrderType); }; return(list); }
private Widget CreateSortDropDownList() { var list = new ThemedDropDownList { Items = { new ThemedDropDownList.Item("Name", SortType.Name), new ThemedDropDownList.Item("Extension", SortType.Extension), new ThemedDropDownList.Item("Size", SortType.Size), new ThemedDropDownList.Item("Date", SortType.Date) }, Index = 0 }; list.Value = (view.RootWidget.Components.Get <ViewNodeComponent>().ViewNode as FSViewNode)?.SortType ?? SortType.Name; list.Changed += args => { view.SortByType((SortType)args.Value, view.OrderType); if (view.RootWidget.Components.Get <ViewNodeComponent>().ViewNode is FSViewNode fsViewNode) { fsViewNode.SortType = (SortType)args.Value; } }; return(list); }
public CookingRulesEditor(Action <string> navigateAndSelect) { this.navigateAndSelect = navigateAndSelect; scrollView = new ThemedScrollView(); scrollView.Content.Layout = new VBoxLayout(); ThemedDropDownList targetSelector; toolbar = new Toolbar(); toolbar.Nodes.AddRange( (targetSelector = new ThemedDropDownList { LayoutCell = new LayoutCell(Alignment.Center) }) ); targetSelector.Items.Add(new DropDownList.Item("None", null)); foreach (var t in Orange.The.Workspace.Targets) { targetSelector.Items.Add(new ThemedDropDownList.Item(t.Name, t)); } targetSelector.Changed += (value) => { if (value.ChangedByUser) { activeTarget = (Target)value.Value; Invalidate(savedSelection); } }; targetSelector.Index = 0; activeTarget = null; RootWidget = new Widget { Layout = new VBoxLayout(), Nodes = { toolbar, scrollView } }; }
private Widget CreateKeyboardPane() { var hotkeyEditor = new HotkeyEditor(); var pane = new Widget { Layout = new VBoxLayout { Spacing = 10 }, Padding = contentPadding }; pane.Awoke += node => hotkeyEditor.SetFocus(); var profileLabel = new ThemedSimpleText("Profile: ") { VAlignment = VAlignment.Center, HAlignment = HAlignment.Right, LayoutCell = new LayoutCell(Alignment.RightCenter, 0) }; var profilePicker = new ThemedDropDownList(); profilePicker.TextWidget.Padding = new Thickness(3, 0); var exportButton = new ThemedButton("Export..."); exportButton.Clicked = () => { var dlg = new FileDialog { Mode = FileDialogMode.Save, InitialFileName = currentProfile.Name }; if (dlg.RunModal()) { currentProfile.Save(dlg.FileName); } }; var importButton = new ThemedButton("Import..."); importButton.Clicked = () => { var dlg = new FileDialog { Mode = FileDialogMode.Open }; if (dlg.RunModal()) { string name = Path.GetFileName(dlg.FileName); if (HotkeyRegistry.Profiles.Any(i => i.Name == name)) { if (new AlertDialog($"Profile with name \"{name}\" already exists. Do you want to rewrite it?", "Yes", "Cancel").Show() != 0) { return; } else { profilePicker.Items.Remove(profilePicker.Items.First(i => i.Text == name)); } } var profile = HotkeyRegistry.CreateProfile(Path.GetFileName(dlg.FileName)); profile.Load(dlg.FileName); profile.Save(); HotkeyRegistry.Profiles.Add(profile); profilePicker.Items.Add(new CommonDropDownList.Item(profile.Name, profile)); profilePicker.Value = profile; } }; var deleteButton = new ThemedButton("Delete"); deleteButton.Clicked = () => { if (new AlertDialog($"Are you sure you want to delete profile \"{currentProfile.Name}\"?", "Yes", "Cancel").Show() == 0) { currentProfile.Delete(); profilePicker.Items.Remove(profilePicker.Items.First(i => i.Value == currentProfile)); profilePicker.Index = 0; HotkeyRegistry.CurrentProfile = profilePicker.Value as HotkeyProfile; foreach (var command in HotkeyRegistry.CurrentProfile.Commands) { command.Command.Shortcut = new Shortcut(Key.Unknown); } } }; var categoryLabel = new ThemedSimpleText("Commands: ") { VAlignment = VAlignment.Center, HAlignment = HAlignment.Right, LayoutCell = new LayoutCell(Alignment.RightCenter, 0) }; var categoryPicker = new ThemedDropDownList(); categoryPicker.TextWidget.Padding = new Thickness(3, 0); var allShortcutsView = new ThemedScrollView(); allShortcutsView.Content.Padding = contentPadding; allShortcutsView.Content.Layout = new VBoxLayout { Spacing = 8 }; var selectedShortcutsView = new ThemedScrollView(); selectedShortcutsView.Content.Padding = contentPadding; selectedShortcutsView.Content.Layout = new VBoxLayout { Spacing = 4 }; hotkeyEditor.SelectedShortcutChanged = () => { selectedShortcutsView.Content.Nodes.Clear(); var commands = hotkeyEditor.SelectedCommands.ToLookup(i => i.CategoryInfo); foreach (var category in commands) { selectedShortcutsView.Content.AddNode(new ThemedSimpleText { Text = category.Key.Title, VAlignment = VAlignment.Center, Color = Theme.Colors.GrayText }); foreach (var command in category) { var shortcut = new ThemedSimpleText { Text = command.Shortcut.ToString(), VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, 1) }; var name = new ThemedSimpleText { Text = command.Title, VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, 2) }; var deleteShortcutButton = new ThemedTabCloseButton { LayoutCell = new LayoutCell(Alignment.LeftCenter, 0), Clicked = () => { command.Shortcut = new Shortcut(); hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); } }; selectedShortcutsView.Content.AddNode(new Widget { Layout = new TableLayout { Spacing = 4, RowCount = 1, ColumnCount = 3 }, Nodes = { shortcut, name, deleteShortcutButton }, Padding = new Thickness(15, 0) }); } } selectedShortcutsView.ScrollPosition = allShortcutsView.MinScrollPosition; }; var filterBox = new ThemedEditBox { MaxWidth = 200 }; filterBox.AddChangeWatcher(() => filterBox.Text, text => { UpdateAllShortcutsView(allShortcutsView, selectedShortcutsView, hotkeyEditor, text.ToLower()); allShortcutsView.ScrollPosition = allShortcutsView.MinScrollPosition; }); categoryPicker.Changed += args => { hotkeyEditor.Category = (args.Value as CommandCategoryInfo); hotkeyEditor.SetFocus(); int index = -1; foreach (var node in allShortcutsView.Content.Nodes.SelectMany(i => i.Nodes)) { var button = node as ThemedExpandButton; if (button == null) { continue; } index++; if (index == args.Index) { if (!button.Expanded) { button.Clicked?.Invoke(); } allShortcutsView.ScrollPosition = button.ParentWidget.Position.Y; break; } } }; profilePicker.Changed += args => { var profile = args.Value as HotkeyProfile; if (profile != null) { hotkeyEditor.Profile = profile; filterBox.Text = null; UpdateAllShortcutsView(allShortcutsView, selectedShortcutsView, hotkeyEditor, filterBox.Text); deleteButton.Enabled = profile.Name != HotkeyRegistry.DefaultProfileName && profilePicker.Items.Count > 1; categoryPicker.Items.Clear(); foreach (var category in profile.Categories) { categoryPicker.Items.Add(new CommonDropDownList.Item(category.Title, category)); } categoryPicker.Value = null; categoryPicker.Value = profile.Categories.First(); currentProfile = profile; } }; UpdateProfiles(profilePicker); HotkeyRegistry.Reseted = () => UpdateProfiles(profilePicker); pane.AddNode(new Widget { Layout = new TableLayout { Spacing = 4, RowCount = 2, ColumnCount = 3 }, Nodes = { profileLabel, profilePicker, new Widget { Layout = new HBoxLayout { Spacing = 4 }, Nodes = { exportButton,importButton, deleteButton } }, categoryLabel, categoryPicker }, LayoutCell = new LayoutCell { StretchY = 0 } }); pane.AddNode(hotkeyEditor); pane.AddNode(new Widget { Layout = new HBoxLayout { Spacing = 12 }, Nodes = { new Widget { Layout = new VBoxLayout{ Spacing = 4 }, Nodes = { new Widget { Layout = new HBoxLayout{ Spacing = 8 }, Nodes = { new ThemedSimpleText("Search: ") { VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, 0) }, filterBox }, LayoutCell = new LayoutCell{ StretchY = 0 } }, new ThemedFrame { Nodes = { allShortcutsView }, Layout = new VBoxLayout() } } }, new Widget { Layout = new VBoxLayout{ Spacing = 4 }, Nodes = { new ThemedSimpleText("Selected commands:") { LayoutCell = new LayoutCell{ StretchY = 0 } }, new ThemedFrame { Nodes = { selectedShortcutsView }, Layout = new VBoxLayout() } } } } }); return(pane); }
public Result Show(Marker marker, bool canDelete) { Widget buttonsPanel; Button deleteButton; Button okButton; Button cancelButton; DropDownList actionSelector; EditBox markerIdEditor; ThemedDropDownList jumpToSelector; Result result; var window = new Window(new WindowOptions { FixedSize = true, Title = "Marker properties", Visible = false, Style = WindowStyle.Dialog }); jumpToSelector = new ThemedDropDownList(); foreach (var m in Document.Current.Container.Markers) { jumpToSelector.Items.Add(new ThemedDropDownList.Item(m.Id, m)); } jumpToSelector.Text = marker.JumpTo; var rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { new Widget { Layout = new TableLayout{ ColCount = 2, RowCount = 3, Spacing = 8, ColDefaults = { new LayoutCell(Alignment.RightCenter, 0.5f, 0), new LayoutCell(Alignment.LeftCenter, 1, 0) } }, Nodes = { new ThemedSimpleText("Marker Id"), (markerIdEditor = new ThemedEditBox{ Text = marker.Id, MinSize= Theme.Metrics.DefaultEditBoxSize * new Vector2(2, 1) }), new ThemedSimpleText("Action"), (actionSelector = new ThemedDropDownList{ Items = { new DropDownList.Item("Play", MarkerAction.Play), new DropDownList.Item("Jump", MarkerAction.Jump), new DropDownList.Item("Stop", MarkerAction.Stop), new DropDownList.Item("Destroy", MarkerAction.Destroy), }, Value = marker.Action }), new ThemedSimpleText("Jump to"), jumpToSelector, } }, (buttonsPanel = new Widget{ Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton("Ok")), (cancelButton = new ThemedButton("Cancel")), } }) } }; if (canDelete) { deleteButton = new ThemedButton("Delete"); buttonsPanel.AddNode(deleteButton); deleteButton.Clicked += () => { result = Result.Delete; window.Close(); }; } rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.Add(new KeyPressHandler(Key.Escape, (input, key) => { input.ConsumeKey(key); window.Close(); })); okButton.Clicked += () => { result = Result.Ok; window.Close(); }; cancelButton.Clicked += window.Close; okButton.SetFocus(); result = Result.Cancel; window.ShowModal(); if (result == Result.Ok) { marker.Id = markerIdEditor.Text; marker.Action = (MarkerAction)actionSelector.Value; marker.JumpTo = jumpToSelector.Text; } return(result); }
private void CreateOverridesWidgets(CookingRulesCollection crc, string key, Target target, Meta.Item yi, CookingRules rules, Widget overridesWidget) { Widget innerContainer; var sourceFilenameText = string.IsNullOrEmpty(rules.SourceFilename) ? "Default" : rules.SourceFilename.Substring(The.Workspace.AssetsDirectory.Length); var targetName = target == null ? "" : $" ({target.Name})"; var container = new Widget { Padding = new Thickness { Right = 30 }, Nodes = { (innerContainer = new Widget { Layout = new HBoxLayout(), }), new ThemedSimpleText(sourceFilenameText + targetName) { FontHeight = 16, ForceUncutText = false, OverflowMode = TextOverflowMode.Ellipsis, HAlignment = HAlignment.Right, VAlignment = VAlignment.Center, MinSize = new Vector2(100, RowHeight), MaxSize = new Vector2(500, RowHeight) }, (new ToolbarButton { Texture = IconPool.GetTexture("Filesystem.ArrowRight"), Padding = Thickness.Zero, Size = RowHeight * Vector2.One, MinMaxSize = RowHeight * Vector2.One, Clicked = () => navigateAndSelect(rules.SourceFilename), }) }, Layout = new HBoxLayout(), }; container.CompoundPostPresenter.Add(new DelegatePresenter <Widget>((w) => { var topmostOverride = crc[key]; while ( topmostOverride.Parent != null && !(topmostOverride.CommonRules.FieldOverrides.Contains(yi) || RulesForActiveTarget(topmostOverride).FieldOverrides.Contains(yi)) ) { topmostOverride = topmostOverride.Parent; } w.PrepareRendererState(); if (target != activeTarget || rules != topmostOverride) { Renderer.DrawLine(10.0f - 30.0f, w.Height * 0.6f, w.Width - 10.0f, w.Height * 0.6f, Color4.Black.Transparentify(0.5f), 1.0f); } else { Renderer.DrawRect(Vector2.Right * -20.0f, w.Size, Color4.Green.Lighten(0.5f).Transparentify(0.5f)); } })); container.Components.Add(new PropertyOverrideComponent { Rules = rules, YuzuItem = yi, }); overridesWidget.Nodes.Add(container); var targetRuels = RulesForTarget(rules, target); var editorParams = new PropertyEditorParams(innerContainer, targetRuels, yi.Name) { ShowLabel = false, PropertySetter = (owner, name, value) => { yi.SetValue(owner, value); targetRuels.Override(name); rules.DeduceEffectiveRules(target); rules.Save(); }, NumericEditBoxFactory = () => { var r = new ThemedNumericEditBox(); r.MinMaxHeight = r.Height = RowHeight; r.TextWidget.VAlignment = VAlignment.Center; r.TextWidget.Padding.Top = r.TextWidget.Padding.Bottom = 0.0f; return(r); }, DropDownListFactory = () => { var r = new ThemedDropDownList(); r.MinMaxHeight = r.Height = RowHeight; return(r); }, EditBoxFactory = () => { var r = new ThemedEditBox(); r.MinMaxHeight = r.Height = RowHeight; r.TextWidget.Padding.Top = r.TextWidget.Padding.Bottom = 0.0f; return(r); }, }; CreatePropertyEditorForType(yi, editorParams); }
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(); }