IEnumerator <object> ProcessCommandsTask() { while (true) { yield return(null); if (!scrollView.IsFocused()) { continue; } if (Commands.Down.Consume()) { SelectAnimation(GetSelectedAnimationIndex() + 1); } if (Commands.Up.Consume()) { scrollView.SetFocus(); SelectAnimation(GetSelectedAnimationIndex() - 1); } if (!Commands.Delete.IsConsumed()) { Command.Delete.Enabled = !Document.Current.Animation.IsLegacy; if (Commands.Delete.Consume()) { Delete(); } } } }
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)); }
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 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 void ScrollViewUpdated(float dt) { ProcessInputOverFSItem(); ProcessDragState(dt); typeNavigationTimeout -= dt; if (scrollView.IsFocused()) { ProcessTypingNavigation(); ProcessOtherCommands(); ProcessSelectionCommands(); foreach (var c in printableKeysCommands) { c.Consume(); } } }