From 7cbade3893c963f71a73b8d51cc2753dcd3ada25 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Mon, 5 Jun 2023 22:13:05 +0200 Subject: [PATCH] Support configurable eraser width Still not color of course --- pympress/scribble.py | 14 ++++++-------- pympress/share/defaults.conf | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pympress/scribble.py b/pympress/scribble.py index 86f4820f..7892ab22 100755 --- a/pympress/scribble.py +++ b/pympress/scribble.py @@ -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)], )) @@ -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)) @@ -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() diff --git a/pympress/share/defaults.conf b/pympress/share/defaults.conf index 8eb45b95..5765f46f 100644 --- a/pympress/share/defaults.conf +++ b/pympress/share/defaults.conf @@ -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)