Exemplo n.º 1
0
    def __init__(self):
        gtk.ToolItem.__init__(self)
        self.set_homogeneous(False)
        self.button_image = gtk.Image()
        self.button_image.set_from_icon_name('mypaint-line-mode',
                                             ToolbarManager.icon_size)
        self.line_mode_panel = dropdownpanel.DropdownPanelButton(
            self.button_image)
        self.vbox = gtk.VBox()
        self.vbox.set_border_width(widgets.SPACING_TIGHT)
        self.vbox.set_spacing(widgets.SPACING_TIGHT)
        frame = gtk.Frame()
        frame.add(self.vbox)
        frame.set_shadow_type(gtk.SHADOW_OUT)
        self.line_mode_panel.set_property("panel-widget", frame)
        self.add(self.line_mode_panel)
        self.connect("create-menu-proxy", lambda *a: True)

        from application import get_app
        app = get_app()
        self.app = app

        # Action switcher buttons
        bbox = gtk.HButtonBox()
        frame = widgets.section_frame(_("Line Mode"))
        frame.add(bbox)
        bbox.set_border_width(widgets.SPACING)
        for action_name in self.action_names:
            action = app.find_action(action_name)
            if action.get_active():
                self.update_icon_from_action(action)
            action.connect("changed", self.linemode_action_changed_cb)
            button = gtk.ToggleButton()
            button.set_related_action(action)
            button.connect("clicked", self.linemode_button_clicked_cb)
            button.set_can_focus(False)
            button.set_can_default(False)
            button.set_image_position(gtk.POS_TOP)
            button.set_relief(gtk.RELIEF_HALF)
            image = action.create_icon(gtk.ICON_SIZE_LARGE_TOOLBAR)
            image.set_padding(widgets.SPACING_TIGHT, widgets.SPACING_TIGHT)
            button.set_image(image)
            bbox.pack_start(button)
        self.vbox.pack_start(frame, False, False)
        bbox.show()

        # Pressure settings.
        frame = widgets.section_frame(_("Line Pressure"))
        self.vbox.pack_start(frame, True, True)
        curve = LineModeCurveWidget()
        curve_align = gtk.Alignment(0, 0, 1, 1)
        curve_align.add(curve)
        curve_align.set_padding(widgets.SPACING, widgets.SPACING,
                                widgets.SPACING, widgets.SPACING)
        frame.add(curve_align)
        curve_align.show()
Exemplo n.º 2
0
    def __init__(self):
        gtk.ToolItem.__init__(self)
        self.history_images = []
        self.main_image = ManagedBrushPreview()
        self.dropdown_button = dropdownpanel.DropdownPanelButton(
            self.main_image)
        self.app = None
        self.image_size = ToolbarManager.icon_size
        self.connect("toolbar-reconfigured", self._toolbar_reconf_cb)
        self.connect("create-menu-proxy", lambda *a: True)
        self.set_tooltip_text(_("Brush history etc."))
        self.add(self.dropdown_button)

        from application import get_app
        app = get_app()
        self.app = app
        bm = self.app.brushmanager
        bm.brush_selected += self._brush_selected_cb

        panel_frame = gtk.Frame()
        panel_frame.set_shadow_type(gtk.SHADOW_OUT)
        self.dropdown_button.set_property("panel-widget", panel_frame)
        panel_vbox = gtk.VBox()
        panel_vbox.set_spacing(widgets.SPACING_TIGHT)
        panel_vbox.set_border_width(widgets.SPACING)
        panel_frame.add(panel_vbox)

        # Quick brush changer
        section_frame = widgets.section_frame(_("Change Brush"))
        panel_vbox.pack_start(section_frame, True, True)

        section_vbox = gtk.VBox()
        section_vbox.set_border_width(widgets.SPACING)
        section_vbox.set_spacing(widgets.SPACING_TIGHT)
        section_frame.add(section_vbox)

        quick_changer = dialogs.QuickBrushChooser(app,
                                                  self._quick_change_select_cb)
        evbox = gtk.EventBox()
        evbox.add(quick_changer)
        section_vbox.pack_start(evbox, True, True)

        # List editor button
        # FIXME: perhaps list out the brush groups now?

        # Brush history
        section_frame = widgets.section_frame(_("Recently Used"))
        panel_vbox.pack_start(section_frame, True, True)

        history = BrushHistoryView(app)
        history.set_border_width(widgets.SPACING)
        history.button_clicked += self._history_button_clicked_cb
        section_frame.add(history)
