def init_widgets(self):
        button_box = gtk.HBox()

        model = lib.document.Document(self.app.brush)
        self.tdw = tileddrawwidget.TiledDrawWidget(self.app, model)
        self.tdw.set_size_request(brushmanager.preview_w*2, brushmanager.preview_h*2)
        self.tdw.scale = 2.0

        tdw_box = gtk.HBox()
        tdw_box.pack_start(self.tdw, expand=False, fill=False)
        tdw_box.pack_start(gtk.Label(), expand=True)

        self.pack_start(tdw_box, expand=False, fill=False, padding=3)
        self.pack_start(button_box, expand=False, fill=False, padding=3)

        ctrlr = CanvasController(self.tdw)
        ctrlr.init_pointer_events()
        ctrlr.modes.default_mode_class = FreehandOnlyMode

        self.brush_preview_edit_mode_button = b = gtk.CheckButton(_('Edit'))
        b.connect('toggled', self.brush_preview_edit_mode_cb)
        button_box.pack_start(b, expand=False, padding=3)

        self.brush_preview_clear_button = b = gtk.Button(_('Clear'))
        b.connect('clicked', self.clear_cb)
        button_box.pack_start(b, expand=False, padding=3)

        self.brush_preview_save_button = b = gtk.Button(_('Save'))
        b.connect('clicked', self.update_preview_cb)
        button_box.pack_start(b, expand=False, padding=3)
Beispiel #2
0
def _test():
    from document import CanvasController
    from freehand import FreehandOnlyMode
    model = _make_testbed_model()
    tdw = TiledDrawWidget()
    tdw.set_model(model)
    tdw.set_size_request(640, 480)
    tdw.renderer.visualize_rendering = True
    ctrlr = CanvasController(tdw)
    ctrlr.init_pointer_events()
    ctrlr.modes.default_mode_class = FreehandOnlyMode
    win = gtk.Window()
    win.set_title("tdw test")
    win.connect("destroy", lambda *a: gtk.main_quit())
    win.add(tdw)
    win.show_all()
    gtk.main()
Beispiel #3
0
def _test():
    from document import CanvasController
    from freehand import FreehandOnlyMode
    model = _make_testbed_model()
    tdw = TiledDrawWidget()
    tdw.set_model(model)
    tdw.set_size_request(640, 480)
    tdw.renderer.visualize_rendering = True
    ctrlr = CanvasController(tdw)
    ctrlr.init_pointer_events()
    ctrlr.modes.default_mode_class = FreehandOnlyMode
    win = gtk.Window()
    win.set_title("tdw test")
    win.connect("destroy", lambda *a: gtk.main_quit())
    win.add(tdw)
    win.show_all()
    gtk.main()
