diff --git a/experimental/ecdb/trunk/data/themes/default/groups/window.edc b/experimental/ecdb/trunk/data/themes/default/groups/window.edc index 65890901..b293cdb9 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/window.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/window.edc @@ -4,12 +4,14 @@ group { min: 640 390; script { - public settings_time_id = 0; - const Float:show_timeout = 1.0; + public settings_time_id; + public in_transition; + const Float:show_timeout = 1.5; public show_settings(val) { + set_int(in_transition, 1); run_program(PROGRAM:"settings,show"); - run_program(PROGRAM:"about_icon,show"); + run_program(PROGRAM:"icons,show"); if (get_int(settings_time_id) != 0) { cancel_timer(get_int(settings_time_id)); } @@ -374,8 +376,8 @@ group { description { state: "visible" 0.0; inherit: "default" 0.0; - min: 72 72; - max: 72 72; + min: 140 72; + max: 140 72; color: 0 0 0 128; } } @@ -392,6 +394,47 @@ group { min: 0 0; max: 0 0; color: 255 255 255 0; + align: 0.0 0.0; + + rel1 { + to: "config_icon"; + relative: 1.0 0.0; + offset: 4 4; + } + + rel2 { + to: "config_icon"; + relative: 1.0 1.0; + offset: -5 -5; + } + + image { + normal: "icon_about.png"; + } + } + + description { + state: "visible" 0.0; + inherit: "default" 0.0; + min: 64 64; + max: 64 64; + color: 255 255 255 255; + } + } + + part { + name: "config_icon"; + type: IMAGE; + mouse_events: 1; + repeat_events: 1; + scale: 1; + + description { + state: "default" 0.0; + min: 0 0; + max: 0 0; + color: 255 255 255 0; + align: 0.0 0.0; rel1 { to: "settings_tab"; @@ -418,6 +461,7 @@ group { color: 255 255 255 255; } } + } programs { @@ -433,8 +477,6 @@ group { program { name: "settings,deactivate"; - signal: "mouse,out"; - source: "settings_tab"; action: STATE_SET "default" 0.0; target: "settings_tab"; transition: DECELERATE 0.3; @@ -445,40 +487,61 @@ group { signal: "mouse,out"; source: "settings_tab"; script { - run_program(PROGRAM:"about_icon,hide"); - if (get_int(settings_time_id) != 0) { - cancel_timer(get_int(settings_time_id)); - set_int(settings_time_id, 0); + if (!get_int(in_transition)) + { + run_program(PROGRAM:"settings,deactivate") + run_program(PROGRAM:"icons,hide"); + if (get_int(settings_time_id) != 0) { + cancel_timer(get_int(settings_time_id)); + set_int(settings_time_id, 0); + } } } } program { - name: "about_icon,hide"; + name: "icons,hide"; action: STATE_SET "default" 0.0; target: "about_icon"; + target: "config_icon"; transition: DECELERATE 0.3; } program { - name: "about_icon,show"; + name: "icons,show"; action: STATE_SET "visible" 0.0; target: "about_icon"; + target: "config_icon"; transition: DECELERATE 0.3; } program { - name: "icon,clicked"; + name: "about_icon,clicked"; signal: "mouse,clicked,1"; source: "about_icon"; action: SIGNAL_EMIT "ecdb/about/show" "ecdb"; } + program { + name: "config_icon,clicked"; + signal: "mouse,clicked,1"; + source: "config_icon"; + action: SIGNAL_EMIT "ecdb/config/show" "ecdb"; + } + program { name: "settings,show"; action: STATE_SET "visible" 0.0; target: "settings_tab"; transition: DECELERATE 0.3; + after: "settings,after"; + } + + program { + name: "settings,after"; + script { + set_int(in_transition, 0); + } } program { diff --git a/experimental/ecdb/trunk/data/themes/default/images/icon_about.png b/experimental/ecdb/trunk/data/themes/default/images/icon_about.png new file mode 100644 index 00000000..d9a0dfd5 Binary files /dev/null and b/experimental/ecdb/trunk/data/themes/default/images/icon_about.png differ diff --git a/experimental/ecdb/trunk/data/themes/default/images/images.edc b/experimental/ecdb/trunk/data/themes/default/images/images.edc index a2ca3d24..72d398eb 100644 --- a/experimental/ecdb/trunk/data/themes/default/images/images.edc +++ b/experimental/ecdb/trunk/data/themes/default/images/images.edc @@ -31,4 +31,5 @@ images { image: "progress_trough.png" COMP; image: "logo.png" COMP; image: "icon_config.png" COMP; + image: "icon_about.png" COMP; } diff --git a/experimental/ecdb/trunk/src/ecdb.c b/experimental/ecdb/trunk/src/ecdb.c index 8a405dd3..182e0a27 100644 --- a/experimental/ecdb/trunk/src/ecdb.c +++ b/experimental/ecdb/trunk/src/ecdb.c @@ -226,6 +226,12 @@ ecdb_initialize_config(void) ecore_config_long_opt_set("scale", "The scaling factor."); ecore_config_short_opt_set("scale", 's'); + // Use scale? + ecore_config_boolean_default("use_scale", 0); + ecore_config_describe("use_scale", "Use scaling?"); + ecore_config_long_opt_set("use_scale", "Use scaling?"); + ecore_config_short_opt_set("use_scale", 'u'); + // Engine ecore_config_string_default("engine", "software_x11"); ecore_config_describe("engine", "The canvas engine."); @@ -245,6 +251,7 @@ ecdb_initialize_config(void) { printf("Invalid file specified, attempting to fall back to default!\n"); gui = ecore_config_theme_with_path_from_name_get("default"); + ecore_config_theme_set("theme", "default"); if (!gui) { diff --git a/experimental/ecdb/trunk/src/ecdb_config_dialog.c b/experimental/ecdb/trunk/src/ecdb_config_dialog.c index 5dfcedcb..beeaf97b 100644 --- a/experimental/ecdb/trunk/src/ecdb_config_dialog.c +++ b/experimental/ecdb/trunk/src/ecdb_config_dialog.c @@ -1,12 +1,7 @@ /* vim: set sw=3 ts=3 sts=3 expandtab: */ #include "ecdb.h" - -typedef struct Config_Data Config_Data; -struct Config_Data -{ - char ** array; - unsigned int count; -}; +#include +#include static void destroy_cb(Ewl_Widget *w, void *event, void *data); static void conf_clicked_cb(Ewl_Widget *w, void *event, void *data); @@ -14,12 +9,15 @@ static void scale_cb(Ewl_Widget *w, void *event, void *data); static void fps_cb(Ewl_Widget *w, void *event, void *data); static void engine_cb(Ewl_Widget *w, void *event, void *data); static void theme_cb(Ewl_Widget *w, void *event, void *data); -static Config_Data *theme_data_init(void); -static Config_Data *engine_data_init(void); -static int theme_data_return_active(Config_Data *data); -static int engine_data_return_active(Config_Data *data); +static void combo_cb(Ewl_Widget *w, void *event, void *data); +static void use_scale_cb(Ewl_Widget *w, void *event, void *data); +static Eina_List *theme_data_init(void); +static Eina_List *engine_data_init(void); +static int theme_data_return_active(Eina_List *data); +static int engine_data_return_active(Eina_List *data); static unsigned int model_data_count(void *data); static void *model_data_fetch(void *data, unsigned int row, unsigned int col); +static char *theme_cut_suffix(const char *file); static Ewl_Widget *conf_win = NULL; @@ -31,7 +29,8 @@ ecdb_config_dialog_show(void) Ewl_Widget *combo; Ewl_Model *model; Ewl_View *view; - Config_Data *data; + Eina_List *data; + int use_scale; /* Only show one config window */ if (conf_win) @@ -53,7 +52,7 @@ ecdb_config_dialog_show(void) ewl_dialog_active_area_set(EWL_DIALOG(conf_win), EWL_POSITION_TOP); main_box = ewl_vbox_new(); ewl_container_child_append(EWL_CONTAINER(conf_win), main_box); - ewl_object_fill_policy_set(EWL_OBJECT(main_box), EWL_FLAG_ALIGN_CENTER); + ewl_object_fill_policy_set(EWL_OBJECT(main_box), EWL_FLAG_FILL_HSHRINKABLE); ewl_widget_show(main_box); /* Setup and show the stock icons */ @@ -102,20 +101,35 @@ ecdb_config_dialog_show(void) ewl_object_fill_policy_set(EWL_OBJECT(l), EWL_FLAG_FILL_NONE); ewl_widget_show(l); + use_scale = ecore_config_boolean_get("use_scale"); + o = ewl_hseeker_new(); ewl_range_minimum_value_set(EWL_RANGE(o), 0.0); ewl_range_maximum_value_set(EWL_RANGE(o), 2.0); - ewl_range_step_set(EWL_RANGE(o), 0.1); + ewl_range_step_set(EWL_RANGE(o), 0.25); ewl_range_value_set(EWL_RANGE(o), em->scalef); ewl_container_child_append(EWL_CONTAINER(border_box), o); ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, scale_cb, l); - scale_cb(o, NULL, NULL); + if (!use_scale) + ewl_widget_disable(o); + scale_cb(o, NULL, l); ewl_widget_show(o); + // Store this widget as we use it as a parameter later + l = o; + + o = ewl_checkbutton_new(); + ewl_button_label_set(EWL_BUTTON(o), "Use scaling?"); + ewl_container_child_append(EWL_CONTAINER(border_box), o); + ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_LEFT); + ewl_checkbutton_checked_set(EWL_CHECKBUTTON(o), use_scale); + ewl_widget_show(o); + ewl_callback_append(o, EWL_CALLBACK_CLICKED, use_scale_cb, l); + /* FPS */ hbox = ewl_grid_new(); ewl_container_child_append(EWL_CONTAINER(border_box), hbox); - ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_FILL); + ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_ALL); ewl_grid_column_preferred_w_use(EWL_GRID(hbox), 1); ewl_widget_show(hbox); @@ -134,18 +148,18 @@ ecdb_config_dialog_show(void) o = ewl_hseeker_new(); ewl_range_minimum_value_set(EWL_RANGE(o), 10.0); ewl_range_maximum_value_set(EWL_RANGE(o), 100.0); - ewl_range_step_set(EWL_RANGE(o), 5.0); + ewl_range_step_set(EWL_RANGE(o), 15.0); ewl_range_value_set(EWL_RANGE(o), em->fps); ewl_container_child_append(EWL_CONTAINER(border_box), o); ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, fps_cb, l); - fps_cb(o, NULL, NULL); + fps_cb(o, NULL, l); ewl_widget_show(o); /* Setup and show the border box */ border_box = ewl_border_new(); ewl_border_label_set(EWL_BORDER(border_box), "Rendering Engine"); ewl_container_child_append(EWL_CONTAINER(main_box), border_box); - ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_FILL); + ewl_object_fill_policy_set(EWL_OBJECT(border_box), EWL_FLAG_FILL_NORMAL); ewl_object_alignment_set(EWL_OBJECT(border_box), EWL_FLAG_ALIGN_CENTER); ewl_object_alignment_set(EWL_OBJECT(main_box), EWL_FLAG_ALIGN_TOP); ewl_widget_show(border_box); @@ -161,6 +175,7 @@ ecdb_config_dialog_show(void) combo = ewl_combo_new(); ewl_container_child_append(EWL_CONTAINER(border_box), combo); ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, engine_cb, NULL); + ewl_callback_append(combo, EWL_CALLBACK_DESTROY, combo_cb, data); ewl_mvc_model_set(EWL_MVC(combo), model); ewl_mvc_view_set(EWL_MVC(combo), view); ewl_mvc_data_set(EWL_MVC(combo), data); @@ -182,6 +197,7 @@ ecdb_config_dialog_show(void) combo = ewl_combo_new(); ewl_container_child_append(EWL_CONTAINER(border_box), combo); ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, theme_cb, NULL); + ewl_callback_append(combo, EWL_CALLBACK_DESTROY, combo_cb, data); ewl_mvc_model_set(EWL_MVC(combo), model); ewl_mvc_view_set(EWL_MVC(combo), view); ewl_mvc_data_set(EWL_MVC(combo), data); @@ -225,95 +241,228 @@ scale_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) value = ewl_range_value_get(EWL_RANGE(w)); ecore_config_float_set("scale", value); - snprintf(buffer, 10, "%f", value); + snprintf(buffer, 10, "%.1f", value); ewl_label_text_set(EWL_LABEL(data), buffer); } static void fps_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) { - double value; + int value; char buffer[10]; value = ewl_range_value_get(EWL_RANGE(w)); ecore_config_int_set("frame_rate", value); - snprintf(buffer, 10, "%f", value); + snprintf(buffer, 10, "%d", value); ewl_label_text_set(EWL_LABEL(data), buffer); } static void engine_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) { - Config_Data *d; + Eina_List *l; Ewl_Selection_Idx *idx; + char *eng; - d = ewl_mvc_data_get(EWL_MVC(w)); + l = ewl_mvc_data_get(EWL_MVC(w)); idx = ewl_mvc_selected_get(EWL_MVC(w)); + if (!idx) + return; free(em->engine); - ecore_config_string_set("engine", d->array[idx->row]); - em->engine = strdup(d->array[idx->row]); + eng = eina_list_nth(l, idx->row); + ecore_config_string_set("engine", eng); + em->engine = strdup(eng); free(idx); } static void theme_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) { - Config_Data *d; + Eina_List *l; Ewl_Selection_Idx *idx; + char *theme; - d = ewl_mvc_data_get(EWL_MVC(w)); + l = ewl_mvc_data_get(EWL_MVC(w)); idx = ewl_mvc_selected_get(EWL_MVC(w)); + if (!idx) + return; free(em->theme_path); - ecore_config_theme_set("theme", d->array[idx->row]); - em->theme_path = ecore_config_theme_with_path_get("theme"); + theme = eina_list_nth(l, idx->row); + ecore_config_theme_set("theme", theme); + em->theme_path = strdup(theme); free(idx); } -static Config_Data * +static Eina_List * theme_data_init(void) { - Config_Data *ret; + Eina_List *ret = NULL; + char *dirs; + char **dirs_array; + struct dirent *file; + DIR *rep; + int i = 0; - ret = malloc(sizeof(Config_Data)); + dirs = ecore_config_theme_search_path_get(); + dirs_array = ecore_str_split(dirs, "|", -1); + free(dirs); + + if (!dirs_array) + { + printf("No possible theme paths!\n"); + return NULL; + } + + while ((dirs = dirs_array[i])) + { + rep = opendir(dirs); + if (rep) + { + while ((file = readdir(rep))) + { + if ((strlen(file->d_name) > 4) && + (ecore_str_has_suffix(file->d_name, ".edj"))) + ret = eina_list_append(ret, theme_cut_suffix(file->d_name)); + } + closedir(rep); + } + i++; + } + + free(*dirs_array); + free(dirs_array); + + if (!ret) + { + printf("No themes available!\n"); + return NULL; + } return ret; } static int -theme_data_return_active(Config_Data *data) +theme_data_return_active(Eina_List *l) { - return 0; + int i; + char *theme, *tmp_theme; + + theme = ecore_config_theme_get("theme"); + + EINA_LIST_FOREACH(l, l, tmp_theme) + { + if (!strcmp(tmp_theme, theme)) + break; + i++; + } + + free(theme); + return i; } -static Config_Data * +static Eina_List * engine_data_init(void) { - Config_Data *ret; + Eina_List *l, *ret = NULL; + char *eng; + int i; + const char *accepted_engines[] = {"software_x11", "xrender_x11", + "opengl_x11", NULL}; - ret = malloc(sizeof(Config_Data)); + l = ecore_evas_engines_get(); + + EINA_LIST_FOREACH(l, l, eng) + { + for (i = 0; accepted_engines[i]; i++) + { + if (!strcmp(accepted_engines[i], eng)) + { + ret = eina_list_append(ret, strdup(eng)); + break; + } + } + } + + ecore_evas_engines_free(l); return ret; } static int -engine_data_return_active(Config_Data *data) +engine_data_return_active(Eina_List *l) { - return 0; + int i = 0; + char *eng, *tmp_eng; + + eng = ecore_config_string_get("engine"); + + EINA_LIST_FOREACH(l, l, tmp_eng) + { + if (!strcmp(tmp_eng, eng)) + break; + i++; + } + + free(eng); + return i; } static unsigned int model_data_count(void *data) { - Config_Data *cd = data; - return cd->count; + Eina_List *l = data; + return eina_list_count(l); } static void * model_data_fetch(void *data, unsigned int row, unsigned int col __UNUSED__) { - Config_Data *cd = data; - return cd->array[row]; + Eina_List *l = data; + return eina_list_nth(l, row); +} + +static char * +theme_cut_suffix(const char *file) +{ + char *new_file, *pt, *end; + + end = strrchr(file, '.'); + + new_file = malloc(end - file + 1); + pt = new_file; + + while (file != end) + *pt++ = *file++; + + *pt = '\0'; + + return new_file; +} + +static void +combo_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) +{ + char *str; + + EINA_LIST_FREE(data, str) + free(str); + + eina_list_free(data); +} + +static void +use_scale_cb(Ewl_Widget *w, void *event __UNUSED__, void *data) +{ + int use_scale; + + use_scale = ewl_checkbutton_is_checked(EWL_CHECKBUTTON(w)); + ecore_config_boolean_set("use_scale", use_scale); + + if (use_scale) + ewl_widget_enable(EWL_WIDGET(data)); + else + ewl_widget_disable(EWL_WIDGET(data)); } diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index c832cce0..f76d2e62 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -13,6 +13,8 @@ static void _filelist_del(Ewl_Widget *w, void *ev_data, void *data); static void ecdb_welcome_page_show_about(void *data, Evas_Object *o, const char *emission, const char *source); +static void ecdb_welcome_page_show_config(void *data, Evas_Object *o, + const char *emission, const char *source); static void ecdb_welcome_page_show_about(void *data __UNUSED__, Evas_Object *o __UNUSED__, @@ -22,6 +24,14 @@ ecdb_welcome_page_show_about(void *data __UNUSED__, Evas_Object *o __UNUSED__, ecdb_about_show(); } +static void +ecdb_welcome_page_show_config(void *data __UNUSED__, Evas_Object *o __UNUSED__, + const char *emission __UNUSED__, + const char *source __UNUSED__) +{ + ecdb_config_dialog_show(); +} + static void _filelist_del(Ewl_Widget *w, void *ev_data __UNUSED__, void *data __UNUSED__) { @@ -223,14 +233,16 @@ ecdb_create_main_gui(void) edje_frametime_set(1.0 / (double)em->fps); ecore_evas_show(em->main_win_ee); - /* Make this configurable at some point */ - edje_scale_set(em->scalef); + if (ecore_config_boolean_get("use_scale")) + edje_scale_set(em->scalef); em->page = calloc(1, sizeof(Ecdb_Page)); em->page->gui = edje_object_add(ecore_evas_get(em->main_win_ee)); edje_object_file_set(em->page->gui, em->theme_path, "ecdb/window"); edje_object_signal_callback_add(em->page->gui, "ecdb/about/show", "ecdb", ecdb_welcome_page_show_about, NULL); + edje_object_signal_callback_add(em->page->gui, "ecdb/config/show", + "ecdb", ecdb_welcome_page_show_config, NULL); edje_object_size_min_get(em->page->gui, &mw, &mh); if (mw <= 0) mw = 400; if (mh <= 0) mh = 300;