Exemplo n.º 3
0
    def __init__(self):
        gtk.ToolItem.__init__(self)
        self.set_homogeneous(False)
        self.button_image = gtk.Image()
        self.button_image.set_from_stock(self.inactive_stock_id,
                                         ToolbarManager.icon_size)
        self.button_shows_modified = False
        self.button = dropdownpanel.DropdownPanelButton(self.button_image)
        self.vbox = gtk.VBox()
        frame = gtk.Frame()
        frame.add(self.vbox)
        frame.set_shadow_type(gtk.SHADOW_OUT)
        self.button.set_property("panel-widget", frame)
        self.add(self.button)
        self.connect("create-menu-proxy", lambda *a: True)

        from application import get_app
        app = get_app()
        self.app = app

        # A limited subset of the available brush settings.

        frame = widgets.section_frame(_("Quick Brush Settings"))
        table = gtk.Table()
        table.set_homogeneous(False)
        table.set_row_spacings(widgets.SPACING_TIGHT)
        table.set_col_spacings(widgets.SPACING)
        table.set_border_width(widgets.SPACING)
        frame.add(table)
        self.vbox.pack_start(frame, True, True)

        sg_row_height = gtk.SizeGroup(gtk.SIZE_GROUP_VERTICAL)
        sg_slider_width = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        row = 0
        for setting_cname in self.setting_cnames:
            scale = gtk.HScale()
            scale.set_size_request(128, -1)
            scale.set_draw_value(False)
            scale.set_can_focus(False)
            scale.set_can_default(False)
            s = brushsettings.settings_dict[setting_cname]
            adj = app.brush_adjustment[setting_cname]
            scale.set_adjustment(adj)
            scale.set_tooltip_text(s.tooltip)
            #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
            sg_row_height.add_widget(scale)
            sg_slider_width.add_widget(scale)

            label = gtk.Label(_("%s:") % s.name)
            label.set_alignment(0.0, 0.5)
            label.set_tooltip_text(s.tooltip)
            sg_row_height.add_widget(label)

            reset_button = widgets.borderless_button(
                stock_id=gtk.STOCK_CLEAR,
                tooltip=_("Restore '%s' to this brush's saved value") % s.name)
            reset_button.connect("clicked", self.reset_button_clicked_cb, adj,
                                 setting_cname)
            sg_row_height.add_widget(reset_button)

            adj.connect("value-changed", self.adjustment_changed_cb,
                        reset_button, setting_cname)
            adj.value_changed()

            table.attach(label, 0, 1, row, row + 1, gtk.FILL)
            table.attach(scale, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND)
            table.attach(reset_button, 2, 3, row, row + 1, gtk.FILL)
            row += 1
        table.set_col_spacing(1, widgets.SPACING_TIGHT)

        # Access to the brush settings window, and a big reset-all button
        # aligned with the settings above.

        frame = widgets.section_frame(_("Detailed Brush Settings"))
        hbox = gtk.HBox()
        hbox.set_spacing(widgets.SPACING)
        hbox.set_border_width(widgets.SPACING)
        frame.add(hbox)
        self.vbox.pack_start(frame, True, True)

        widget = gtk.ToggleButton()
        action = self.app.find_action("BrushEditorWindow")
        widget.set_related_action(action)
        #widget.set_label(_("Edit All Settings"))
        hbox.pack_start(widget, True, True)
        widget.connect("toggled", lambda a: self.button.panel_hide())
        sg_slider_width.add_widget(widget)

        widget = gtk.ToggleButton()
        action = self.app.find_action("BrushIconEditorWindow")
        widget.set_related_action(action)
        #widget.set_label(_("Edit Icon"))
        hbox.pack_start(widget, True, True)
        widget.connect("toggled", lambda a: self.button.panel_hide())
        sg_slider_width.add_widget(widget)

        widget = gtk.Button(_("Restore Saved Settings"))
        widget.connect("clicked", self.reset_all_clicked_cb)
        widget.set_tooltip_text(
            _("Reset all brush settings to the current brush's saved values"))
        hbox.pack_start(widget, True, True)
        sg_slider_width.add_widget(widget)
        self.reset_all_button = widget

        # Brush blend modes

        vbox = gtk.VBox()
        vbox.set_border_width(widgets.SPACING)
        vbox.set_spacing(widgets.SPACING_TIGHT)
        frame = widgets.section_frame(_("Brush Blend Mode"))
        frame.add(vbox)
        self.vbox.pack_start(frame, True, True)

        table = gtk.Table(2, 2, homogeneous=True)
        topts = gtk.EXPAND | gtk.FILL
        tpad = 0
        table.set_row_spacings(widgets.SPACING_TIGHT)
        table.set_col_spacings(widgets.SPACING)
        for la, ra, ta, ba, action_name in self.blend_modes_table:
            action = self.app.find_action(action_name)
            button = gtk.ToggleButton()
            button.set_related_action(action)
            button.set_can_focus(False)
            button.set_can_default(False)
            button.set_image_position(gtk.POS_LEFT)
            button.set_alignment(0.0, 0.5)
            button.set_relief(gtk.RELIEF_HALF)
            image = action.create_icon(gtk.ICON_SIZE_BUTTON)
            image.set_padding(widgets.SPACING_TIGHT, widgets.SPACING_TIGHT)
            button.set_image(image)
            table.attach(button, la, ra, ta, ba, topts, topts, tpad, tpad)
            button.connect("clicked", self.blendmode_button_clicked_cb)
        vbox.pack_start(table, False, False)

        self.vbox.set_border_width(widgets.SPACING)
        self.vbox.set_spacing(widgets.SPACING)

        self.app.brush.observers.append(self.brush_settings_changed_cb)
