Exemplo n.º 1
0
 override protected void OnRelease()
 {
     _slice.Draw(Preview.Renderer);
     SliceData.AddSlice(_slice);
     Preview.Renderer.Function = Gdk.Function.Copy;
     Redraw();
 }
Exemplo n.º 2
0
        public Preview(Drawable drawable, SliceData sliceData)
        {
            MaxSize = drawable.Dimensions;

            ExposeEvent += delegate { sliceData.Draw(Renderer); };
            Realized    += delegate
            {
                var gc = new Gdk.GC(GdkWindow);
                Renderer = new PreviewRenderer(this, gc, drawable.Dimensions);
                Draw(drawable);
            };
            SizeAllocated += delegate { Draw(drawable); };

            Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
                     EventMask.PointerMotionHintMask | EventMask.PointerMotionMask |
                     EventMask.LeaveNotifyMask;

            ButtonPressEvent += (o, args) =>
            {
                var c = new IntCoordinate((int)args.Event.X, (int)args.Event.Y);
                Func.GetActualFunc(c).OnButtonPress(o, args);
            };

            MotionNotifyEvent += (o, args) =>
            {
                GdkWindow.Cursor = Func.GetCursor(GetXY(args));
            };

            Func = new SelectFunc(sliceData, this);
        }
Exemplo n.º 3
0
        public Dialog(Image image, Drawable drawable, SliceData sliceData)
            : base(_("Slice Tool"), _("SliceTool"), 
	   IntPtr.Zero, 0, null, _("SliceTool"),
	   Stock.SaveAs, (Gtk.ResponseType) 2,
	   Stock.Save, (Gtk.ResponseType) 3,
	   Stock.Close, ResponseType.Close)
        {
            _image = image;
              _drawable = drawable;
              _sliceData = sliceData;

              SetTitle(null);

              var vbox = new VBox(false, 12) {BorderWidth = 12};
              VBox.PackStart(vbox, true, true, 0);

              var hbox = new HBox();
              vbox.PackStart(hbox, true, true, 0);

              var preview = CreatePreview(drawable, sliceData);
              var toolbox = Preview.CreateToolbox(sliceData);

              hbox.PackStart(toolbox, false, true, 0);
              hbox.PackStart(preview, true, true, 0);

              hbox = new HBox();
              vbox.PackStart(hbox, true, true, 0);
              hbox.PackStart(new CoordinatesDisplay(Preview), false, false, 0);

              hbox = new HBox(false, 24);
              vbox.PackStart(hbox, true, true, 0);

              var properties = new CellPropertiesFrame(sliceData.Rectangles);
              hbox.PackStart(properties, false, true, 0);

              vbox = new VBox(false, 12);
              hbox.PackStart(vbox, false, true, 0);

              var rollover = new RolloversFrame(sliceData);
              vbox.PackStart(rollover, false, true, 0);

              _format = new Format(sliceData.Rectangles);
              _format.Extension = System.IO.Path.GetExtension(image.Name).ToLower();
              vbox.PackStart(_format, false, true, 0);

              vbox = new VBox(false, 12);
              hbox.PackStart(vbox, false, true, 0);

              var save = new SaveSettingsButton(this, sliceData);
              vbox.PackStart(save, false, true, 0);

              var load = new LoadSettingsButton(this, sliceData);
              vbox.PackStart(load, false, true, 0);

              var preferences = new PreferencesButton(_("Preferences"), Preview);
              vbox.PackStart(preferences, false, true, 0);

              sliceData.Rectangles.SelectedRectangleChanged += delegate {Redraw();};
              sliceData.Init(drawable);
        }
Exemplo n.º 4
0
        public Preview(Drawable drawable, SliceData sliceData)
        {
            MaxSize = drawable.Dimensions;

              ExposeEvent += delegate {sliceData.Draw(Renderer);};
              Realized += delegate
            {
              var gc = new Gdk.GC(GdkWindow);
              Renderer = new PreviewRenderer(this, gc, drawable.Dimensions);
              Draw(drawable);
            };
              SizeAllocated += delegate {Draw(drawable);};

              Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask |
            EventMask.PointerMotionHintMask | EventMask.PointerMotionMask |
            EventMask.LeaveNotifyMask;

              ButtonPressEvent += (o, args) =>
            {
              var c = new IntCoordinate((int) args.Event.X, (int) args.Event.Y);
              Func.GetActualFunc(c).OnButtonPress(o, args);
            };

              MotionNotifyEvent += (o, args) =>
            {
              GdkWindow.Cursor = Func.GetCursor(GetXY(args));
            };

              Func = new SelectFunc(sliceData, this);
        }
