| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
from gi.repository import Gdk |
| 19 |
from .abstract_classic_tool import AbstractClassicTool |
| 20 |
from .utilities_colors import utilities_get_rgba_name, \ |
| 21 |
utilities_gdk_rgba_from_xy, \ |
| 22 |
utilities_gdk_rgba_to_hexadecimal |
| 23 |
|
| 24 |
class ToolPicker(AbstractClassicTool): |
| 25 |
__gtype_name__ = 'ToolPicker' |
| 26 |
|
| 27 |
def __init__(self, window, **kwargs): |
| 28 |
|
| 29 |
|
| 30 |
super().__init__('picker', _("Color Picker"), 'color-select-symbolic', window) |
| 31 |
self.use_size = False |
| 32 |
|
| 33 |
def get_options_model(self): |
| 34 |
return None |
| 35 |
|
| 36 |
def get_tooltip(self, event_x, event_y, motion_behavior): |
| 37 |
color = utilities_gdk_rgba_from_xy(self.get_surface(), event_x, event_y) |
| 38 |
if color is None: |
| 39 |
return None |
| 40 |
color_name = utilities_get_rgba_name(color) |
| 41 |
color_code = utilities_gdk_rgba_to_hexadecimal(color) |
| 42 |
return color_name + "\n" + color_code |
| 43 |
|
| 44 |
def on_release_on_area(self, event, surface, event_x, event_y): |
| 45 |
color = utilities_gdk_rgba_from_xy(surface, event_x, event_y) |
| 46 |
if event.button == 1: |
| 47 |
self.window.options_manager.set_left_color(color) |
| 48 |
elif event.button == 3: |
| 49 |
self.window.options_manager.set_right_color(color) |
| 50 |
self.window.back_to_previous() |
| 51 |
|
| 52 |
|
| 53 |
|