public SearchPanel(Widget rootWidget) { PanelWidget = rootWidget; scrollView = new ThemedScrollView(); RootWidget = new Frame { Id = "SearchPanel", Padding = new Thickness(4), Layout = new VBoxLayout { Spacing = 4 }, Nodes = { (searchStringEditor = new ThemedEditBox()), scrollView } }; resultPane = scrollView.Content; RootWidget.AddChangeWatcher(() => searchStringEditor.Text, RefreshResultPane); scrollView.TabTravesable = new TabTraversable(); resultPane.CompoundPresenter.Insert(0, new DelegatePresenter <Widget>(w => { w.PrepareRendererState(); if (scrollView.IsFocused() && results.Count > 0) { Renderer.DrawRect( 0, rowHeight * selectedIndex, w.Width, (selectedIndex + 1) * rowHeight, Theme.Colors.SelectedBackground); } })); scrollView.LateTasks.Add(new KeyRepeatHandler(ScrollView_KeyRepeated)); }
/// <summary> /// Creates basic UI elements, but lefts bundle list empty. To fill it, call <see cref="CreateBundlesList"/> /// </summary> public BundlePickerWidget(BundlePicker bundlePicker) { this.bundlePicker = bundlePicker; Layout = new VBoxLayout { Spacing = 6 }; MaxWidth = 250f; checkboxes = new Dictionary <string, ThemedCheckBox>(); lines = new Dictionary <string, Widget>(); scrollView = new ThemedScrollView(); scrollView.CompoundPostPresenter.Add(new WidgetBoundsPresenter(Lime.Theme.Colors.ControlBorder)); scrollView.Content.Layout = new VBoxLayout { Spacing = 6 }; scrollView.Content.Padding = new Thickness(6); scrollView.CompoundPresenter.Add(new WidgetFlatFillPresenter(Color4.White)); selectButton = new ThemedButton { Text = "Select all", Clicked = SelectButtonClickHandler }; refreshButton = new ThemedButton { Text = "Refresh", Clicked = Refresh, }; filter = new ThemedEditBox(); filter.Tasks.Add(FilterBundlesTask); infoText = new ThemedSimpleText("Selected action uses all bundles.") { Color = Theme.Colors.BlackText, MinMaxHeight = Theme.Metrics.DefaultEditBoxSize.Y, Visible = false, VAlignment = VAlignment.Center, }; AddNode(filter); AddNode(infoText); AddNode(scrollView); var buttonLine = new Widget { Layout = new HBoxLayout { Spacing = 6 } }; AddNode(buttonLine); buttonLine.AddNode(new Widget { LayoutCell = new LayoutCell { StretchX = float.MaxValue }, MaxHeight = 0 }); buttonLine.AddNode(refreshButton); buttonLine.AddNode(selectButton); selectButton.Tasks.Add(UpdateTextOfSelectButtonTask()); }
private Widget CreateMaterialEffectsPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.MaterialEffect>( w => new MaterialEffectRow(w, attachment.MaterialEffects), attachment.MaterialEffects); widgetFactory.AddHeader(MaterialEffectRow.CreateHeader()); widgetFactory.AddFooter(DeletableRow <Model3DAttachment.MaterialEffect> .CreateFooter(() => { attachment.MaterialEffects.Add(new Model3DAttachment.MaterialEffect { Name = "MaterialEffect", MaterialName = "MaterialName", Path = "MaterialPath", }); })); list.Components.Add(widgetFactory); return(pane); }
private Widget CreateAnimationsPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.Animation>( w => new AnimationRow(w, attachment.Animations), attachment.Animations); widgetFactory.AddHeader(AnimationRow.CreateHeader()); widgetFactory.AddFooter(AnimationRow.CreateFooter(() => { attachment.Animations.Add(new Model3DAttachment.Animation { Name = "Animation", }); })); if (!attachment.Animations.Any(a => a.Name == Model3DAttachment.DefaultAnimationName)) { attachment.Animations.Insert(0, new Model3DAttachment.Animation { Name = Model3DAttachment.DefaultAnimationName, }); } list.Components.Add(widgetFactory); return(pane); }
private Widget CreateMeshOptionsPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.MeshOption>( w => new MeshRow(w, attachment.MeshOptions), attachment.MeshOptions); widgetFactory.AddHeader(MeshRow.CreateHeader()); widgetFactory.AddFooter(MeshRow.CreateFooter(() => { attachment.MeshOptions.Add(new Model3DAttachment.MeshOption { Id = "MeshOption", }); })); list.Components.Add(widgetFactory); return(pane); }
public Inspector(Widget panelWidget) { PanelWidget = panelWidget; RootWidget = new Widget { Layout = new VBoxLayout() }; var toolbarArea = new Widget { Layout = new StackLayout(), Padding = new Thickness(4, 0) }; contentWidget = new ThemedScrollView(); RootWidget.AddNode(toolbarArea); RootWidget.AddNode(contentWidget); RootWidget.Gestures.Add(DropFilesGesture = new DropFilesGesture()); contentWidget.Content.Layout = new VBoxLayout(); Toolbar = new ToolbarView(toolbarArea, GetToolbarLayout()); Objects = new List <object>(); content = new InspectorContent(contentWidget.Content) { Footer = new Widget { MinHeight = 300.0f }, History = Document.Current.History }; DropFilesGesture.Recognized += content.DropFiles; CreateWatchersToRebuild(); OnCreate?.Invoke(this); }
private static Widget CreateMaterialEffectsPane(Model3DAttachment attachment) { var pane = new ThemedScrollView(); pane.Content.Padding = new Thickness { Right = 10 }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.MaterialEffect>( w => new MaterialEffectRow(w, attachment.MaterialEffects), attachment.MaterialEffects); widgetFactory.AddHeader(MaterialEffectRow.CreateHeader()); widgetFactory.AddFooter(DeletableRow <Model3DAttachment.MaterialEffect> .CreateFooter(() => { history.DoTransaction(() => { Core.Operations.InsertIntoList.Perform( attachment.MaterialEffects, attachment.MaterialEffects.Count, new Model3DAttachment.MaterialEffect { Name = "MaterialEffect", MaterialName = "MaterialName", Path = "MaterialPath", } ); }); })); list.Components.Add(widgetFactory); return(pane); }
private static Widget CreateMeshOptionsPane(Model3DAttachment attachment) { var pane = new ThemedScrollView(); pane.Content.Padding = new Thickness { Right = 10 }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.MeshOption>( w => new MeshRow(w, attachment.MeshOptions), attachment.MeshOptions); widgetFactory.AddHeader(MeshRow.CreateHeader()); widgetFactory.AddFooter(MeshRow.CreateFooter(() => { history.DoTransaction(() => Core.Operations.InsertIntoList.Perform( attachment.MeshOptions, attachment.MeshOptions.Count, new Model3DAttachment.MeshOption { Id = "MeshOption" } )); })); list.Components.Add(widgetFactory); return(pane); }
Widget CreateGeneralPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; pane.Content.Layout = new VBoxLayout { Spacing = 4 }; new Vector2PropertyEditor( new PropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, nameof(Tangerine.AppUserPreferences.DefaultSceneDimensions), "Default scene dimensions")); new BooleanPropertyEditor( new PropertyEditorParams(pane.Content, CoreUserPreferences.Instance, nameof(CoreUserPreferences.AutoKeyframes), "Automatic keyframes")); new BooleanPropertyEditor( new PropertyEditorParams(pane.Content, UI.Timeline.TimelineUserPreferences.Instance, nameof(UI.Timeline.TimelineUserPreferences.AnimationMode), "Animation mode")); new IntPropertyEditor( new PropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, nameof(Tangerine.AppUserPreferences.AutosaveDelay), "Autosave delay")); var boneWidthPropertyEditor = new FloatPropertyEditor( new PropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, nameof(UI.SceneView.SceneUserPreferences.DefaultBoneWidth), "Bone Width")); boneWidthPropertyEditor.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.DefaultBoneWidth, (v) => Application.InvalidateWindows()); return(pane); }
Widget CreateGeneralPane() { var parent = new Widget(); parent.Layout = new VBoxLayout { Spacing = 0 }; parent.Padding = contentPadding; var platform = new Widget(); platform.Layout = new HBoxLayout { Spacing = 4, DefaultCell = new DefaultLayoutCell(Alignment.Center) }; platform.Padding = contentPadding; platform.AddNode(new ThemedSimpleText("Target platform")); var platformPicker = (Orange.The.UI as OrangeInterface).PlatformPicker; platformPicker.Unlink(); platform.AddNode(platformPicker); parent.AddNode(platform); var pane = new ThemedScrollView(); pane.Content.Layout = new VBoxLayout { Spacing = 4 }; pane.Content.Padding = contentPadding; editors.AddRange(new IPropertyEditor[] { new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ReloadModifiedFiles), displayName: "Reload modified files")), new Vector2PropertyEditor( new PreferencesPropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, propertyName: nameof(Tangerine.AppUserPreferences.DefaultSceneDimensions), displayName: "Default scene dimensions")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.AutoKeyframes), displayName: "Automatic keyframes")), new IntPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, propertyName: nameof(Tangerine.AppUserPreferences.AutosaveDelay), displayName: "Autosave delay")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.StopAnimationOnCurrentFrame), displayName: "Stop animaion on current frame")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ShowSceneThumbnail), displayName: "Show scene thumbnail")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ShowSplinesGlobally), displayName: "Show splines globally")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.DontPasteAtMouse), displayName: "Don't paste at mouse pointer")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.InverseShiftKeyframeDrag), displayName: "Inverse Shift behaviour when dragging keyframes")), new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.SwapMouseButtonsForKeyframeSwitch), displayName: "Swap mouse buttons for keyframe switch")), }); var boneWidthPropertyEditor = new FloatPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, propertyName: nameof(UI.SceneView.SceneUserPreferences.DefaultBoneWidth), displayName: "Bone Width")); boneWidthPropertyEditor.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.DefaultBoneWidth, (v) => Application.InvalidateWindows()); new EnumPropertyEditor <KeyFunction>( new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.DefaultKeyFunction), displayName: "Default interpolation")); parent.AddNode(pane); return(parent); }
public override void Initialize() { Tab = new ThemedTab { Text = "Devices" }; Content = new Widget { Layout = new VBoxLayout(), Nodes = { (mainToolbar = new RemoteScriptingWidgets.Toolbar()), new Widget { Layout = new HBoxLayout(), Nodes = { (devicesScrollView = new ThemedScrollView { MinMaxWidth = 300, TabTravesable = new TabTraversable() }), (deviceWidgetPlaceholder = new Widget() { Layout = new HBoxLayout() }) } } } }; RefreshMainToolbar(); Content.AddChangeWatcher( () => CompiledAssembly.Instance, _ => { RefreshMainToolbar(); } ); void SelectDeviceBasedOnMousePosition() { devicesScrollView.SetFocus(); var index = (devicesScrollView.Content.LocalMousePosition().Y / rowHeight).Floor(); if (index < devices.Count) { SelectDevice(index); } } var mouseDownGesture = new ClickGesture(0); mouseDownGesture.Began += SelectDeviceBasedOnMousePosition; devicesScrollView.Gestures.Add(mouseDownGesture); devicesScrollView.Content.CompoundPresenter.Insert(0, new SyncDelegatePresenter <Widget>(w => { w.PrepareRendererState(); Renderer.DrawRect( 0, rowHeight * selectedDeviceIndex, w.Width, rowHeight * (selectedDeviceIndex + 1), devicesScrollView.IsFocused() ? Theme.Colors.SelectedBackground : Theme.Colors.SelectedInactiveBackground ); })); }
public Preview() { var t = PrepareChessTexture(Theme.Colors.ZebraColor1.Transparentify(0.5f), Theme.Colors.ZebraColor2); const float ChessCellSize = 50; //Color4 Color1 = Core.UserPreferences.Instance.Get<UserPreferences>().BackgroundColorA; //Color4 Color2 = Core.UserPreferences.Instance.Get<UserPreferences>().BackgroundColorB; RootWidget = new ThemedScrollView(); RootWidget.Content.Layout = new FlowLayout { Spacing = 5.0f, }; RootWidget.Content.Padding = new Thickness(5.0f); RootWidget.CompoundPresenter.Insert(1, new SyncDelegatePresenter <Widget>((w) => { w.PrepareRendererState(); var ratio = ChessCellSize * 1.0f; Renderer.DrawSprite( t, Color4.White, Vector2.Zero, w.Size, -Vector2.Zero / ratio, (w.Size - Vector2.Zero) / ratio); })); RootWidget.Updated += (dt) => { if (RootWidget.IsMouseOver()) { if (!RootWidget.Input.IsKeyPressed(Key.Control)) { return; } int zoomDelta = 0; if (RootWidget.Input.WasKeyPressed(Key.MouseWheelUp)) { zoomDelta = 1; } if (RootWidget.Input.WasKeyPressed(Key.MouseWheelDown)) { zoomDelta = -1; } if (zoomDelta != 0) { for (int i = 0; i < zoom.Count; i++) { var z = zoom[i]; int newZoom = Mathf.Clamp(z.Item1 + zoomDelta, 0, z.Item2); if (newZoom != z.Item1) { zoom[i] = new Tuple <int, int>(newZoom, z.Item2); } } ApplyZoom(); } } }; }
public AnimationsPanel(Widget panelWidget) { Instance = this; this.panelWidget = panelWidget; scrollView = new ThemedScrollView { TabTravesable = new TabTraversable() }; this.rootWidget = new Frame { Id = "AnimationsPanel", Padding = new Thickness(4), Layout = new VBoxLayout { Spacing = 4 }, Nodes = { scrollView } }; scrollView.Content.CompoundPresenter.Insert(0, new SyncDelegatePresenter <Widget>(w => { w.PrepareRendererState(); var selectedIndex = GetSelectedAnimationIndex(); Renderer.DrawRect( 0, rowHeight * selectedIndex, w.Width, rowHeight * (selectedIndex + 1), scrollView.IsFocused() ? Theme.Colors.SelectedBackground : Theme.Colors.SelectedInactiveBackground); })); var dragGesture = new DragGesture(0); dragGesture.Recognized += () => { var index = (scrollView.Content.LocalMousePosition().Y / rowHeight).Floor(); if (index >= 0 && index < GetAnimations().Count) { var animation = GetAnimations()[index]; if (!animation.IsLegacy && animation != Document.Current.Animation) { // Dirty hack: using a file drag&drop mechanics for dropping animation clips on the timeline grid. var encodedAnimationId = Convert.ToBase64String(Encoding.UTF8.GetBytes(animation.Id)); // DragFiles in Winforms blocks execution, call it on the next update Application.InvokeOnNextUpdate(() => { Window.Current.DragFiles(new[] { encodedAnimationId }); }); } } }; var mouseDownGesture = new ClickGesture(0); mouseDownGesture.Recognized += SelectAnimationBasedOnMousePosition; scrollView.Gestures.Add(dragGesture); scrollView.Gestures.Add(new ClickGesture(1, ShowContextMenu)); scrollView.Gestures.Add(mouseDownGesture); scrollView.Gestures.Add(new DoubleClickGesture(0, RenameAnimation)); scrollView.LateTasks.Add(ProcessCommandsTask); scrollView.AddChangeWatcher(CalcAnimationsHashCode, _ => Refresh()); }
private VisualHintsPanel(Panel panel) { if (Instance != null) { throw new InvalidOperationException(); } Instance = this; this.panel = panel; rootWidget = new ThemedScrollView(); rootWidget.Content.Layout = new VBoxLayout { Spacing = 6 }; panel.ContentWidget.AddNode(rootWidget); }
public void Rebuild() { Nodes.Clear(); pane = new ThemedScrollView(); pane.Content.Layout = new VBoxLayout { Spacing = 4 }; pane.Content.Padding = new Thickness(10); var flags = BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Instance; foreach (var color in typeof(Theme.ColorTheme).GetProperties(flags)) { if (color.PropertyType != typeof(Color4)) { continue; } CreateColorEditor( pane, AppUserPreferences.Instance.LimeColorTheme, color.Name, $"Basic {color.Name}", () => color.GetValue(Theme.Colors) ); } foreach (var category in typeof(ColorTheme).GetProperties(flags)) { if (category.Name == "Basic") { continue; } foreach (var color in category.PropertyType.GetProperties(flags)) { if (color.PropertyType != typeof(Color4)) { continue; } CreateColorEditor( pane, category.GetValue(AppUserPreferences.Instance.ColorTheme), color.Name, $"{category.Name} {color.Name}", () => color.GetValue(category.GetValue(AppUserPreferences.Instance.ColorTheme)) ); } } AddNode(CreateSearchBox()); AddNode(pane); }
private static Widget CreateGeneralPane(Model3DAttachment attachment) { var pane = new ThemedScrollView(); pane.Content.Padding = new Thickness(10, AttachmentMetrics.Spacing); pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; new FloatPropertyEditor(Decorate(new PropertyEditorParams( pane.Content, attachment, nameof(Model3DAttachment.ScaleFactor), nameof(Model3DAttachment.ScaleFactor)), displayLabel: true)); return(pane); }
private Widget CreateGeneralPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; new FloatPropertyEditor( new PropertyEditorParams(pane.Content, attachment, nameof(Model3DAttachment.ScaleFactor), "Scale Factor")); return(pane); }
private Widget CreateColorsPane() { var pane = new ThemedScrollView { Padding = new Thickness { Right = 15, }, }; pane.Content.Layout = new VBoxLayout { Spacing = 4 }; new EnumPropertyEditor <ColorThemeEnum>( new PropertyEditorParams(pane.Content, AppUserPreferences.Instance, nameof(Tangerine.AppUserPreferences.Theme), "User interface theme")); var tmp = new BooleanPropertyEditor( new PropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, nameof(UI.SceneView.SceneUserPreferences.EnableChessBackground), "Chess background")); tmp.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.EnableChessBackground, (v) => Application.InvalidateWindows()); tmp = new BooleanPropertyEditor( new PropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, nameof(UI.SceneView.SceneUserPreferences.DrawFrameBorder), "Draw frame border")); tmp.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.DrawFrameBorder, (v) => Application.InvalidateWindows()); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.BackgroundColorA), "Background color A", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.BackgroundColorA, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.BackgroundColorB), "Background color B", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.BackgroundColorB, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.RootWidgetOverlayColor), "Root overlay color", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.RootWidgetOverlayColor, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.AnimationPreviewBackground), "Animation preview background", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => Color4.Black.Transparentify(0.6f), pane); return(pane); }
private void ProcessChangeViewMode() { if ( ScrollView.Input.IsKeyPressed(Key.Control) && (ScrollView.Input.WasKeyPressed(Key.MouseWheelDown) || ScrollView.Input.WasKeyPressed(Key.MouseWheelUp)) ) { ScrollView.Unlink(); if (ScrollView.Direction == ScrollDirection.Horizontal) { ScrollView = new ThemedScrollView(ScrollDirection.Vertical) { TabTravesable = new TabTraversable(), }; ScrollView.Content.Layout = new FlowLayout(LayoutDirection.LeftToRight) { Spacing = 1.0f }; } else { ScrollView = new ThemedScrollView(ScrollDirection.Horizontal) { TabTravesable = new TabTraversable(), }; ScrollView.Content.Layout = new FlowLayout(LayoutDirection.TopToBottom) { Spacing = 1.0f }; } ScrollView.Content.Padding = new Thickness(5.0f); ScrollView.Content.CompoundPostPresenter.Insert(0, new SyncDelegatePresenter <Widget>(RenderFilesWidgetRectSelection)); ScrollView.Updated += ScrollViewUpdated; ScrollView.Content.Presenter = new SyncDelegatePresenter <Widget>((w) => { w.PrepareRendererState(); var wp = w.ParentWidget; var p = wp.Padding; Renderer.DrawRect(-w.Position + Vector2.Zero - new Vector2(p.Left, p.Top), -w.Position + wp.Size + new Vector2(p.Right, p.Bottom), Theme.Colors.WhiteBackground); }); InvalidateView(model.CurrentPath); lastKeyboardSelectedFilesystemItem = ScrollView.Content.FirstChild as FilesystemItem; selectionPreviewSplitter.Nodes.Insert(0, ScrollView); } }
private void CreateColorEditor(ThemedScrollView container, object source, string propertyName, string displayName, Func <object> valueGetter) { var tmp = new Color4PropertyEditor( new PreferencesPropertyEditorParams( container.Content, source, propertyName: propertyName, displayName: displayName ) { DefaultValueGetter = valueGetter } ); tmp.Changed += Editor_Changed; }
public FilesystemView() { RootWidget = new Widget() { Id = "FSRoot" }; RootWidget.FocusScope = new KeyboardFocusScope(RootWidget); ScrollView = new ThemedScrollView(ScrollDirection.Horizontal) { TabTravesable = new TabTraversable(), }; crEditor = new CookingRulesEditor(NavigateAndSelect); crEditor.RootWidget.TabTravesable = new TabTraversable(); preview = new Preview(); preview.RootWidget.TabTravesable = new TabTraversable(); }
public FilesystemView() { RootWidget = new Widget() { Id = "FSRoot" }; RootWidget.FocusScope = new KeyboardFocusScope(RootWidget); scrollView = new ThemedScrollView { TabTravesable = new TabTraversable() }; // TODO: Display path RootWidget.AddChangeWatcher(() => model.CurrentPath, (path) => toolbar.Path = path.ToString()); crEditor = new CookingRulesEditor(NavigateAndSelect); crEditor.RootWidget.TabTravesable = new TabTraversable(); preview = new Preview(); preview.RootWidget.TabTravesable = new TabTraversable(); }
private Widget CreateColorsPane() { var pane = new ThemedScrollView(); pane.Content.Layout = new VBoxLayout { Spacing = 4 }; pane.Content.Padding = contentPadding; var tmp = new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, propertyName: nameof(UI.SceneView.SceneUserPreferences.EnableChessBackground), displayName: "Chess background")); tmp.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.EnableChessBackground, (v) => Application.InvalidateWindows()); tmp = new BooleanPropertyEditor( new PreferencesPropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, propertyName: nameof(UI.SceneView.SceneUserPreferences.DrawFrameBorder), displayName: "Draw frame border")); tmp.ContainerWidget.AddChangeWatcher( () => UI.SceneView.SceneUserPreferences.Instance.DrawFrameBorder, (v) => Application.InvalidateWindows()); editors.Add(tmp); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.BackgroundColorA), "Background color A", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.BackgroundColorA, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.BackgroundColorB), "Background color B", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.BackgroundColorB, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.RootWidgetOverlayColor), "Root overlay color", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => ColorTheme.Current.SceneView.RootWidgetOverlayColor, pane); CreateColorPropertyEditor( nameof(UI.SceneView.SceneUserPreferences.AnimationPreviewBackground), "Animation preview background", Core.UserPreferences.Instance.Get <UI.SceneView.SceneUserPreferences>(), () => Color4.Black.Transparentify(0.6f), pane); return(pane); }
IEnumerator <object> UpdateDragCursor(ThemedScrollView selectedShortcutsView, HotkeyEditor hotkeyEditor) { while (true) { var nodeUnderMouse = WidgetContext.Current.NodeUnderMouse; bool allowDrop = (nodeUnderMouse == selectedShortcutsView && hotkeyEditor.Main != Key.Unknown) || (nodeUnderMouse as KeyboardButton != null && !(nodeUnderMouse as KeyboardButton).Key.IsModifier()); if (allowDrop) { Utils.ChangeCursorIfDefault(Cursors.DragHandOpen); } else { Utils.ChangeCursorIfDefault(Cursors.DragHandClosed); } yield return(null); } }
public Inspector(Widget panelWidget) { PanelWidget = panelWidget; RootWidget = new ThemedScrollView(); var toolbarArea = new Widget { Layout = new StackLayout(), Padding = new Thickness(4, 0) }; contentWidget = new Widget(); RootWidget.Content.AddNode(toolbarArea); RootWidget.Content.AddNode(contentWidget); RootWidget.Content.Layout = new VBoxLayout(); Toolbar = new Toolbar(toolbarArea); contentWidget.Layout = new VBoxLayout { Tag = "InspectorContent" }; Objects = new List <object>(); content = new InspectorContent(contentWidget); CreateWatchersToRebuild(); SetupToolbar(); }
public BackupHistoryPanel(Widget panelWidget) { Instance = this; this.panelWidget = panelWidget; scrollView = new ThemedScrollView { TabTravesable = new TabTraversable() }; this.rootWidget = new Frame { Id = "BackupHistoryPanel", Padding = new Thickness(4), Layout = new VBoxLayout { Spacing = 4 }, Nodes = { scrollView } }; resultPane = scrollView.Content; resultPane.CompoundPresenter.Insert(0, new SyncDelegatePresenter <Widget>(w => { w.PrepareRendererState(); if (selectedIndex == 0) { if (history?.Count > 0) { Renderer.DrawRect( 0, rowHeight * selectedIndex, w.Width, (selectedIndex + 1) * rowHeight, Theme.Colors.SelectedBackground); } } if (history?.Count > 0) { Renderer.DrawRect( 0, rowHeight * selectedIndex, w.Width, (selectedIndex + 1) * rowHeight, Theme.Colors.SelectedBackground); } })); scrollView.LateTasks.Add(new KeyRepeatHandler(ScrollView_KeyRepeated)); }
private static Widget CreateAnimationsPane(Model3DAttachment attachment) { var pane = new ThemedScrollView { Padding = new Thickness { Right = 10 }, }; var list = new Widget { Layout = new VBoxLayout(), }; pane.Content.Layout = new VBoxLayout { Spacing = AttachmentMetrics.Spacing }; pane.Content.AddNode(list); var widgetFactory = new AttachmentWidgetFactory <Model3DAttachment.Animation>( w => new AnimationRow(w, attachment.Animations), attachment.Animations); widgetFactory.AddHeader(AnimationRow.CreateHeader()); widgetFactory.AddFooter(AnimationRow.CreateFooter(() => { history.DoTransaction(() => Core.Operations.InsertIntoList.Perform( attachment.Animations, attachment.Animations.Count, new Model3DAttachment.Animation { Name = "Animation", } )); })); if (attachment.Animations.All(a => a.Name != Model3DAttachment.DefaultAnimationName)) { attachment.Animations.Insert(0, new Model3DAttachment.Animation { Name = Model3DAttachment.DefaultAnimationName, }); } list.Components.Add(widgetFactory); return(pane); }
public Inspector(Widget panelWidget) { PanelWidget = panelWidget; RootWidget = new ThemedScrollView(); var toolbarArea = new Widget { Layout = new StackLayout(), Padding = new Thickness(4, 0) }; contentWidget = new Widget(); RootWidget.Content.AddNode(toolbarArea); RootWidget.Content.AddNode(contentWidget); RootWidget.Content.Layout = new VBoxLayout(); Toolbar = new ToolbarView(toolbarArea, GetToolbarLayout()); contentWidget.Layout = new VBoxLayout(); Objects = new List <object>(); content = new InspectorContent(contentWidget) { Footer = new Widget { MinHeight = 300.0f }, History = Document.Current.History }; CreateWatchersToRebuild(); }
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 void UpdateAllShortcutsView(ThemedScrollView allShortcutsView, ThemedScrollView selectedShortcutsView, HotkeyEditor hotkeyEditor, string filter) { allShortcutsView.Content.Nodes.Clear(); if (hotkeyEditor.Profile == null) { return; } foreach (var category in hotkeyEditor.Profile.Categories) { var expandableContent = new Frame { Layout = new VBoxLayout { Spacing = 4 }, Visible = true }; var expandButton = new ThemedExpandButton { Anchors = Anchors.Left, MinMaxSize = Vector2.One * 20f, Expanded = expandableContent.Visible }; var title = new ThemedSimpleText { Text = category.Title, VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, stretchX: 0) }; expandButton.Clicked += () => { expandableContent.Visible = !expandableContent.Visible; expandButton.Expanded = expandableContent.Visible; }; var header = new Widget { Layout = new HBoxLayout(), Nodes = { expandButton, title } }; allShortcutsView.Content.AddNode(header); allShortcutsView.Content.AddNode(expandableContent); var filteredCommands = String.IsNullOrEmpty(filter) ? category.Commands.Values : category.Commands.Values.Where(i => i.Title.ToLower().Contains(filter)); title.Color = filteredCommands.Any() ? Theme.Colors.BlackText : Theme.Colors.GrayText; expandButton.Enabled = filteredCommands.Any(); foreach (var command in filteredCommands) { var editor = new ShortcutPropertyEditor( new PreferencesPropertyEditorParams(expandableContent, command, propertyName: "Shortcut", displayName: command.Title)); editor.PropertyLabel.OverflowMode = TextOverflowMode.Ellipsis; editor.PropertyLabel.LayoutCell = new LayoutCell(Alignment.LeftCenter, 1); editor.PropertyLabel.Padding = new Thickness(expandButton.Width, 0); editor.PropertyLabel.CompoundPresenter.RemoveAll(i => i as SelectionPresenter != null); editor.PropertyLabel.Caret = new CaretPosition(); if (!String.IsNullOrEmpty(filter)) { var mc = new MultiCaretPosition(); var start = new CaretPosition { IsVisible = true, WorldPos = new Vector2(1, 1) }; var finish = new CaretPosition { IsVisible = true, WorldPos = new Vector2(1, 1) }; mc.Add(start); mc.Add(finish); editor.PropertyLabel.Caret = mc; start.TextPos = editor.PropertyLabel.Text.ToLower().IndexOf(filter); finish.TextPos = start.TextPos + filter.Length; new SelectionPresenter(editor.PropertyLabel, start, finish, new SelectionParams() { Color = Theme.Colors.TextSelection, OutlineThickness = 0 }); } editor.ContainerWidget.LayoutCell = new LayoutCell(Alignment.LeftCenter, 1); editor.PropertyChanged = () => { hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); }; var dragGesture = new DragGesture(); editor.ContainerWidget.Gestures.Add(dragGesture); var task = new Task(UpdateDragCursor(selectedShortcutsView, hotkeyEditor)); dragGesture.Recognized += () => editor.ContainerWidget.LateTasks.Add(task); dragGesture.Ended += () => { editor.ContainerWidget.LateTasks.Remove(task); var nodeUnderMouse = WidgetContext.Current.NodeUnderMouse; if (nodeUnderMouse == selectedShortcutsView && hotkeyEditor.Main != Key.Unknown) { if (hotkeyEditor.Main != Key.Unknown) { command.Shortcut = new Shortcut(hotkeyEditor.Modifiers, hotkeyEditor.Main); hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); hotkeyEditor.SetFocus(); } } else if (nodeUnderMouse as KeyboardButton != null) { var button = nodeUnderMouse as KeyboardButton; if (Shortcut.ValidateMainKey(button.Key) && !button.Key.IsModifier()) { command.Shortcut = new Shortcut(hotkeyEditor.Modifiers, button.Key); hotkeyEditor.UpdateButtonCommands(); hotkeyEditor.UpdateShortcuts(); hotkeyEditor.SetFocus(); } } }; } } }