protected override void OnResize(int newWidth, int newHeight) { var w = newWidth > MinWidth ? newWidth : MinWidth; var h = newHeight > MinHeight ? newHeight : MinHeight; RootWidget.Move((w - MinWidth) / 2, (h - MinHeight) / 2); }
public WhiteboardMenuButton(string buttonIconPath, WhiteboardPlugin plugin) : base(buttonIconPath) { m_plugin = plugin; m_rootWidget = DrawArgs.NewRootWidget; this.Description = "Whiteboard"; this.SetPushed(true); }
void InitializeWidgets() { RootWidget.AddChangeWatcher(() => selection.Version, Selection_Changed); 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); }); RootWidget.AddChangeWatcher(() => dragState, (ds) => Window.Current.Invalidate()); RootWidget.AddChangeWatcher(() => dragEndPosition, WhenSelectionRectChanged); RootWidget.AddChangeWatcher(() => WidgetContext.Current.NodeUnderMouse, (value) => { if (value != null && ScrollView.Content == value.Parent) { Window.Current.Invalidate(); } }); RootWidget.AddChangeWatcher(() => model.CurrentPath, (p) => { var up = RootWidget.Components.Get <ViewNodeComponent>().ViewNode as FSViewNode; up.Path = p; AddToNavHystory(p); selection.Clear(); InvalidateView(p); InvalidateFSWatcher(p); preview.ClearTextureCache(); lastKeyboardSelectedFilesystemItem = ScrollView.Content.FirstChild as FilesystemItem; }); RootWidget.Layout = new VBoxLayout(); RootWidget.AddNode((cookingRulesSplitter = new ThemedHSplitter { Nodes = { (new Widget { Layout = new VBoxLayout(), Nodes = { toolbar, (selectionPreviewSplitter = new ThemedVSplitter{ Nodes = { ScrollView, preview.RootWidget, } }) } }), crEditor.RootWidget, } })); }
private void RegisterHotkeys() { // General Hotkeys.Register(Key.Escape, () => { escapeWindow.Visible = !escapeWindow.Visible; // bring to front escapeWindow.Remove(); RootWidget.AddChild(escapeWindow); }); // HUD Menu Hotkeys.Register(Key.Tab, () => HudMenu.Activate(HudMenu.Button.Inventory)); Hotkeys.Register(Key.E, KeyModifiers.Control, () => HudMenu.Activate(HudMenu.Button.Equipment)); Hotkeys.Register(Key.T, KeyModifiers.Control, () => HudMenu.Activate(HudMenu.Button.Character)); Hotkeys.Register(Key.B, KeyModifiers.Control, () => HudMenu.Activate(HudMenu.Button.BuddyList)); }
public void DragStart(TransferDataSource data, DragDropAction dragAction, object image, double xhot, double yhot) { var lo = RootWidget.ConvertPointToBase(new PointF(Widget.Bounds.X, Widget.Bounds.Y)); lo = RootWidget.Window.ConvertBaseToScreen(lo); var ml = NSEvent.CurrentMouseLocation; var pb = NSPasteboard.FromName(NSPasteboard.NSDragPasteboardName); if (pb == null) { throw new InvalidOperationException("Could not get pasteboard"); } if (data == null) { throw new ArgumentNullException("data"); } InitPasteboard(pb, data); var img = (NSImage)image; var pos = new PointF(ml.X - lo.X - (float)xhot, lo.Y - ml.Y - (float)yhot + img.Size.Height); Widget.DragImage(img, pos, new SizeF(0, 0), NSApplication.SharedApplication.CurrentEvent, pb, Widget, true); }
public void DragStart(DragStartData sdata) { var lo = RootWidget.ConvertPointToBase(new PointF(Widget.Bounds.X, Widget.Bounds.Y)); lo = RootWidget.Window.ConvertBaseToScreen(lo); var ml = NSEvent.CurrentMouseLocation; var pb = NSPasteboard.FromName(NSPasteboard.NSDragPasteboardName); if (pb == null) { throw new InvalidOperationException("Could not get pasteboard"); } if (sdata.Data == null) { throw new ArgumentNullException("data"); } InitPasteboard(pb, sdata.Data); var img = (NSImage)sdata.ImageBackend; var pos = new PointF(ml.X - lo.X - (float)sdata.HotX, lo.Y - ml.Y - (float)sdata.HotY + img.Size.Height); Widget.DragImage(img, pos, new SizeF(0, 0), NSApplication.SharedApplication.CurrentEvent, pb, Widget, true); }
protected BaseScreen() { this.rootWidget = new RootWidget(this); this.hotkeys = new HotkeyManager(); }