summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-10-19 22:57:40 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-10-19 22:57:40 -0200
commite9dfef704816b7efde2eba04dbfc82e8f0497548 (patch)
treee4f93d2cdca38d8aff50962dfd850dc0ea2422e6
parent044184ef175579b6b439b1b9b4b879f1816a18cc (diff)
Show color on hexa / rgb when it's enabled / disabled
No need to wait for cursor position changes to update it.
-rw-r--r--src/bin/main.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 781ae11..eeff1d8 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -82,6 +82,7 @@ struct _Zone {
82 struct { 82 struct {
83 int x, y; 83 int x, y;
84 } last_mouse; 84 } last_mouse;
85 unsigned int color;
85 Eina_Bool last_ruler_used : 1; 86 Eina_Bool last_ruler_used : 1;
86 Eina_Bool keyboard_move : 1; 87 Eina_Bool keyboard_move : 1;
87}; 88};
@@ -163,6 +164,23 @@ theme_apply(Evas_Object *edje, const char *group)
163} 164}
164 165
165static void 166static void
167set_color(const Zone *zone)
168{
169 char buf[64];
170
171 if (hex_colors)
172 snprintf(buf, sizeof(buf), "#%06x", zone->color);
173 else
174 {
175 snprintf(buf, sizeof(buf), "%d %d %d",
176 (zone->color >> 16) & 0xff,
177 (zone->color >> 8) & 0xff,
178 (zone->color & 0xff));
179 }
180 edje_object_part_text_set(zone->zoom.frame, "color", buf);
181}
182
183static void
166show_hexa_apply(void) 184show_hexa_apply(void)
167{ 185{
168 const Eina_List *l; 186 const Eina_List *l;
@@ -171,6 +189,7 @@ show_hexa_apply(void)
171 EINA_LIST_FOREACH(zones, l, zone) 189 EINA_LIST_FOREACH(zones, l, zone)
172 { 190 {
173 elm_check_state_set(zone->gui.hex_colors, hex_colors); 191 elm_check_state_set(zone->gui.hex_colors, hex_colors);
192 set_color(zone);
174 } 193 }
175} 194}
176 195
@@ -451,7 +470,7 @@ _event_mouse_tracker(void *data)
451 if (zone->zoom.ready) 470 if (zone->zoom.ready)
452 { 471 {
453 int fx, fy, fw, fh, zx, zy, zw, zh, stride, iw, ih; 472 int fx, fy, fw, fh, zx, zy, zw, zh, stride, iw, ih;
454 unsigned int *pixels, color; 473 unsigned int *pixels;
455 474
456 zw = zone->zoom.ideal_size.w < zone->w / 4 ? 475 zw = zone->zoom.ideal_size.w < zone->w / 4 ?
457 zone->zoom.ideal_size.w : zone->w / 4; 476 zone->zoom.ideal_size.w : zone->w / 4;
@@ -487,18 +506,9 @@ _event_mouse_tracker(void *data)
487 EINA_SAFETY_ON_FALSE_GOTO(x < iw, position_invalid); 506 EINA_SAFETY_ON_FALSE_GOTO(x < iw, position_invalid);
488 EINA_SAFETY_ON_FALSE_GOTO(y < ih, position_invalid); 507 EINA_SAFETY_ON_FALSE_GOTO(y < ih, position_invalid);
489 508
490 color = pixels[y * (stride / sizeof(unsigned int)) + x]; 509 zone->color = pixels[y * (stride / sizeof(unsigned int)) + x];
491 color = color & 0xffffff; 510 zone->color = zone->color & 0xffffff;
492 if (hex_colors) 511 set_color(zone);
493 snprintf(buf, sizeof(buf), "#%06x", color);
494 else
495 {
496 snprintf(buf, sizeof(buf), "%d %d %d",
497 (color >> 16) & 0xff,
498 (color >> 8) & 0xff,
499 (color & 0xff));
500 }
501 edje_object_part_text_set(zone->zoom.frame, "color", buf);
502 512
503 position_invalid: 513 position_invalid:
504 evas_object_image_data_set(zone->zoom.image, pixels); 514 evas_object_image_data_set(zone->zoom.image, pixels);