You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.8 KiB

#include "e.h"
static void _e_color_dialog_button1_click(void *data, E_Dialog *edia);
static void _e_color_dialog_button2_click(void *data, E_Dialog *edia);
static void _e_color_dialog_free(E_Color_Dialog *dia);
static void _e_color_dialog_dia_del(void *obj);
static void _e_color_dialog_cb_csel_change(void *data, Evas_Object *obj, void *ev);
* Create a color selector dialog.
compositor rewrite / charlie-foxtrot situation huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once. * compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine. ** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes ** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects ** protocol-specific window management and compositor functionality is now kept exclusively in backend files ** e_pixmap api provides generic client finding and rendering api ** screen/xinerama screens are now provided directly by compositor on startup and re-set on change ** e_comp_render_update finally replaced with eina_tiler ** wayland compositor no longer creates X windows ** compositor e_layout removed entirely * e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra * e_manager is just for screensaver and keybind stuff now, possibly remove later? * e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor ** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed. *** do NOT set interceptors on a client's comp_object. seriously. * startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor * ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get * e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas * deskmirror is (more) broken for now * illume is totally fucked * Ecore_X_Window replaced with Ecore_Window in most cases * edge binding XWindows replaced with regular canvas objects * some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result comp files and descriptions: e_comp.c - overall compositor functions, rendering/update loop, shape cutting e_comp_x.c - X window management and compositor functionality e_comp_wl.c - Wayland surface management and compositor functionality e_comp_canvas.c - general compositor canvas functions and utilities e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems additional authors: feature: new compositor removal: e_border, e_container, e_popup
9 years ago
* @param c compositor to display on
* @param color color to initialize to (or NULL for black).
* @param alpha_enabled if set, uses alpha and let user edit it.
E_Color_Dialog *
e_color_dialog_new(const E_Color *color, Eina_Bool alpha_enabled)
E_Color_Dialog *dia;
Evas_Object *o, *bx, *re, *fr;
dia = E_OBJECT_ALLOC(E_Color_Dialog, E_COLOR_DIALOG_TYPE, _e_color_dialog_free);
if (!dia) return NULL;
dia->dia = e_dialog_new(NULL, "E", "_color_dialog");
e_dialog_title_set(dia->dia, _("Color Selector"));
dia->color = calloc(1, sizeof(E_Color));
dia->initial = calloc(1, sizeof(E_Color));
if (color)
e_color_copy(color, dia->color);
if ((!color) || (!alpha_enabled))
dia->color->a = 255;
e_color_copy(dia->color, dia->initial);
bx = elm_box_add(dia->dia->win);
o = elm_colorselector_add(bx);
elm_colorselector_mode_set(o, ELM_COLORSELECTOR_COMPONENTS);
elm_colorselector_color_set(o, dia->color->r, dia->color->g, dia->color->b, dia->color->a);
elm_box_pack_end(bx, o);
fr = elm_frame_add(bx);
elm_object_text_set(fr, _("Color Preview"));
elm_box_pack_end(bx, fr);
re = evas_object_rectangle_add(evas_object_evas_get(dia->dia->win));
evas_object_data_set(o, "rect", re);
evas_object_size_hint_min_set(re, 1, ELM_SCALE_SIZE(100));
elm_object_content_set(fr, re);
evas_object_smart_callback_add(o, "changed", _e_color_dialog_cb_csel_change, dia);
e_dialog_content_set(dia->dia, bx, 250, -1);
/* buttons at the bottom */
e_dialog_button_add(dia->dia, _("Select"), NULL, _e_color_dialog_button1_click, dia);
e_dialog_button_add(dia->dia, _("Cancel"), NULL, _e_color_dialog_button2_click, dia);
elm_win_center(dia->dia->win, 1, 1);
dia->dia->data = dia;
e_object_del_attach_func_set(E_OBJECT(dia->dia), _e_color_dialog_dia_del);
return dia;
e_color_dialog_show(E_Color_Dialog *dia)
e_dialog_border_icon_set(dia->dia, "enlightenment/colors");
evas_object_size_hint_min_set(dia->dia->win, 250, -1);
e_color_dialog_title_set(E_Color_Dialog *dia, const char *title)
e_dialog_title_set(dia->dia, title);
e_color_dialog_select_callback_set(E_Color_Dialog *dia, void (*func)(E_Color_Dialog *dia, E_Color *color, void *data), void *data)
dia->select_func = func;
dia->select_data = data;
e_color_dialog_cancel_callback_set(E_Color_Dialog *dia, void (*func)(E_Color_Dialog *dia, E_Color *color, void *data), void *data)
dia->cancel_func = func;
dia->cancel_data = data;
E_API void
e_color_dialog_change_callback_set(E_Color_Dialog *dia, void (*func)(E_Color_Dialog *dia, E_Color *color, void *data), void *data)
dia->change_func = func;
dia->change_data = data;
static void
_e_color_dialog_cb_csel_change(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
E_Color_Dialog *dia = data;
Evas_Object *re;
int r, g, b;
elm_colorselector_color_get(obj, &dia->color->r, &dia->color->g, &dia->color->b, &dia->color->a);
r = dia->color->r;
g = dia->color->g;
b = dia->color->b;
re = evas_object_data_get(obj, "rect");
evas_color_argb_premul(dia->color->a, &r, &g, &b);
evas_object_color_set(re, r, g, b, dia->color->a);
if (dia->change_func)
dia->change_func(dia, dia->color, dia->change_data);
static void
_e_color_dialog_button1_click(void *data, E_Dialog *edia EINA_UNUSED)
E_Color_Dialog *dia;
dia = data;
if (dia->select_func)
dia->select_func(dia, dia->color, dia->select_data);
static void
_e_color_dialog_button2_click(void *data, E_Dialog *edia EINA_UNUSED)
E_Color_Dialog *dia;
dia = data;
if (dia->cancel_func)
dia->cancel_func(dia, dia->initial, dia->cancel_data);
static void
_e_color_dialog_free(E_Color_Dialog *dia)
if (dia->dia)
e_object_del_attach_func_set(E_OBJECT(dia->dia), NULL);
dia->dia = NULL;
static void
_e_color_dialog_dia_del(void *obj)
E_Dialog *dia = obj;
E_Color_Dialog *cdia = dia->data;
if (cdia->cancel_func && cdia->initial)
cdia->cancel_func(cdia, cdia->initial, cdia->cancel_data);
cdia->dia = NULL;