Skip to content

Commit

Permalink
Support configurable eraser width
Browse files Browse the repository at this point in the history
Still not color of course
  • Loading branch information
Cimbali committed Jun 5, 2023
1 parent 7d38f17 commit 7cbade3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pympress/scribble.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(self, config, builder, notes_mode):
self.eraser_surface = cairo.ImageSurface.create_from_png(str(util.get_icon_path('eraser.png')))

# Load color and active pen preferences. Pen 0 is the eraser.
self.color_width = [(Gdk.RGBA(0, 0, 0, 0), 150)] + list(zip(
self.color_width = [(Gdk.RGBA(0, 0, 0, 0), config.getfloat('highlight', 'width_eraser'))] + list(zip(
[self.parse_color(config.get('highlight', 'color_{}'.format(pen))) for pen in range(1, 10)],
[config.getfloat('highlight', 'width_{}'.format(pen)) for pen in range(1, 10)],
))
Expand Down Expand Up @@ -573,14 +573,13 @@ def update_width(self, widget, event, value):
def update_active_color_width(self):
""" Update modifications to the active scribble color and width, on the pen button and config object
"""
if not self.active_preset:
return

self.color_width[self.active_preset] = self.scribble_color, self.scribble_width
self.scribble_preset_buttons[self.active_preset].queue_draw()
if self.active_preset:
self.scribble_preset_buttons[self.active_preset].queue_draw()

pen = self.active_preset
self.config.set('highlight', 'color_{}'.format(pen), self.scribble_color.to_string())
pen = self.active_preset if self.active_preset else 'eraser'
if self.active_preset:
self.config.set('highlight', 'color_{}'.format(pen), self.scribble_color.to_string())
self.config.set('highlight', 'width_{}'.format(pen), str(self.scribble_width))


Expand Down Expand Up @@ -811,7 +810,6 @@ def load_preset(self, gaction=None, target=None):
self.scribble_width_selector.set_value(math.log10(self.scribble_width) if self.scribble_width < 10
else 1 + (self.scribble_width - 10) / 90)
self.scribble_color_selector.set_sensitive(target != 'eraser')
self.scribble_width_selector.set_sensitive(target != 'eraser')

# Re-draw the eraser
self.scribble_p_da.queue_draw()
Expand Down
1 change: 1 addition & 0 deletions pympress/share/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ vertical = bottom
maxpages = 200

[highlight]
width_eraser = 90
color_1 = rgba(255,255,0,0.5)
width_1 = 90
color_2 = rgba(128,255,0,0.5)
Expand Down

0 comments on commit 7cbade3

Please sign in to comment.