| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
from .abstract_select import AbstractSelectionTool |
| 19 |
from .utilities_colors import utilities_get_rgba_name, \ |
| 20 |
utilities_gdk_rgba_from_xy, \ |
| 21 |
utilities_gdk_rgba_to_hexadecimal |
| 22 |
from .utilities_paths import utilities_get_magic_path |
| 23 |
|
| 24 |
class ToolColorSelect(AbstractSelectionTool): |
| 25 |
__gtype_name__ = 'ToolColorSelect' |
| 26 |
|
| 27 |
def __init__(self, window, **kwargs): |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
super().__init__('color_select', _("Color selection"), 'tool-magic-symbolic', window) |
| 32 |
|
| 33 |
def get_tooltip(self, event_x, event_y, motion_behavior): |
| 34 |
color = utilities_gdk_rgba_from_xy(self.get_surface(), event_x, event_y) |
| 35 |
if color is None: |
| 36 |
return None |
| 37 |
color_name = utilities_get_rgba_name(color) |
| 38 |
color_code = utilities_gdk_rgba_to_hexadecimal(color) |
| 39 |
return color_name + "\n" + color_code |
| 40 |
|
| 41 |
def get_editing_tips(self): |
| 42 |
tips = super().get_editing_tips() |
| 43 |
if not self.selection_is_active(): |
| 44 |
label_warning1 = self.label + " - " + _("May not work for complex shapes") |
| 45 |
tips.append(label_warning1) |
| 46 |
label_warning2 = self.label + " - " + _("It will not work well " + \ |
| 47 |
"if the area's edges are blurry") |
| 48 |
tips.append(label_warning2) |
| 49 |
return tips |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
def press_define(self, event_x, event_y): |
| 54 |
pass |
| 55 |
|
| 56 |
def motion_define(self, event_x, event_y, render): |
| 57 |
pass |
| 58 |
|
| 59 |
def release_define(self, surfc, event_x, event_y): |
| 60 |
path = utilities_get_magic_path(surfc, event_x, event_y, self.window, 1) |
| 61 |
self._pre_load_path(path) |
| 62 |
if path is None: |
| 63 |
return |
| 64 |
self.operation_type = 'op-define' |
| 65 |
operation = self.build_operation() |
| 66 |
self.apply_operation(operation) |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|