Exemplo n.º 5
0
        override protected void OnPress(IntCoordinate c)
        {
            var slice = SliceData.MayRemove(c);

            if (slice != null)
            {
                SliceData.Remove(slice);
                Redraw();
            }
        }
Exemplo n.º 6
0
 override protected void OnPress(IntCoordinate c)
 {
     _x          = c.X;
     _y          = c.Y;
     _rectangle  = SliceData.FindRectangle(c);
     _slice      = _rectangle.CreateHorizontalSlice(_y);
     _horizontal = true;
     Preview.Renderer.Function = Gdk.Function.Equiv;
     _slice.Draw(Preview.Renderer);
 }
Exemplo n.º 7
0
        public RolloversFrame(SliceData sliceData)
            : base(_("Rollovers"))
        {
            var vbox = new VBox(false, 12);
              Add(vbox);

              vbox.Add(CreateRolloverButton(sliceData));

              var label = new Label(_("Rollover enabled: no"));
              vbox.Add(label);
        }
Exemplo n.º 8
0
        public RolloversFrame(SliceData sliceData) : base(_("Rollovers"))
        {
            var vbox = new VBox(false, 12);

            Add(vbox);

            vbox.Add(CreateRolloverButton(sliceData));

            var label = new Label(_("Rollover enabled: no"));

            vbox.Add(label);
        }
Exemplo n.º 9
0
        override protected void OnPress(IntCoordinate c)
        {
            var rows    = new Variable <int>(3);
            var columns = new Variable <int>(3);
            var dialog  = new TableDialog(rows, columns);

            dialog.ShowAll();
            if (dialog.Run() == ResponseType.Ok)
            {
                SliceData.CreateTable(c, rows.Value, columns.Value);
                Redraw();
            }
            dialog.Destroy();
        }
Exemplo n.º 10
0
        public Toolbox(Preview preview, SliceData sliceData)
        {
            _preview = preview;

              CreateStockIcons();

              Orientation = Gtk.Orientation.Vertical;
              ToolbarStyle = Gtk.ToolbarStyle.Icons;

              var toggle = CreateSelectToggle(sliceData);
              toggle = CreateSliceToggle(toggle, sliceData);
              toggle.Active = true;
              toggle = CreateEraserToggle(toggle, sliceData);
              CreateTableToggle(toggle, sliceData);
        }
Exemplo n.º 11
0
        public Toolbox(Preview preview, SliceData sliceData)
        {
            _preview = preview;

            CreateStockIcons();

            Orientation  = Gtk.Orientation.Vertical;
            ToolbarStyle = Gtk.ToolbarStyle.Icons;

            var toggle = CreateSelectToggle(sliceData);

            toggle        = CreateSliceToggle(toggle, sliceData);
            toggle.Active = true;
            toggle        = CreateEraserToggle(toggle, sliceData);
            CreateTableToggle(toggle, sliceData);
        }
Exemplo n.º 12
0
        override protected void OnMove(IntCoordinate c)
        {
            var coordinate = (_horizontal) ? new IntCoordinate(c.X, _y)
        : new IntCoordinate(_x, c.Y);
            var rectangle = SliceData.FindRectangle(coordinate);

            bool rectangleChanged = rectangle != _endRectangle;

            _endRectangle = rectangle;

            bool horizontal         = Math.Abs(c.X - _x) > Math.Abs(c.Y - _y);
            bool orientationChanged = horizontal != _horizontal;

            _horizontal = horizontal;

            if (orientationChanged || rectangleChanged)
            {
                _slice.Draw(Preview.Renderer);
                if (_horizontal)
                {
                    if (rectangle.X1 <= _rectangle.X1)
                    {
                        _slice = new HorizontalSlice(rectangle.Left,
                                                     _rectangle.Right, _y);
                    }
                    else
                    {
                        _slice = new HorizontalSlice(_rectangle.Left,
                                                     rectangle.Right, _y);
                    }
                }
                else
                {
                    if (rectangle.Y1 <= _rectangle.Y1)
                    {
                        _slice = new VerticalSlice(rectangle.Top,
                                                   _rectangle.Bottom, _x);
                    }
                    else
                    {
                        _slice = new VerticalSlice(_rectangle.Top,
                                                   rectangle.Bottom, _x);
                    }
                }
                _slice.Draw(Preview.Renderer);
            }
        }
