public CanvasWindow (Document document) : base (2, 2, false) { scrolled_window = new ScrolledWindow (); var vp = new Viewport () { ShadowType = ShadowType.None }; Canvas = new PintaCanvas (this, document) { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask)16134 }; // Rulers horizontal_ruler = new HRuler (); horizontal_ruler.Metric = MetricType.Pixels; Attach (horizontal_ruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vertical_ruler = new VRuler (); vertical_ruler.Metric = MetricType.Pixels; Attach (vertical_ruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); scrolled_window.Hadjustment.ValueChanged += delegate { UpdateRulerRange (); }; scrolled_window.Vadjustment.ValueChanged += delegate { UpdateRulerRange (); }; document.Workspace.CanvasSizeChanged += delegate { UpdateRulerRange (); }; Canvas.MotionNotifyEvent += delegate (object o, MotionNotifyEventArgs args) { if (!PintaCore.Workspace.HasOpenDocuments) return; var point = PintaCore.Workspace.WindowPointToCanvas (args.Event.X, args.Event.Y); horizontal_ruler.Position = point.X; vertical_ruler.Position = point.Y; }; Attach (scrolled_window, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); scrolled_window.Add (vp); vp.Add (Canvas); ShowAll (); Canvas.Show (); vp.Show (); horizontal_ruler.Visible = false; vertical_ruler.Visible = false; Canvas.SizeAllocated += delegate { UpdateRulerRange (); }; }
public CanvasWindow(Document document) : base(2, 2, false) { scrolled_window = new ScrolledWindow(); var vp = new Viewport() { ShadowType = ShadowType.None }; Canvas = new PintaCanvas(this, document) { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask) 16134 }; // Rulers horizontal_ruler = new HRuler(); horizontal_ruler.Metric = MetricType.Pixels; Attach(horizontal_ruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vertical_ruler = new VRuler(); vertical_ruler.Metric = MetricType.Pixels; Attach(vertical_ruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); scrolled_window.Hadjustment.ValueChanged += delegate { UpdateRulerRange(); }; scrolled_window.Vadjustment.ValueChanged += delegate { UpdateRulerRange(); }; document.Workspace.CanvasSizeChanged += delegate { UpdateRulerRange(); }; Canvas.MotionNotifyEvent += delegate(object o, MotionNotifyEventArgs args) { if (!PintaCore.Workspace.HasOpenDocuments) { return; } var point = PintaCore.Workspace.WindowPointToCanvas(args.Event.X, args.Event.Y); horizontal_ruler.Position = point.X; vertical_ruler.Position = point.Y; }; Attach(scrolled_window, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); scrolled_window.Add(vp); vp.Add(Canvas); ShowAll(); Canvas.Show(); vp.Show(); horizontal_ruler.Visible = false; vertical_ruler.Visible = false; Canvas.SizeAllocated += delegate { UpdateRulerRange(); }; }
private void CreateDockAndPads(HBox container) { // Create canvas Table mainTable = new Table (2, 2, false); sw = new ScrolledWindow () { Name = "sw", ShadowType = ShadowType.EtchedOut }; Viewport vp = new Viewport () { ShadowType = ShadowType.None }; canvas = new PintaCanvas () { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask)16134 }; // Dock widget dock = new DockFrame (); dock.CompactGuiLevel = 5; Gtk.IconFactory fact = new Gtk.IconFactory (); fact.Add ("Tools.Pencil.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Tools.Pencil.png"))); fact.Add ("Pinta.png", new Gtk.IconSet (PintaCore.Resources.GetIcon ("Pinta.png"))); fact.AddDefault (); // Toolbox pad DockItem toolbox_item = dock.AddItem ("Toolbox"); toolbox = new ToolBoxWidget () { Name = "toolbox" }; toolbox_item.Label = Catalog.GetString ("Tools"); toolbox_item.Content = toolbox; toolbox_item.Icon = PintaCore.Resources.GetIcon ("Tools.Pencil.png"); toolbox_item.Behavior |= DockItemBehavior.CantClose; toolbox_item.DefaultWidth = 65; Gtk.Action show_toolbox = show_pad.AppendAction ("Tools", Catalog.GetString ("Tools"), null, "Tools.Pencil.png"); show_toolbox.Activated += delegate { toolbox_item.Visible = true; }; // Palette pad DockItem palette_item = dock.AddItem ("Palette"); color = new ColorPaletteWidget () { Name = "color" }; palette_item.Label = Catalog.GetString ("Palette"); palette_item.Content = color; palette_item.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); palette_item.DefaultLocation = "Toolbox/Bottom"; palette_item.Behavior |= DockItemBehavior.CantClose; palette_item.DefaultWidth = 65; Gtk.Action show_palette = show_pad.AppendAction ("Palette", Catalog.GetString ("Palette"), null, "Pinta.png"); show_palette.Activated += delegate { palette_item.Visible = true; }; // Canvas pad DockItem documentDockItem = dock.AddItem ("Canvas"); documentDockItem.Behavior = DockItemBehavior.Locked; documentDockItem.Expand = true; documentDockItem.DrawFrame = false; documentDockItem.Label = Catalog.GetString ("Documents"); documentDockItem.Content = mainTable; //rulers hruler = new HRuler (); hruler.Metric = MetricType.Pixels; mainTable.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vruler = new VRuler (); vruler.Metric = MetricType.Pixels; mainTable.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); sw.Hadjustment.ValueChanged += delegate { UpdateRulerRange (); }; sw.Vadjustment.ValueChanged += delegate { UpdateRulerRange (); }; PintaCore.Workspace.CanvasSizeChanged += delegate { UpdateRulerRange (); }; canvas.MotionNotifyEvent += delegate (object o, MotionNotifyEventArgs args) { if (!PintaCore.Workspace.HasOpenDocuments) return; Cairo.PointD point = PintaCore.Workspace.WindowPointToCanvas (args.Event.X, args.Event.Y); hruler.Position = point.X; vruler.Position = point.Y; }; mainTable.Attach (sw, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); sw.Add (vp); vp.Add (canvas); mainTable.ShowAll (); canvas.Show (); vp.Show (); HideRulers(); // Layer pad layers = new LayersListWidget (); DockItem layers_item = dock.AddItem ("Layers"); DockItemToolbar layers_tb = layers_item.GetToolbar (PositionType.Bottom); layers_item.Label = Catalog.GetString ("Layers"); layers_item.Content = layers; layers_item.Icon = PintaCore.Resources.GetIcon ("Menu.Layers.MergeLayerDown.png"); layers_tb.Add (PintaCore.Actions.Layers.AddNewLayer.CreateDockToolBarItem ()); layers_tb.Add (PintaCore.Actions.Layers.DeleteLayer.CreateDockToolBarItem ()); layers_tb.Add (PintaCore.Actions.Layers.DuplicateLayer.CreateDockToolBarItem ()); layers_tb.Add (PintaCore.Actions.Layers.MergeLayerDown.CreateDockToolBarItem ()); layers_tb.Add (PintaCore.Actions.Layers.MoveLayerUp.CreateDockToolBarItem ()); layers_tb.Add (PintaCore.Actions.Layers.MoveLayerDown.CreateDockToolBarItem ()); Gtk.Action show_layers = show_pad.AppendAction ("Layers", Catalog.GetString ("Layers"), null, "Menu.Layers.MergeLayerDown.png"); show_layers.Activated += delegate { layers_item.Visible = true; }; // History pad HistoryTreeView history = new HistoryTreeView (); DockItem history_item = dock.AddItem ("History"); DockItemToolbar history_tb = history_item.GetToolbar (PositionType.Bottom); history_item.Label = Catalog.GetString ("History"); history_item.DefaultLocation = "Layers/Bottom"; history_item.Content = history; history_item.Icon = PintaCore.Resources.GetIcon ("Menu.Layers.DuplicateLayer.png"); history_tb.Add (PintaCore.Actions.Edit.Undo.CreateDockToolBarItem ()); history_tb.Add (PintaCore.Actions.Edit.Redo.CreateDockToolBarItem ()); Gtk.Action show_history = show_pad.AppendAction ("History", Catalog.GetString ("History"), null, "Menu.Layers.DuplicateLayer.png"); show_history.Activated += delegate { history_item.Visible = true; }; container.PackStart (dock, true, true, 0); string layout_file = System.IO.Path.Combine (PintaCore.Settings.GetUserSettingsDirectory (), "layouts.xml"); if (System.IO.File.Exists (layout_file)) dock.LoadLayouts (layout_file); if (!dock.HasLayout ("Default")) dock.CreateLayout ("Default", false); dock.CurrentLayout = "Default"; }
public void Initialize(DockFrame workspace, Menu padMenu) { // Create canvas Table mainTable = new Table (2, 2, false); sw = new ScrolledWindow () { Name = "sw", ShadowType = ShadowType.EtchedOut }; Viewport vp = new Viewport () { ShadowType = ShadowType.None }; canvas = new PintaCanvas () { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask)16134 }; // Canvas pad DockItem documentDockItem = workspace.AddItem ("Canvas"); documentDockItem.Behavior = DockItemBehavior.Locked; documentDockItem.Expand = true; documentDockItem.DrawFrame = false; documentDockItem.Label = Catalog.GetString ("Canvas"); documentDockItem.Content = mainTable; documentDockItem.Icon = PintaCore.Resources.GetIcon ("Menu.Effects.Artistic.OilPainting.png"); //rulers hruler = new HRuler (); hruler.Metric = MetricType.Pixels; mainTable.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vruler = new VRuler (); vruler.Metric = MetricType.Pixels; mainTable.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); sw.Hadjustment.ValueChanged += delegate { UpdateRulerRange (); }; sw.Vadjustment.ValueChanged += delegate { UpdateRulerRange (); }; PintaCore.Workspace.CanvasSizeChanged += delegate { UpdateRulerRange (); }; canvas.MotionNotifyEvent += delegate (object o, MotionNotifyEventArgs args) { if (!PintaCore.Workspace.HasOpenDocuments) return; Cairo.PointD point = PintaCore.Workspace.WindowPointToCanvas (args.Event.X, args.Event.Y); hruler.Position = point.X; vruler.Position = point.Y; }; mainTable.Attach (sw, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); sw.Add (vp); vp.Add (canvas); mainTable.ShowAll (); canvas.Show (); vp.Show (); hruler.Visible = false; vruler.Visible = false; PintaCore.Chrome.InitializeCanvas (canvas); canvas.SizeAllocated += delegate { UpdateRulerRange (); }; PintaCore.Actions.View.Rulers.Toggled += HandleRulersToggled; PintaCore.Actions.View.Pixels.Activated += (o, e) => { SetRulersUnit (MetricType.Pixels); }; PintaCore.Actions.View.Inches.Activated += (o, e) => { SetRulersUnit (MetricType.Inches); }; PintaCore.Actions.View.Centimeters.Activated += (o, e) => { SetRulersUnit (MetricType.Centimeters); }; }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); Requisition req = new Requisition (); req.Height = 600; req.Width = 800; drawingarea1.Requisition = req; // Initialize interface things PintaCore.Actions.AccelGroup = new AccelGroup (); this.AddAccelGroup (PintaCore.Actions.AccelGroup); progress_dialog = new ProgressDialog (); PintaCore.Initialize (tooltoolbar, label5, drawingarea1, history_treeview, this, progress_dialog, (Gtk.Viewport)table1.Parent); colorpalettewidget1.Initialize (); PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged); PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated); PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged); CreateToolBox (); PintaCore.Actions.CreateMainMenu (menubar1); PintaCore.Actions.CreateToolBar (toolbar1); PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4); PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2); Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png")); i.Show (); statusbar1.Add (i); Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i]; box.Position = 2; box.Fill = false; box.Expand = false; this.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); dialog_handler = new DialogHandlers (this); // Create a blank document Layer background = PintaCore.Layers.AddNewLayer ("Background"); using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (255, 255, 255); g.Paint (); } PintaCore.Workspace.Filename = "Untitled1"; PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-new", "New Image")); PintaCore.Workspace.IsDirty = false; PintaCore.Workspace.Invalidate (); //History history_treeview.Model = PintaCore.History.ListStore; history_treeview.HeadersVisible = false; history_treeview.Selection.Mode = SelectionMode.Single; history_treeview.Selection.SelectFunction = HistoryItemSelected; Gtk.TreeViewColumn icon_column = new Gtk.TreeViewColumn (); Gtk.CellRendererPixbuf icon_cell = new Gtk.CellRendererPixbuf (); icon_column.PackStart (icon_cell, true); Gtk.TreeViewColumn text_column = new Gtk.TreeViewColumn (); Gtk.CellRendererText text_cell = new Gtk.CellRendererText (); text_column.PackStart (text_cell, true); text_column.SetCellDataFunc (text_cell, new Gtk.TreeCellDataFunc (HistoryRenderText)); icon_column.SetCellDataFunc (icon_cell, new Gtk.TreeCellDataFunc (HistoryRenderIcon)); history_treeview.AppendColumn (icon_column); history_treeview.AppendColumn (text_column); PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (OnHistoryItemsChanged); PintaCore.History.ActionUndone += new EventHandler (OnHistoryItemsChanged); PintaCore.History.ActionRedone += new EventHandler (OnHistoryItemsChanged); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); PintaCore.LivePreview.RenderUpdated += LivePreview_RenderUpdated; WindowAction.Visible = false; hruler = new HRuler (); hruler.Metric = MetricType.Pixels; table1.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vruler = new VRuler (); vruler.Metric = MetricType.Pixels; table1.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); UpdateRulerRange (); PintaCore.Actions.View.ZoomComboBox.ComboBox.Changed += HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged; gr = new GridRenderer (cr); if (Platform.GetOS () == Platform.OS.Mac) { try { //enable the global key handler for keyboard shortcuts IgeMacMenu.GlobalKeyHandlerEnabled = true; //Tell the IGE library to use your GTK menu as the Mac main menu IgeMacMenu.MenuBar = menubar1; /* //tell IGE which menu item should be used for the app menu's quit item IgeMacMenu.QuitMenuItem = yourQuitMenuItem; */ //add a new group to the app menu, and add some items to it var appGroup = IgeMacMenu.AddAppMenuGroup (); MenuItem aboutItem = (MenuItem)PintaCore.Actions.Help.About.CreateMenuItem (); appGroup.AddMenuItem (aboutItem, Mono.Unix.Catalog.GetString ("About")); menubar1.Hide (); } catch { // If things don't work out, just use a normal menu. } } }
public void Initialize(DockFrame workspace, Menu padMenu) { // Create canvas Table mainTable = new Table(2, 2, false); sw = new ScrolledWindow() { Name = "sw", ShadowType = ShadowType.EtchedOut }; Viewport vp = new Viewport() { ShadowType = ShadowType.None }; canvas = new PintaCanvas() { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask) 16134 }; // Canvas pad DockItem documentDockItem = workspace.AddItem("Canvas"); documentDockItem.Behavior = DockItemBehavior.Locked; documentDockItem.Expand = true; documentDockItem.DrawFrame = false; documentDockItem.Label = Catalog.GetString("Canvas"); documentDockItem.Content = mainTable; documentDockItem.Icon = PintaCore.Resources.GetIcon("Menu.Effects.Artistic.OilPainting.png"); //rulers hruler = new HRuler(); hruler.Metric = MetricType.Pixels; mainTable.Attach(hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); vruler = new VRuler(); vruler.Metric = MetricType.Pixels; mainTable.Attach(vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0); sw.Hadjustment.ValueChanged += delegate { UpdateRulerRange(); }; sw.Vadjustment.ValueChanged += delegate { UpdateRulerRange(); }; PintaCore.Workspace.CanvasSizeChanged += delegate { UpdateRulerRange(); }; canvas.MotionNotifyEvent += delegate(object o, MotionNotifyEventArgs args) { if (!PintaCore.Workspace.HasOpenDocuments) { return; } Cairo.PointD point = PintaCore.Workspace.WindowPointToCanvas(args.Event.X, args.Event.Y); hruler.Position = point.X; vruler.Position = point.Y; }; mainTable.Attach(sw, 1, 2, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Expand | AttachOptions.Fill, 0, 0); sw.Add(vp); vp.Add(canvas); mainTable.ShowAll(); canvas.Show(); vp.Show(); hruler.Visible = false; vruler.Visible = false; PintaCore.Chrome.InitializeCanvas(canvas); canvas.SizeAllocated += delegate { UpdateRulerRange(); }; PintaCore.Actions.View.Rulers.Toggled += HandleRulersToggled; PintaCore.Actions.View.Pixels.Activated += (o, e) => { SetRulersUnit(MetricType.Pixels); }; PintaCore.Actions.View.Inches.Activated += (o, e) => { SetRulersUnit(MetricType.Inches); }; PintaCore.Actions.View.Centimeters.Activated += (o, e) => { SetRulersUnit(MetricType.Centimeters); }; }