Exemplo n.º 4
0
    def __init__(self):
        gtk.ToolItem.__init__(self)
        preview = ColorPreview()
        self.dropdown_button = dropdownpanel.DropdownPanelButton(preview)
        self.preview_size = ToolbarManager.icon_size
        self.connect("toolbar-reconfigured", self._toolbar_reconf_cb)
        self.connect("create-menu-proxy", lambda *a: True)
        self.set_tooltip_text(_("Color History and other tools"))
        self.add(self.dropdown_button)

        from application import get_app
        app = get_app()
        app.brush.observers.append(self._brush_settings_changed_cb)
        preview.color = app.brush_color_manager.get_color()

        self._app = app
        self._main_preview = preview

        panel_frame = gtk.Frame()
        panel_frame.set_shadow_type(gtk.SHADOW_OUT)
        self.dropdown_button.set_property("panel-widget", panel_frame)
        panel_vbox = gtk.VBox()
        panel_vbox.set_spacing(widgets.SPACING_TIGHT)
        panel_vbox.set_border_width(widgets.SPACING)
        panel_frame.add(panel_vbox)

        def hide_panel_cb(*a):
            self.dropdown_button.panel_hide()

        def hide_panel_idle_cb(*a):
            gobject.idle_add(self.dropdown_button.panel_hide)

        # Colour changing
        section_frame = widgets.section_frame(_("Change Color"))
        panel_vbox.pack_start(section_frame, True, True)

        section_table = gtk.Table()
        section_table.set_col_spacings(widgets.SPACING)
        section_table.set_border_width(widgets.SPACING)
        section_frame.add(section_table)

        hsv_widget = HSVTriangle()
        hsv_widget.set_size_request(175, 175)
        hsv_widget.set_color_manager(app.brush_color_manager)
        section_table.attach(hsv_widget, 0, 1, 0, 1)

        preview_hbox = gtk.HBox()
        color_picker = ColorPickerButton()
        preview_adj = PreviousCurrentColorAdjuster()
        preview_adj.set_color_manager(app.brush_color_manager)
        color_picker.set_color_manager(app.brush_color_manager)
        preview_hbox.pack_start(color_picker, False, False)
        preview_hbox.pack_start(preview_adj, True, True)

        side_vbox = gtk.VBox()
        side_vbox.set_spacing(widgets.SPACING_TIGHT)
        section_table.attach(side_vbox, 1, 2, 0, 1)

        def init_proxy(widget, action_name):
            action = app.find_action(action_name)
            assert action is not None, \
                    "Must be able to find action %s" % (action_name,)
            widget.set_related_action(action)
            widget.connect("clicked", hide_panel_cb)
            return widget

        button = init_proxy(gtk.Button(), "ColorDetailsDialog")
        side_vbox.pack_end(button, False, False)
        side_vbox.pack_end(preview_hbox, False, False)

        side_vbox.pack_end(gtk.Alignment(), True, True)
        button = init_proxy(gtk.ToggleButton(), "HCYWheelTool")
        button.set_label(_("HCY Wheel"))
        side_vbox.pack_end(button, False, False)
        button = init_proxy(gtk.ToggleButton(), "PaletteTool")
        button.set_label(_("Color Palette"))
        side_vbox.pack_end(button, False, False)

        # History
        section_frame = widgets.section_frame(_("Recently Used"))
        panel_vbox.pack_start(section_frame, True, True)

        history = ColorHistoryView(app)
        history.button_clicked += self._history_button_clicked
        section_frame.add(history)