Exemplo n.º 13
0
        public SaveSettingsButton(Dialog parent, SliceData sliceData) :
            base(Catalog.GetString("Save Settings..."))
        {
            Clicked += delegate
            {
                var fc = new FileChooserDialog(Catalog.GetString("Save Settings"),
                                               parent, FileChooserAction.Save,
                                               "Cancel", ResponseType.Cancel,
                                               "Save", ResponseType.Accept);

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    sliceData.SaveSettings(fc.Filename);
                }
                fc.Destroy();
            };
        }
Exemplo n.º 14
0
        public SaveSettingsButton(Dialog parent, SliceData sliceData)
            : base(Catalog.GetString("Save Settings..."))
        {
            Clicked += delegate
            {
              var fc = new FileChooserDialog(Catalog.GetString("Save Settings"),
                     parent, FileChooserAction.Save,
                     "Cancel", ResponseType.Cancel,
                     "Save", ResponseType.Accept);

              if (fc.Run() == (int) ResponseType.Accept)
              {
            sliceData.SaveSettings(fc.Filename);
              }
              fc.Destroy();
            };
        }
Exemplo n.º 15
0
        Button CreateRolloverButton(SliceData sliceData)
        {
            var button = new Button(_("Rollover Creator..."));

              button.Clicked += delegate {
            var dialog = new RolloverDialog();
            dialog.SetRectangleData(sliceData.Selected);
            dialog.ShowAll();
            var type = dialog.Run();
            if (type == ResponseType.Ok)
            {
              dialog.GetRectangleData(sliceData.Selected);
            }
            dialog.Destroy();
              };
              return button;
        }
Exemplo n.º 16
0
        Button CreateRolloverButton(SliceData sliceData)
        {
            var button = new Button(_("Rollover Creator..."));

            button.Clicked += delegate {
                var dialog = new RolloverDialog();
                dialog.SetRectangleData(sliceData.Selected);
                dialog.ShowAll();
                var type = dialog.Run();
                if (type == ResponseType.Ok)
                {
                    dialog.GetRectangleData(sliceData.Selected);
                }
                dialog.Destroy();
            };
            return(button);
        }
Exemplo n.º 17
0
        public LoadSettingsButton(Dialog parent, SliceData sliceData)
            : base(Catalog.GetString("Load Settings..."))
        {
            Clicked += delegate
            {
              var fc = new FileChooserDialog(Catalog.GetString("Load Settings"),
                     parent, FileChooserAction.Open,
                     "Cancel", ResponseType.Cancel,
                     "Open", ResponseType.Accept);

              if (fc.Run() == (int) ResponseType.Accept)
              {
            sliceData.LoadSettings(fc.Filename);
            parent.Redraw(); // fix me: should be handled in callback method
              }
              fc.Destroy();
            };
        }
Exemplo n.º 18
0
        Widget CreatePreview(Drawable drawable, SliceData sliceData)
        {
            var window = new ScrolledWindow();

            window.SetSizeRequest(600, 400);

            var alignment = new Alignment(0.5f, 0.5f, 0, 0);

            Preview = new Preview(drawable, sliceData)
            {
                WidthRequest = drawable.Width, HeightRequest = drawable.Height
            };

            alignment.Add(Preview);
            window.AddWithViewport(alignment);

            return(window);
        }