Beispiel #4
0
    def _init_widgets(self):
        # Icon preview and edit TDW
        self._tdw = tileddrawwidget.TiledDrawWidget()
        self._tdw.set_model(self._model)
        self._tdw.set_size_request(brushmanager.PREVIEW_W*self._SCALE,
                                  brushmanager.PREVIEW_H*self._SCALE)
        self._tdw.scale = float(self._SCALE)
        self._tdw.scroll_on_allocate = False
        self._tdw.pixelize_threshold = 0
        tdw_align = Gtk.Alignment(xalign=0.5, yalign=0.0,
                                  xscale=0.0, yscale=0.0)
        tdw_align.add(self._tdw)
        self.attach(tdw_align, 0, 0, 1, 1)

        ctrlr = CanvasController(self._tdw)
        ctrlr.init_pointer_events()
        ctrlr.modes.default_mode_class = FreehandOnlyMode

        # Brush name label
        lbl = Gtk.Label()
        lbl.set_alignment(0.5, 0.0)
        lbl.set_justify(Gtk.Justification.CENTER)
        lbl_tmpl = self._ICON_PREVIEWING_TMPL
        lbl.set_markup(lbl_tmpl % (escape(self._NO_BRUSH_NAME),))
        self.attach(lbl, 0, 1, 1, 1)
        self.brush_name_label = lbl

        # Action buttons
        button_box = Gtk.VButtonBox()
        button_box.set_homogeneous(False)
        button_box.set_layout(Gtk.ButtonBoxStyle.START)
        button_box.set_spacing(4)

        # TRANSLATORS: begin editing a brush's preview icon
        b = self._make_image_button(_('Edit'), Gtk.STOCK_EDIT,
                                    self._edit_cb)
        b.set_tooltip_text(_("Begin editing this preview icon"))
        button_box.pack_start(b, expand=False)
        self._edit_button = b

        # TRANSLATORS: revert edits to a brush icon
        b = self._make_image_button(_('Revert'), Gtk.STOCK_REVERT_TO_SAVED,
                                    self._revert_cb)
        b.set_tooltip_text(_("Discard changes, and cancel editing"))
        button_box.pack_start(b, expand=False)
        button_box.set_child_secondary(b, False)
        self._revert_button = b

        # TRANSLATORS: clear the brush preview icon being edited
        b = self._make_image_button(_('Clear'), Gtk.STOCK_CLEAR,
                                    self._clear_cb)
        b.set_tooltip_text(_("Clear the preview icon"))
        button_box.pack_start(b, expand=False)
        self._clear_button = b

        #lbl = Gtk.Label(_("Use any brush and color when editing"))
        #lbl.set_line_wrap(Pango.WrapMode.WORD_CHAR)
        #button_box.pack_start(lbl, expand=False)

        # TRANSLATORS: save edits to a brush icon
        b = self._make_image_button(_('Save'), Gtk.STOCK_SAVE,
                                    self._save_cb)
        b.set_tooltip_text(_("Save this preview icon, and finish editing"))
        button_box.pack_start(b, expand=False)
        button_box.set_child_secondary(b, True)
        self._save_button = b

        self.attach(button_box, 1, 0, 1, 2)

        self.connect_after("show", self._show_cb)

        mb = self._bm.selected_brush
        preview = mb.preview
        self._set_preview_pixbuf(preview)
        name = mb.name
        if name is None:
            name = self._NO_BRUSH_NAME
        self.brush_name_label.set_markup(lbl_tmpl % (escape(name),))
    def _init_widgets(self):
        # Icon preview and edit TDW
        self._tdw = tileddrawwidget.TiledDrawWidget()
        self._tdw.set_model(self._model)
        self._tdw.set_size_request(
            brushmanager.PREVIEW_W*self._SCALE,
            brushmanager.PREVIEW_H*self._SCALE
        )
        self._tdw.scale = float(self._SCALE)
        self._tdw.scroll_on_allocate = False
        self._tdw.pixelize_threshold = 0
        tdw_align = Gtk.Alignment(xalign=0.5, yalign=0.0,
                                  xscale=0.0, yscale=0.0)
        tdw_align.add(self._tdw)
        self.attach(tdw_align, 0, 0, 1, 1)

        ctrlr = CanvasController(self._tdw)
        ctrlr.init_pointer_events()
        ctrlr.modes.default_mode_class = FreehandMode

        # Brush name label
        lbl = Gtk.Label()
        lbl.set_alignment(0.5, 0.0)
        lbl.set_justify(Gtk.Justification.CENTER)
        lbl_tmpl = self._ICON_PREVIEWING_TMPL
        lbl.set_markup(lbl_tmpl % (lib.xml.escape(self._NO_BRUSH_NAME),))
        self.attach(lbl, 0, 1, 1, 1)
        self.brush_name_label = lbl

        # Action buttons
        button_box = Gtk.VButtonBox()
        button_box.set_homogeneous(False)
        button_box.set_layout(Gtk.ButtonBoxStyle.START)
        button_box.set_spacing(4)

        # TRANSLATORS: begin editing a brush's preview icon
        b = self._make_image_button(
            _('Edit'), "mypaint-freehand-symbolic", self._edit_cb
        )
        b.set_tooltip_text(_("Begin editing this preview icon"))
        button_box.pack_start(b, False, True, 0)
        self._edit_button = b

        # TRANSLATORS: revert edits to a brush icon
        b = self._make_image_button(
            _('Revert'), "mypaint-document-revert-symbolic", self._revert_cb
        )
        b.set_tooltip_text(_("Discard changes, and cancel editing"))
        button_box.pack_start(b, False, True, 0)
        button_box.set_child_secondary(b, False)
        self._revert_button = b

        # TRANSLATORS: clear the brush preview icon being edited
        b = self._make_image_button(
            _('Clear'), "mypaint-clear-all-symbolic", self._clear_cb
        )
        b.set_tooltip_text(_("Clear the preview icon"))
        button_box.pack_start(b, False, True, 0)
        self._clear_button = b

        # TRANSLATORS: set the brush icon to a built-in default
        b = self._make_image_button(
            _('Auto'), "mypaint-document-new-symbolic", self._default_cb
        )
        b.set_tooltip_text(_("Use the default icon"))
        button_box.pack_start(b, False, True, 0)
        self._default_button = b

        # TRANSLATORS: save edits to a brush icon
        b = self._make_image_button(
            _('Save'), "mypaint-document-save-symbolic", self._save_cb
        )
        b.set_tooltip_text(_("Save this preview icon, and finish editing"))
        button_box.pack_start(b, False, True, 0)
        button_box.set_child_secondary(b, True)
        self._save_button = b

        self.attach(button_box, 1, 0, 1, 2)

        self.connect_after("show", self._show_cb)

        mb = self._bm.selected_brush
        preview = mb.preview
        self._set_preview_pixbuf(preview)
        name = mb.name
        if name is None:
            name = self._NO_BRUSH_NAME
        self.brush_name_label.set_markup(lbl_tmpl % (lib.xml.escape(name),))
