def init_specialized_widgets(self, row): cname = "slow_tracking" label = Gtk.Label() # TRANSLATORS: Short alias for "Slow position tracking". This is # TRANSLATORS: used on the options panel. label.set_text(_("Smooth:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.adjustable_settings.add(cname) adj = self.app.brush_adjustment[cname] scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj) scale.set_draw_value(False) scale.set_hexpand(True) self.attach(label, 0, row, 1, 1) self.attach(scale, 1, row, 1, 1) row += 1 cname = "fakepressure" label = Gtk.Label() # TRANSLATORS: Short alias for "Fake Pressure (for mouse)". This is # TRANSLATORS: used on the options panel. label.set_text(_("Pressure:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) changed_cb = self._fakepressure_value_changed_cb adj = Gtk.Adjustment(value=0.5, lower=0.0, upper=1.0, step_increment=0.01, page_increment=0.1) self.app.fake_adjustment['fakepressure'] = adj adj.connect("value-changed", changed_cb) scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj) scale.set_draw_value(False) scale.set_hexpand(True) self.attach(label, 0, row, 1, 1) self.attach(scale, 1, row, 1, 1) row += 1 cname = "fakerotation" label = Gtk.Label() # TRANSLATORS: Short alias for "Fake Barrel Rotation (for mouse)". # TRANSLATORS: This is used on the options panel. label.set_text(_("Twist:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) changed_cb = self._fakerotation_value_changed_cb adj = Gtk.Adjustment(value=0.5, lower=0.0, upper=1.0, step_increment=0.0625, page_increment=0.25) self.app.fake_adjustment['fakerotation'] = adj adj.connect("value-changed", changed_cb) scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj) scale.set_draw_value(False) scale.set_hexpand(True) self.attach(label, 0, row, 1, 1) self.attach(scale, 1, row, 1, 1) row += 1 return row
def _init_adjustments(self): """Initializes adjustments for the scales used internally When running as part of the MyPaint app, the brush setting ones are shared with it. """ # Brush setting base values if self.app: for s in brushsettings.settings_visible: adj = self.app.brush_adjustment[s.cname] self._base_adj[s.cname] = adj # The application instance manages value-changed callbacks itself. else: for s in brushsettings.settings_visible: adj = Gtk.Adjustment(value=s.default, lower=s.min, upper=s.max, step_increment=0.01, page_increment=0.1) self._base_adj[s.cname] = adj changed_cb = self._testmode_base_value_adj_changed_cb for cname, adj in iteritems(self._base_adj): adj.connect('value-changed', changed_cb, cname) # Per-input scale maxima and minima for inp in brushsettings.inputs: name = inp.name adj = Gtk.Adjustment(value=1.0 / 4.0, lower=-1.0, upper=1.0, step_increment=0.01, page_increment=0.1) adj.connect("value-changed", self.input_adj_changed_cb, inp) self._input_y_adj[name] = adj lower = -20.0 upper = +20.0 # Pre-libmypaint split, the limits were read from json and could be # None. Now that cannot be checked directly, so instead check if # the limits are extreme (in libmypaint, they are set to +-FLT_MAX) if abs(inp.hard_min) < 1e16: lower = inp.hard_min if abs(inp.hard_max) < 1e16: upper = inp.hard_max adj = Gtk.Adjustment(value=inp.soft_min, lower=lower, upper=upper - 0.1, step_increment=0.01, page_increment=0.1) adj.connect("value-changed", self.input_adj_changed_cb, inp) self._input_xmin_adj[name] = adj adj = Gtk.Adjustment(value=inp.soft_max, lower=lower + 0.1, upper=upper, step_increment=0.01, page_increment=0.1) adj.connect("value-changed", self.input_adj_changed_cb, inp) self._input_xmax_adj[name] = adj
def __init__(self): super(SymmetryEditOptionsWidget, self).__init__( xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0, ) self._symmetry_type_combo = None self._axis_sym_lines_entry = None from gui.application import get_app self.app = get_app() rootstack = self.app.doc.model.layer_stack x, y = rootstack.symmetry_center def pos_adj(start_val): return Gtk.Adjustment( value=start_val, upper=32000, lower=-32000, step_increment=1, page_increment=100, ) self._axis_pos_adj_x = pos_adj(x) self._xpos_cb_id = self._axis_pos_adj_x.connect( 'value-changed', self._axis_pos_adj_x_changed, ) self._axis_pos_adj_y = pos_adj(y) self._ypos_cb_id = self._axis_pos_adj_y.connect( 'value-changed', self._axis_pos_adj_y_changed, ) self._axis_angle = Gtk.Adjustment( value=rootstack.symmetry_angle, upper=180, lower=0, step_increment=1, page_increment=15, ) self._angle_cb_id = self._axis_angle.connect( "value-changed", self._angle_value_changed) self._axis_symmetry_lines = Gtk.Adjustment( value=rootstack.symmetry_lines, upper=50, lower=2, step_increment=1, page_increment=3, ) self._lines_cb_id = self._axis_symmetry_lines.connect( 'value-changed', self._axis_rot_symmetry_lines_changed, ) self._init_ui() rootstack.symmetry_state_changed += self._symmetry_state_changed_cb
def __init__(self): super(SymmetryEditOptionsWidget, self).__init__( xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0, ) self._axis_pos_x_dialog = None self._axis_pos_x_button = None self._axis_pos_y_dialog = None self._axis_pos_y_button = None self._symmetry_type_combo = None self._axis_rot_sym_lines_entry = None from gui.application import get_app self.app = get_app() rootstack = self.app.doc.model.layer_stack self._axis_pos_adj_x = Gtk.Adjustment( value=rootstack.symmetry_x, upper=32000, lower=-32000, step_increment=1, page_increment=100, ) self._axis_pos_adj_x.connect( 'value-changed', self._axis_pos_adj_x_changed, ) self._axis_pos_adj_y = Gtk.Adjustment( value=rootstack.symmetry_y, upper=32000, lower=-32000, step_increment=1, page_increment=100, ) self._axis_pos_adj_y.connect( 'value-changed', self._axis_pos_adj_y_changed, ) self._axis_rot_symmetry_lines = Gtk.Adjustment( value=rootstack.rot_symmetry_lines, upper=50, lower=2, step_increment=1, page_increment=3, ) self._axis_rot_symmetry_lines.connect( 'value-changed', self._axis_rot_symmetry_lines_changed, ) self._init_ui() rootstack.symmetry_state_changed += self._symmetry_state_changed_cb self._update_axis_pos_x_button_label(rootstack.symmetry_x) self._update_axis_pos_y_button_label(rootstack.symmetry_y)
def pos_adj(start_val): return Gtk.Adjustment( value=start_val, upper=32000, lower=-32000, step_increment=1, page_increment=100, )
def init_brush_adjustments(self): """Initializes the base value adjustments for all brush settings""" assert not self.brush_adjustment changed_cb = self._brush_adjustment_value_changed_cb for s in brushsettings.settings_visible: adj = Gtk.Adjustment(value=s.default, lower=s.min, upper=s.max, step_increment=0.01, page_increment=0.1) self.brush_adjustment[s.cname] = adj adj.connect("value-changed", changed_cb, s.cname) self.brush.observers.append(self._brush_modified_cb)
def specific_setup(self, pref_path, value): self.adj = Gtk.Adjustment( value=value, lower=self._lower, upper=self._upper, step_incr=self._step, page_incr=self._page, ) def _value_changed_cb(a): self._set_value(self.get_value()) self.adj.connect("value-changed", _value_changed_cb)
def __init__(self): super(FrameEditOptionsWidget, self).__init__( xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0, ) from gui.application import get_app self.app = get_app() self.callbacks_active = False docmodel = self.app.doc.model x, y, w, h = docmodel.get_frame() dpi = docmodel.get_resolution() self.width_adj = UnitAdjustment(w, upper=32000, lower=1, step_increment=1, page_increment=128, dpi=dpi) self.height_adj = UnitAdjustment(h, upper=32000, lower=1, step_increment=1, page_increment=128, dpi=dpi) self.dpi_adj = Gtk.Adjustment( value=dpi, upper=9600, lower=1, step_increment=76, # hack: 3 clicks 72->300 page_increment=dpi) docmodel.frame_updated += self._frame_updated_cb self._init_ui() self.width_adj.connect('value-changed', self.on_size_adjustment_changed) self.height_adj.connect('value-changed', self.on_size_adjustment_changed) self.dpi_adj.connect('value-changed', self.on_dpi_adjustment_changed) self._update_size_button()
def __init__(self): super(FrameEditOptionsWidget, self).__init__() from gui.application import get_app self.app = get_app() self.callbacks_active = False docmodel = self.app.doc.model x, y, w, h = docmodel.get_frame() dpi = docmodel.get_resolution() self.width_adj = UnitAdjustment(w, upper=32000, lower=1, step_increment=1, page_increment=128, dpi=dpi) self.height_adj = UnitAdjustment(h, upper=32000, lower=1, step_increment=1, page_increment=128, dpi=dpi) self.dpi_adj = Gtk.Adjustment( value=dpi, upper=9600, lower=1, step_increment=76, # hack: 3 clicks 72->300 page_increment=dpi) frame_overlays = list( filter(lambda o: isinstance(o, FrameOverlay), self.app.doc.tdw.display_overlays)) assert len(frame_overlays) == 1, "Should be exactly 1 frame overlay!" self._overlay = frame_overlays[0] docmodel.frame_updated += self._frame_updated_cb self._init_ui() self.width_adj.connect('value-changed', self.on_size_adjustment_changed) self.height_adj.connect('value-changed', self.on_size_adjustment_changed) self.dpi_adj.connect('value-changed', self.on_dpi_adjustment_changed)
def __init__(self, app): """Initializer; initial settings are loaded from the app prefs""" object.__init__(self) self.app = app self.adjustments = {} #: Dictionary of GtkAdjustments self.observers = [] #: List of callbacks self._idle_srcid = None self._changed_settings = set() for line_list in _LINE_MODE_SETTINGS_LIST: cname, name, const, min_, default, max_, tooltip = line_list prefs_key = "linemode.%s" % cname value = float(self.app.preferences.get(prefs_key, default)) adj = Gtk.Adjustment(value=value, lower=min_, upper=max_, step_increment=0.01, page_increment=0.1) adj.connect("value-changed", self._value_changed_cb, prefs_key) self.adjustments[cname] = adj
def __init__(self): import gui.application app = gui.application.get_app() assert app is not None super(PreferencesWindow, self).__init__( app=app, title=_('Preferences'), transient_for=app.drawWindow, destroy_with_parent=True, ) self.add_buttons( Gtk.STOCK_REVERT_TO_SAVED, RESPONSE_REVERT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT, ) self.connect('response', self.on_response) self.in_update_ui = False # Set up widgets builder = Gtk.Builder() builder.set_translation_domain("mypaint") ui_dir = os.path.dirname(os.path.abspath(__file__)) xml_path = os.path.join(ui_dir, 'preferenceswindow.glade') builder.add_from_file(xml_path) self._builder = builder getobj = builder.get_object self.compat_preferences = CompatibilityPreferences(app, builder) # Populate locale/language combo box locale_combo = getobj("locale_combobox") setup_locale_combobox(locale_combo) # Notebook nb = getobj("prefs_notebook") self.nb = nb self.vbox.pack_start(nb, True, True, 0) # Curve init curve = getobj("mapping_curve") curve.changed_cb = self.pressure_curve_changed_cb curve.magnetic = False self._pressure_curve = curve # Button mappings editor assert "input.button_mapping" in app.preferences reg = gui.mode.ModeRegistry actions_possible = [ n for n in reg.get_action_names() if issubclass(reg.get_mode_class(n), gui.mode.DragMode) ] actions_possible += gui.mode.BUTTON_BINDING_ACTIONS bm_ed = getobj("button_mapping_editor") bm_ed.set_bindings(app.preferences["input.button_mapping"]) bm_ed.set_actions(actions_possible) bm_ed.bindings_observers.append(self.button_mapping_edited_cb) # Autosave controls autosave_interval_spinbut = getobj("autosave_interval_spinbutton") self._autosave_interval_spinbutton = autosave_interval_spinbut # Dynamic brush cursor crosshair settings p = app.preferences dyn_ch_checkbut = getobj("show_crosshair_checkbutton") dyn_ch_enabled = p.get("cursor.dynamic_crosshair", False) dyn_ch_checkbut.set_active(dyn_ch_enabled) self._dynamic_crosshair_checkbut = dyn_ch_checkbut dyn_ch_spinner = getobj("dynamic_crosshair_threshold_spinbutton") dyn_ch_threshold = p.get("cursor.dynamic_crosshair_threshold", 8) max_cursor = max(Gdk.Display.get_default().get_maximal_cursor_size()) adj = Gtk.Adjustment(value=dyn_ch_threshold, lower=(1 + p.get("cursor.freehand.min_size", 4) // 2), upper=max_cursor, step_increment=1, page_increment=2) dyn_ch_spinner.set_adjustment(adj) dyn_ch_spinner.set_sensitive(dyn_ch_enabled) self._dyn_crosshair_threshold = dyn_ch_spinner self._dyn_crosshair_label = getobj("dynamic_crosshair_threshold_label") # Signal hookup now everything is in the right initial state self._builder.connect_signals(self)
def __init__(self): Gtk.Grid.__init__(self) self.set_row_spacing(6) self.set_column_spacing(6) from gui.application import get_app self.app = get_app() prefs = self.app.preferences row = 0 label = Gtk.Label() label.set_markup( C_( "fill options: numeric value that determines whether tested pixels" " will be included in the fill, based on color difference", u"Tolerance:")) label.set_tooltip_text( C_( "fill options: Tolerance (tooltip) " "Note: 'the start' refers to the color of " "the starting point (pixel) of the fill", u"How much pixel colors are allowed to vary from the start\n" u"before Flood Fill will refuse to fill them")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) value = prefs.get(self.TOLERANCE_PREF, self.DEFAULT_TOLERANCE) value = float(value) adj = Gtk.Adjustment(value=value, lower=0.0, upper=1.0, step_increment=0.05, page_increment=0.05, page_size=0) adj.connect("value-changed", self._tolerance_changed_cb) self._tolerance_adj = adj scale = Gtk.Scale() scale.set_hexpand(True) scale.set_adjustment(adj) scale.set_draw_value(False) self.attach(scale, 1, row, 1, 1) row += 1 label = Gtk.Label() label.set_markup( C_( "fill options: option category (label) " "Options under this category relate to what the fill is" "based on, not where the actual fill ends up.", u"Source:")) label.set_tooltip_text( C_("fill options: 'Source:' category (tooltip)", u"The input that the fill will be based on")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) # Selection independent fill-basis root = self.app.doc.model.layer_stack src_list = FlatLayerList(root) self.src_list = src_list combo = Gtk.ComboBox.new_with_model(src_list) cell = Gtk.CellRendererText() cell.set_property("ellipsize", Pango.EllipsizeMode.END) combo.pack_start(cell, True) def layer_name_render(_, name_cell, model, it): """ Display layer groups in italics and child layers indented with two spaces per level """ name, path, layer = model[it][:3] if name is None: name = "Layer" if layer is None: name_cell.set_property("markup", "( <i>{text}</i> )".format(text=name)) return indented = " " * (len(path) - 1) + name if isinstance(layer, lib.layer.LayerStack): name_cell.set_property("markup", "<i>{text}</i>".format(text=indented)) else: name_cell.set_property("text", indented) def sep_func(model, it): return model[it][0] is None combo.set_row_separator_func(sep_func) combo.set_cell_data_func(cell, layer_name_render) combo.set_tooltip_text( C_("fill options: 'Source' category: Layer dropdown (tooltip)", u"Select a specific layer you want the fill to be based on")) combo.set_active(0) self._prev_src_layer = None root.layer_inserted += self._layer_inserted_cb self._src_combo_cb_id = combo.connect("changed", self._src_combo_changed_cb) self._src_combo = combo self.attach(combo, 1, row, 2, 1) row += 1 text = C_( "fill options: 'Source:' category: toggle (label)\n" "When this option is enabled, the fill is based\n" "on the combination of all visible layers", u"Sample Merged") checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( C_( "fill options: Sample Merged (tooltip)", u"When considering which area to fill, use a\n" u"temporary merge of all the visible layers\n" u"underneath the current layer")) self.attach(checkbut, 1, row, 1, 1) active = bool( prefs.get(self.SAMPLE_MERGED_PREF, self.DEFAULT_SAMPLE_MERGED)) checkbut.set_active(active) checkbut.connect("toggled", self._sample_merged_toggled_cb) self._sample_merged_toggle = checkbut self._src_combo.set_sensitive(not active) row += 1 text = C_( "fill options: toggle whether the fill will be limited " "by the viewport", u"Limit to View") checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( C_( "fill options: Limit to View (tooltip)\n" "Note: 'that can fit the view' is equivalent to: " "'in which the entire visible part of the canvas can fit", u"Limit the area that can be filled, based on the viewport.\n" u"If the view is rotated, the fill will be limited to the\n" u"smallest canvas-aligned rectangle that can fit the view.")) self.attach(checkbut, 1, row, 1, 1) active = bool( prefs.get(self.LIM_TO_VIEW_PREF, self.DEFAULT_LIM_TO_VIEW)) checkbut.set_active(active) checkbut.connect("toggled", self._limit_to_view_toggled_cb) self._limit_to_view_toggle = checkbut row += 1 label = Gtk.Label() label.set_markup( C_( "fill options: option category (label)\n" "Options under this category relate to where the fill " "will end up (default: the active layer) and how it " "will be combined with that layer.", u"Target:")) label.set_tooltip_text( C_("fill options: 'Target:' category (tooltip)", u"Where the output should go")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) text = C_( "fill options: Target | toggle (label)\n" "When this option is enabled, the fill will be placed on a new\n" "layer above the active layer. Option resets after each fill.", u"New Layer (once)") checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( C_( "fill options: Target | New Layer (tooltip)", u"Create a new layer with the results of the fill.\n" u"This is turned off automatically after use.")) self.attach(checkbut, 1, row, 1, 1) active = self.DEFAULT_MAKE_NEW_LAYER checkbut.set_active(active) self._make_new_layer_toggle = checkbut row += 1 label = Gtk.Label() label.set_markup(u"<b>\u26a0</b>") # unicode warning sign label.set_tooltip_text( C_("fill options: Target | Blend Mode dropdown - warning text", u"This mode does nothing when alpha locking is enabled!")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self._warning_shown = False # Not attached here, warning label is only shown for no-op combinations self._bm_warning_label = (label, 0, row, 1, 1) modes = list(lib.modes.STANDARD_MODES) modes.remove(lib.mypaintlib.CombineSpectralWGM) modes.insert(0, lib.mypaintlib.CombineSpectralWGM) combo = gui.layers.new_blend_mode_combo(modes, lib.modes.MODE_STRINGS) combo.set_tooltip_text( C_("fill options: Target | Blend Mode dropdown (tooltip)", u"Blend mode used when filling")) # Reinstate the last _mode id_ independent of mode-list order mode_type = prefs.get(self.BLEND_MODE_PREF, self.DEFAULT_BLEND_MODE) mode_dict = {mode: index for index, mode, in enumerate(modes)} # Fallback is only necessary for compat. if a mode is ever removed active = mode_dict.get(int(mode_type), self.DEFAULT_BLEND_MODE) combo.set_active(active) combo.connect("changed", self._bm_combo_changed_cb) self._blend_mode_combo = combo self.attach(combo, 1, row, 2, 1) row += 1 label = Gtk.Label() label.set_markup(_(u"Opacity:")) label.set_tooltip_text( C_("fill options: Opacity slider (tooltip)", u"Opacity of the fill")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) value = prefs.get(self.OPACITY_PREF, self.DEFAULT_OPACITY) adj = Gtk.Adjustment(value=value, lower=0.0, upper=1.0, step_increment=0.05, page_increment=0.05, page_size=0) adj.connect("value-changed", self._opacity_changed_cb) self._opacity_adj = adj scale = Gtk.Scale() scale.set_hexpand(True) scale.set_adjustment(adj) scale.set_draw_value(False) self.attach(scale, 1, row, 1, 1) row += 1 self.attach(Gtk.Separator(), 0, row, 2, 1) row += 1 label = Gtk.Label() label.set_markup( C_("fill options: numeric option - grow/shrink fill (label)", u"Offset:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) TILE_SIZE = lib.floodfill.TILE_SIZE value = prefs.get(self.OFFSET_PREF, self.DEFAULT_OFFSET) adj = Gtk.Adjustment(value=value, lower=-TILE_SIZE, upper=TILE_SIZE, step_increment=1, page_increment=4) adj.connect("value-changed", self._offset_changed_cb) self._offset_adj = adj spinbut = Gtk.SpinButton() spinbut.set_tooltip_text( C_("fill options: Offset (tooltip)", u"The distance in pixels to grow or shrink the fill")) spinbut.set_hexpand(True) spinbut.set_adjustment(adj) spinbut.set_numeric(True) self.attach(spinbut, 1, row, 1, 1) row += 1 label = Gtk.Label() label.set_markup( C_("fill options: numeric option for blurring fill (label)", u"Feather:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) value = prefs.get(self.FEATHER_PREF, self.DEFAULT_FEATHER) adj = Gtk.Adjustment(value=value, lower=0, upper=TILE_SIZE, step_increment=1, page_increment=4) adj.connect("value-changed", self._feather_changed_cb) self._feather_adj = adj spinbut = Gtk.SpinButton() spinbut.set_tooltip_text( C_("fill options: Feather (tooltip)", u"The amount of blur to apply to the fill")) spinbut.set_hexpand(True) spinbut.set_adjustment(adj) spinbut.set_numeric(True) self.attach(spinbut, 1, row, 1, 1) row += 1 self.attach(Gtk.Separator(), 0, row, 2, 1) row += 1 gap_closing_params = Gtk.Grid() self._gap_closing_grid = gap_closing_params text = C_("fill options: gap detection toggle (label)", u'Use Gap Detection') checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( C_( "fill options: Use Gap Detection (tooltip)", u"Try to detect gaps and not fill past them.\n" u"Note: This can be a lot slower than the regular fill, " u"only enable when you need it.")) self._gap_closing_toggle = checkbut checkbut.connect("toggled", self._gap_closing_toggled_cb) active = prefs.get(self.GAP_CLOSING_PREF, self.DEFAULT_GAP_CLOSING) checkbut.set_active(active) gap_closing_params.set_sensitive(active) self.attach(checkbut, 0, row, 2, 1) row += 1 self.attach(gap_closing_params, 0, row, 2, 1) gcp_row = 0 label = Gtk.Label() label.set_markup( C_( "fill options: gap-detection sub-option, numeric setting (label)", u"Max Gap Size:")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) gap_closing_params.attach(label, 0, gcp_row, 1, 1) value = prefs.get(self.GAP_SIZE_PREF, self.DEFAULT_GAP_SIZE) adj = Gtk.Adjustment(value=value, lower=1, upper=int(TILE_SIZE / 2), step_increment=1, page_increment=4) adj.connect("value-changed", self._max_gap_size_changed_cb) self._max_gap_adj = adj spinbut = Gtk.SpinButton() spinbut.set_tooltip_text( C_( "fill options: Max Gap Size (tooltip)", u"The size of the largest gaps that can be detected.\n" u"Using large values can make the fill run a lot slower.")) spinbut.set_hexpand(True) spinbut.set_adjustment(adj) spinbut.set_numeric(True) gap_closing_params.attach(spinbut, 1, gcp_row, 1, 1) gcp_row += 1 text = C_( "fill options: on/off sub-option, numeric (label)\n" "When enabled, if the fill stops after going past a detected gap, " "it 'pulls' the fill back out of the gap to the other side of it.", u"Prevent seeping") checkbut = Gtk.CheckButton.new_with_label(text) active = prefs.get(self.RETRACT_SEEPS_PREF, self.DEFAULT_RETRACT_SEEPS) checkbut.set_active(active) checkbut.set_tooltip_text( C_( "fill options: Prevent seeping (tooltip)", u"Try to prevent the fill from seeping into the gaps.\n" u"If a fill starts in a detected gap, this option will do nothing." )) checkbut.connect("toggled", self._retract_seeps_toggled_cb) self._retract_seeps_toggle = checkbut gap_closing_params.attach(checkbut, 1, gcp_row, 1, 1) row += 1 align = Gtk.Alignment.new(0.5, 1.0, 1.0, 0.0) align.set_vexpand(True) button = Gtk.Button(label=_("Reset")) button.connect("clicked", self._reset_clicked_cb) button.set_tooltip_text( C_("fill options: Reset button (tooltip)", "Reset options to their defaults")) align.add(button) self.attach(align, 0, row, 2, 1) # Set up blend modifier callbacks self.bm = self.get_blend_modes() self.bm.mode_changed += self.update_blend_mode
def __init__(self): GObject.GObject.__init__(self) from gui.application import get_app app = get_app() self.app = app self.set_spacing(widgets.SPACING_CRAMPED) self.set_border_width(widgets.SPACING_TIGHT) # GtkTreeView init docmodel = app.doc.model view = layers.RootStackTreeView(docmodel) self._treemodel = view.get_model() self._treeview = view # RootStackTreeView events view.current_layer_rename_requested += self._layer_properties_cb view.current_layer_changed += self._blink_current_layer_cb view.current_layer_menu_requested += self._popup_menu_cb # Drag and drop view.drag_began += self._view_drag_began_cb view.drag_ended += self._view_drag_ended_cb statusbar_cid = app.statusbar.get_context_id(self.STATUSBAR_CONTEXT) self._drag_statusbar_context_id = statusbar_cid # View scrolls view_scroll = Gtk.ScrolledWindow() view_scroll.set_shadow_type(Gtk.ShadowType.ETCHED_IN) vscroll_pol = Gtk.PolicyType.ALWAYS hscroll_pol = Gtk.PolicyType.AUTOMATIC view_scroll.set_policy(hscroll_pol, vscroll_pol) view_scroll.add(view) view_scroll.set_size_request(-1, 200) view_scroll.set_hexpand(True) view_scroll.set_vexpand(True) # Context menu ui_dir = os.path.dirname(os.path.abspath(__file__)) ui_path = os.path.join(ui_dir, "layerswindow.xml") self.app.ui_manager.add_ui_from_file(ui_path) menu = self.app.ui_manager.get_widget("/LayersWindowPopup") menu.set_title(_("Layer")) self.connect("popup-menu", self._popup_menu_cb) menu.attach_to_widget(self, None) self._menu = menu self._layer_specific_ui_mergeids = [] self._layer_specific_ui_class = None # Main layout grid grid = Gtk.Grid() grid.set_row_spacing(widgets.SPACING_TIGHT) grid.set_column_spacing(widgets.SPACING) row = -1 # Visibility set management row += 1 layer_view_ui = gui.layervis.LayerViewUI(docmodel) grid.attach(layer_view_ui.widget, 0, row, 6, 1) self._layer_view_ui = layer_view_ui # Mode dropdown row += 1 # ComboBox w/ list model (mode_num, label, sensitive, scale) modes = list(STACK_MODES + STANDARD_MODES) modes.remove(lib.mypaintlib.CombineSpectralWGM) modes.insert(0, lib.mypaintlib.CombineSpectralWGM) combo = layers.new_blend_mode_combo(modes, MODE_STRINGS) self._layer_mode_combo = combo grid.attach(combo, 0, row, 5, 1) # Opacity widgets adj = Gtk.Adjustment(lower=0, upper=100, step_increment=1, page_increment=10) sbut = Gtk.ScaleButton() sbut.set_adjustment(adj) sbut.remove(sbut.get_child()) sbut.set_hexpand(False) sbut.set_vexpand(False) label_text_widest = self.OPACITY_LABEL_TEXT_TEMPLATE % (100, ) label = Gtk.Label(label_text_widest) label.set_width_chars(len(label_text_widest)) # prog = Gtk.ProgressBar() # prog.set_show_text(False) sbut.add(label) self._opacity_scale_button = sbut # self._opacity_progress = prog self._opacity_label = label self._opacity_adj = adj grid.attach(sbut, 5, row, 1, 1) # Layer list and controls row += 1 layersbox = Gtk.VBox() style = layersbox.get_style_context() style.add_class(Gtk.STYLE_CLASS_LINKED) style = view_scroll.get_style_context() style.set_junction_sides(Gtk.JunctionSides.BOTTOM) list_tools = inline_toolbar(self.app, [ ("NewLayerGroupAbove", "mypaint-layer-group-new-symbolic"), ("NewPaintingLayerAbove", "mypaint-add-symbolic"), ("RemoveLayer", "mypaint-remove-symbolic"), ("RaiseLayerInStack", "mypaint-up-symbolic"), ("LowerLayerInStack", "mypaint-down-symbolic"), ("DuplicateLayer", None), ("MergeLayerDown", None), ]) style = list_tools.get_style_context() style.set_junction_sides(Gtk.JunctionSides.TOP) layersbox.pack_start(view_scroll, True, True, 0) layersbox.pack_start(list_tools, False, False, 0) layersbox.set_hexpand(True) layersbox.set_vexpand(True) grid.attach(layersbox, 0, row, 6, 1) # Background layer controls row += 1 show_bg_btn = Gtk.CheckButton() change_bg_act = self.app.find_action("BackgroundWindow") change_bg_btn = widgets.borderless_button(action=change_bg_act) show_bg_act = self.app.find_action("ShowBackgroundToggle") show_bg_btn.set_related_action(show_bg_act) grid.attach(show_bg_btn, 0, row, 5, 1) grid.attach(change_bg_btn, 5, row, 1, 1) # Pack self.pack_start(grid, False, True, 0) # Updates from the real layers tree (TODO: move to lib/layers.py) self._processing_model_updates = False self._opacity_adj.connect('value-changed', self._opacity_adj_changed_cb) self._layer_mode_combo.connect('changed', self._layer_mode_combo_changed_cb) rootstack = docmodel.layer_stack rootstack.layer_properties_changed += self._layer_propchange_cb rootstack.current_path_updated += self._current_path_updated_cb # Initial update self.connect("show", self._show_cb)