Exemplo n.º 19
0
        public LoadSettingsButton(Dialog parent, SliceData sliceData) :
            base(Catalog.GetString("Load Settings..."))
        {
            Clicked += delegate
            {
                var fc = new FileChooserDialog(Catalog.GetString("Load Settings"),
                                               parent, FileChooserAction.Open,
                                               "Cancel", ResponseType.Cancel,
                                               "Open", ResponseType.Accept);

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    sliceData.LoadSettings(fc.Filename);
                    parent.Redraw(); // fix me: should be handled in callback method
                }
                fc.Destroy();
            };
        }
Exemplo n.º 20
0
 RadioToolButton CreateTableToggle(RadioToolButton group,
                                   SliceData sliceData)
 {
     return(AddToggle(group, GimpStock.GRID, _("Insert Table"),
                      new CreateTableFunc(sliceData, _preview)));
 }
Exemplo n.º 21
0
 RadioToolButton CreateEraserToggle(RadioToolButton group,
                                    SliceData sliceData)
 {
     return(AddToggle(group, GimpStock.TOOL_ERASER, _("Remove Slice"),
                      new RemoveFunc(sliceData, _preview)));
 }
Exemplo n.º 22
0
 public CreateFunc(SliceData sliceData, Preview preview) :
     base(sliceData, preview)
 {
 }
Exemplo n.º 23
0
        RadioToolButton CreateSliceToggle(RadioToolButton group,
				      SliceData sliceData)
        {
            return AddToggle(group, GimpStock.TOOL_CROP, _("Create a new Slice"),
               new CreateFunc(sliceData, _preview));
        }
Exemplo n.º 24
0
 override public Cursor GetCursor(IntCoordinate c) =>
 (SliceData.MayRemove(c) == null) ? base.GetCursor(c) : _cursor;
Exemplo n.º 25
0
 public RemoveFunc(SliceData sliceData, Preview preview) :
     base(sliceData, preview)
 {
 }
Exemplo n.º 26
0
 public SelectFunc(SliceData sliceData, Preview preview) :
     base(sliceData, preview)
 {
 }
Exemplo n.º 27
0
 public RemoveFunc(SliceData sliceData, Preview preview)
     : base(sliceData, preview)
 {
 }
Exemplo n.º 28
0
 public Toolbox CreateToolbox(SliceData sliceData)
 {
     return new Toolbox(this, sliceData);
 }
Exemplo n.º 29
0
        Widget CreatePreview(Drawable drawable, SliceData sliceData)
        {
            var window = new ScrolledWindow();
              window.SetSizeRequest(600, 400);

              var alignment = new Alignment(0.5f, 0.5f, 0, 0);

              Preview = new Preview(drawable, sliceData)
            {WidthRequest = drawable.Width, HeightRequest = drawable.Height};

              alignment.Add(Preview);
              window.AddWithViewport(alignment);

              return window;
        }
Exemplo n.º 30
0
 public CreateFunc(SliceData sliceData, Preview preview)
     : base(sliceData, preview)
 {
 }
Exemplo n.º 31
0
 MoveSliceFunc(SliceData sliceData, Preview preview, Slice slice) :
     base(sliceData, preview)
 {
     _slice = slice;
     Preview.Renderer.Function = Gdk.Function.Equiv;
 }
Exemplo n.º 32
0
 override protected void OnRelease()
 {
     Preview.Renderer.Function = Gdk.Function.Copy;
     SliceData.Cleanup(_slice);
     Redraw();
 }
Exemplo n.º 33
0
 override protected void OnPress(IntCoordinate c)
 {
     SliceData.SelectRectangle(c);
 }
Exemplo n.º 34
0
        override public Cursor GetCursor(IntCoordinate c)
        {
            var slice = SliceData.FindSlice(c);

            return((SliceIsSelectable(slice)) ? slice.Cursor : base.GetCursor(c));
        }
Exemplo n.º 35
0
 MoveSliceFunc(SliceData sliceData, Preview preview, Slice slice)
     : base(sliceData, preview)
 {
     _slice = slice;
       Preview.Renderer.Function = Gdk.Function.Equiv;
 }
Exemplo n.º 36
0
 RadioToolButton CreateSelectToggle(SliceData sliceData)
 {
     return AddToggle(null, "slice-tool-arrow",
        _("Select Rectangle or Slice"),
        new SelectFunc(sliceData, _preview));
 }