Beispiel #6
0
        """
        x, y, w, h = self.doc.get_effective_bbox()
        desired_cx_model = x+w/2.0
        desired_cy_model = y+h/2.0
        cx, cy = self.get_center()
        cx_model, cy_model = self.display_to_model(cx, cy)
        self.translation_x += (cx_model - desired_cx_model)*self.scale
        self.translation_y += (cy_model - desired_cy_model)*self.scale
        self.queue_draw()

    def toggle_show_layers_above(self):
        self.show_layers_above = not self.show_layers_above
        self.queue_draw()


if __name__ == '__main__':
    from document import CanvasController
    from canvasevent import FreehandOnlyMode
    tdw = TiledDrawWidget()
    tdw.set_size_request(640, 480)
    tdw.renderer.visualize_rendering = True
    ctrlr = CanvasController(tdw)
    ctrlr.init_pointer_events()
    ctrlr.modes.default_mode_class = FreehandOnlyMode
    win = gtk.Window()
    win.set_title("tdw test")
    win.connect("destroy", lambda *a: gtk.main_quit())
    win.add(tdw)
    win.show_all()
    gtk.main()
    def _init_widgets(self):
        # Icon preview and edit TDW
        self._tdw = tileddrawwidget.TiledDrawWidget()
        self._tdw.set_model(self._model)
        self._tdw.set_size_request(
            brushmanager.PREVIEW_W * self._SCALE,
            brushmanager.PREVIEW_H * self._SCALE
        )
        self._tdw.scale = 1  # it will be corrected later
        self._tdw.scroll_on_allocate = False
        self._tdw.pixelize_threshold = 0
        tdw_align = Gtk.Alignment(xalign=0.5, yalign=0.0,
                                  xscale=0.0, yscale=0.0)
        tdw_align.add(self._tdw)
        self.attach(tdw_align, 0, 0, 1, 1)

        ctrlr = CanvasController(self._tdw)
        ctrlr.init_pointer_events()
        ctrlr.modes.default_mode_class = FreehandMode

        # Brush name label
        lbl = Gtk.Label()
        lbl.set_alignment(0.5, 0.0)
        lbl.set_justify(Gtk.Justification.CENTER)
        lbl_tmpl = self._ICON_PREVIEWING_TMPL
        lbl.set_markup(lbl_tmpl % (lib.xml.escape(self._NO_BRUSH_NAME),))
        self.attach(lbl, 0, 1, 1, 1)
        self.brush_name_label = lbl

        # Action buttons
        button_box = Gtk.VButtonBox()
        button_box.set_homogeneous(False)
        button_box.set_layout(Gtk.ButtonBoxStyle.START)
        button_box.set_spacing(4)

        # TRANSLATORS: begin editing a brush's preview icon
        b = self._make_image_button(
            _('Edit'), "mypaint-freehand-symbolic", self._edit_cb
        )
        b.set_tooltip_text(_("Begin editing this preview icon"))
        button_box.pack_start(b, False, True, 0)
        self._edit_button = b

        # TRANSLATORS: revert edits to a brush icon
        b = self._make_image_button(
            _('Revert'), "mypaint-document-revert-symbolic", self._revert_cb
        )
        b.set_tooltip_text(_("Discard changes, and cancel editing"))
        button_box.pack_start(b, False, True, 0)
        button_box.set_child_secondary(b, False)
        self._revert_button = b

        # TRANSLATORS: clear the brush preview icon being edited
        b = self._make_image_button(
            _('Clear'), "mypaint-clear-all-symbolic", self._clear_cb
        )
        b.set_tooltip_text(_("Clear the preview icon"))
        button_box.pack_start(b, False, True, 0)
        self._clear_button = b

        # TRANSLATORS: set the brush icon to a built-in default
        b = self._make_image_button(
            _('Auto'), "mypaint-document-new-symbolic", self._default_cb
        )
        b.set_tooltip_text(_("Use the default icon"))
        button_box.pack_start(b, False, True, 0)
        self._default_button = b

        # TRANSLATORS: save edits to a brush icon
        b = self._make_image_button(
            _('Save'), "mypaint-document-save-symbolic", self._save_cb
        )
        b.set_tooltip_text(_("Save this preview icon, and finish editing"))
        button_box.pack_start(b, False, True, 0)
        button_box.set_child_secondary(b, True)
        self._save_button = b

        self.attach(button_box, 1, 0, 1, 2)

        self.connect_after("show", self._show_cb)

        mb = self._bm.selected_brush
        preview = mb.preview
        self._set_preview_pixbuf(preview)
        name = mb.name
        if name is None:
            name = self._NO_BRUSH_NAME
        self.brush_name_label.set_markup(lbl_tmpl % (lib.xml.escape(name),))