Exemplo n.º 37
0
 RadioToolButton CreateSelectToggle(SliceData sliceData)
 {
     return(AddToggle(null, "slice-tool-arrow",
                      _("Select Rectangle or Slice"),
                      new SelectFunc(sliceData, _preview)));
 }
Exemplo n.º 38
0
        RadioToolButton CreateTableToggle(RadioToolButton group, 
				      SliceData sliceData)
        {
            return AddToggle(group, GimpStock.GRID, _("Insert Table"),
               new CreateTableFunc(sliceData, _preview));
        }
Exemplo n.º 39
0
 RadioToolButton CreateSliceToggle(RadioToolButton group,
                                   SliceData sliceData)
 {
     return(AddToggle(group, GimpStock.TOOL_CROP, _("Create a new Slice"),
                      new CreateFunc(sliceData, _preview)));
 }
Exemplo n.º 40
0
        RadioToolButton CreateEraserToggle(RadioToolButton group, 
				       SliceData sliceData)
        {
            return AddToggle(group, GimpStock.TOOL_ERASER, _("Remove Slice"),
               new RemoveFunc(sliceData, _preview));
        }
Exemplo n.º 41
0
        public Dialog(Image image, Drawable drawable, SliceData sliceData) :
            base(_("Slice Tool"), _("SliceTool"),
                 IntPtr.Zero, 0, null, _("SliceTool"),
                 Stock.SaveAs, (Gtk.ResponseType) 2,
                 Stock.Save, (Gtk.ResponseType) 3,
                 Stock.Close, ResponseType.Close)
        {
            _image     = image;
            _drawable  = drawable;
            _sliceData = sliceData;

            SetTitle(null);

            var vbox = new VBox(false, 12)
            {
                BorderWidth = 12
            };

            VBox.PackStart(vbox, true, true, 0);

            var hbox = new HBox();

            vbox.PackStart(hbox, true, true, 0);

            var preview = CreatePreview(drawable, sliceData);
            var toolbox = Preview.CreateToolbox(sliceData);

            hbox.PackStart(toolbox, false, true, 0);
            hbox.PackStart(preview, true, true, 0);

            hbox = new HBox();
            vbox.PackStart(hbox, true, true, 0);
            hbox.PackStart(new CoordinatesDisplay(Preview), false, false, 0);

            hbox = new HBox(false, 24);
            vbox.PackStart(hbox, true, true, 0);

            var properties = new CellPropertiesFrame(sliceData.Rectangles);

            hbox.PackStart(properties, false, true, 0);

            vbox = new VBox(false, 12);
            hbox.PackStart(vbox, false, true, 0);

            var rollover = new RolloversFrame(sliceData);

            vbox.PackStart(rollover, false, true, 0);

            _format           = new Format(sliceData.Rectangles);
            _format.Extension = System.IO.Path.GetExtension(image.Name).ToLower();
            vbox.PackStart(_format, false, true, 0);

            vbox = new VBox(false, 12);
            hbox.PackStart(vbox, false, true, 0);

            var save = new SaveSettingsButton(this, sliceData);

            vbox.PackStart(save, false, true, 0);

            var load = new LoadSettingsButton(this, sliceData);

            vbox.PackStart(load, false, true, 0);

            var preferences = new PreferencesButton(_("Preferences"), Preview);

            vbox.PackStart(preferences, false, true, 0);

            sliceData.Rectangles.SelectedRectangleChanged += delegate { Redraw(); };
            sliceData.Init(drawable);
        }
Exemplo n.º 42
0
 public Toolbox CreateToolbox(SliceData sliceData)
 {
     return(new Toolbox(this, sliceData));
 }
Exemplo n.º 43
0
 public MouseFunc(SliceData sliceData, Preview preview)
 {
     SliceData = sliceData;
       Preview = preview;
 }
Exemplo n.º 44
0
 public MouseFunc(SliceData sliceData, Preview preview)
 {
     SliceData = sliceData;
     Preview   = preview;
 }
Exemplo n.º 45
0
 public SelectFunc(SliceData sliceData, Preview preview)
     : base(sliceData, preview)
 {
 }