Merge branch 'feature/edi_translucency' into develop

This commit is contained in:
Andy Williams 2017-12-08 22:42:21 +00:00
commit 5055a0985a
9 changed files with 133 additions and 14 deletions

View File

@ -42,7 +42,7 @@
((EDI_CONFIG_FILE_EPOCH << 16) | EDI_CONFIG_FILE_GENERATION)
# define EDI_PROJECT_CONFIG_FILE_EPOCH 0x0002
# define EDI_PROJECT_CONFIG_FILE_GENERATION 0x0004
# define EDI_PROJECT_CONFIG_FILE_GENERATION 0x0005
# define EDI_PROJECT_CONFIG_FILE_VERSION \
((EDI_PROJECT_CONFIG_FILE_EPOCH << 16) | EDI_PROJECT_CONFIG_FILE_GENERATION)
@ -273,6 +273,7 @@ _edi_config_init(void)
EDI_CONFIG_VAL(D, T, font.name, EET_T_STRING);
EDI_CONFIG_VAL(D, T, font.size, EET_T_INT);
EDI_CONFIG_VAL(D, T, gui.translucent, EET_T_UCHAR);
EDI_CONFIG_VAL(D, T, gui.alpha, EET_T_INT);
EDI_CONFIG_VAL(D, T, gui.theme, EET_T_STRING);
EDI_CONFIG_VAL(D, T, gui.width, EET_T_INT);
EDI_CONFIG_VAL(D, T, gui.height, EET_T_INT);
@ -506,7 +507,6 @@ _edi_project_config_load()
/* setup defaults */
IFPCFG(0x0001);
_edi_project_config->gui.translucent = EINA_TRUE;
_edi_project_config->gui.width = 640;
_edi_project_config->gui.height = 480;
_edi_project_config->gui.leftsize = 0.25;
@ -529,6 +529,17 @@ _edi_project_config_load()
_edi_project_config->gui.tab_inserts_spaces = EINA_TRUE;
IFPCFGEND;
IFPCFG(0x0004);
_edi_project_config->panels = NULL;
_panel_add();
_edi_project_config->windows = NULL;
IFPCFGEND;
IFPCFG(0x0005);
_edi_project_config->gui.translucent = EINA_FALSE;
_edi_project_config->gui.alpha = 255;
IFPCFGEND;
/* limit config values so they are sane */
EDI_CONFIG_LIMIT(_edi_project_config->font.size, EDI_FONT_MIN, EDI_FONT_MAX);
EDI_CONFIG_LIMIT(_edi_project_config->gui.width, 150, 10000);
@ -539,12 +550,6 @@ _edi_project_config_load()
_edi_project_config->version = EDI_PROJECT_CONFIG_FILE_VERSION;
IFPCFG(0x0004);
_edi_project_config->panels = NULL;
_panel_add();
_edi_project_config->windows = NULL;
IFPCFGEND;
if (save) _edi_project_config_save_no_notify();
}

View File

@ -79,6 +79,7 @@ struct _Edi_Project_Config
struct
{
Eina_Bool translucent;
int alpha;
const char *theme;
int width, height, bottomtab;
double leftsize, bottomsize;

View File

@ -8,10 +8,12 @@
#include <Ecore_Getopt.h>
#include <Elementary.h>
#include <Efl_Ui.h>
#include <Eio.h>
#include "Edi.h"
#include "edi_config.h"
#include "edi_theme.h"
#include "edi_filepanel.h"
#include "edi_file.h"
#include "edi_logpanel.h"
@ -1366,6 +1368,8 @@ static Eina_Bool
_edi_config_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
_edi_toolbar_set_visible(!_edi_project_config->gui.toolbar_hidden);
edi_theme_window_alpha_set();
return ECORE_CALLBACK_RENEW;
}
@ -1472,6 +1476,11 @@ _win_delete_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
edi_close();
}
Evas_Object *edi_main_win_get(void)
{
return _edi_main_win;
}
Eina_Bool
edi_open(const char *inputpath)
{
@ -1508,6 +1517,8 @@ edi_open(const char *inputpath)
elm_win_resize_object_add(win, hbx);
evas_object_show(hbx);
edi_theme_window_alpha_set();
tb = edi_toolbar_setup(hbx);
elm_box_pack_start(hbx, tb);
_edi_toolbar = tb;

View File

@ -48,6 +48,8 @@ extern int EDI_EVENT_FILE_SAVED;
Eina_Bool edi_open(const char *path);
Evas_Object *edi_main_win_get(void);
void edi_close();
void edi_open_url();

View File

@ -3,6 +3,7 @@
#endif
#include <Elementary.h>
#include <Efl_Ui.h>
#include "Edi.h"
#include "edi_theme.h"
@ -14,13 +15,37 @@ static Eina_List *_edi_themes = NULL;
// we are hooking into Efl for now...
Efl_Ui_Theme_Apply efl_ui_widget_theme_apply(Eo *obj);
void
edi_theme_window_alpha_set(void)
{
Evas_Object *win;
Eina_Bool enabled = _edi_project_config->gui.translucent;
win = edi_main_win_get();
elm_win_alpha_set(win, enabled);
if (enabled)
efl_gfx_color_set(efl_part(win, "background"), 64, 64, 64, _edi_project_config->gui.alpha);
else
efl_gfx_color_set(efl_part(win, "background"), 64, 64, 64, 255);
}
void edi_theme_elm_code_alpha_set(Evas_Object *obj)
{
if (_edi_project_config->gui.translucent)
elm_code_widget_alpha_set(obj, _edi_project_config->gui.alpha);
else
elm_code_widget_alpha_set(obj, 255);
}
void
edi_theme_elm_code_set(Evas_Object *obj, const char *name)
{
Eina_List *l;
Edi_Theme *theme;
if (!name)
if (!obj || !name)
return;
edi_theme_themes_get();

View File

@ -57,7 +57,8 @@ Eina_List *edi_theme_themes_get(void);
*/
Edi_Theme *edi_theme_theme_by_name(const char *name);
void edi_theme_window_alpha_set(void);
void edi_theme_elm_code_alpha_set(Evas_Object *obj);
/**
* @}
*/

View File

@ -1307,6 +1307,7 @@ _edi_editor_config_changed(void *data, int type EINA_UNUSED, void *event EINA_UN
code->config.trim_whitespace = _edi_config->trim_whitespace;
elm_obj_code_widget_font_set(widget, _edi_project_config->font.name, _edi_project_config->font.size);
edi_theme_elm_code_alpha_set(widget);
edi_theme_elm_code_set(widget, _edi_project_config->gui.theme);
elm_obj_code_widget_show_whitespace_set(widget, _edi_project_config->gui.show_whitespace);
elm_obj_code_widget_tab_inserts_spaces_set(widget, _edi_project_config->gui.tab_inserts_spaces);

View File

@ -297,6 +297,7 @@ _edi_mainview_split_config_changed_cb(void *data, int type EINA_UNUSED, void *ev
Elm_Code_Widget *widget = data;
elm_code_widget_font_set(widget, _edi_project_config->font.name, _edi_project_config->font.size);
edi_theme_elm_code_alpha_set(widget);
edi_theme_elm_code_set(widget, _edi_project_config->gui.theme);
return ECORE_CALLBACK_RENEW;

View File

@ -173,11 +173,43 @@ _edi_settings_display_theme_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED
return strdup(current->title);
}
static void
_edi_settings_display_translucent_state_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event EINA_UNUSED)
{
Evas_Object *slider, *check;
int state;
check = obj;
slider = data;
state = elm_check_state_get(check);
_edi_project_config->gui.translucent = state;
_edi_project_config_save();
elm_object_disabled_set(slider, !state);
}
static void
_edi_settings_display_alpha_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
_edi_project_config->gui.alpha = elm_slider_value_get(obj);
_edi_project_config_save();
}
static char *
_edi_settings_display_alpha_format(double value)
{
return (char*)eina_stringshare_printf("%1.0f%%", (value/255)*100);
}
static Evas_Object *
_edi_settings_display_create(Evas_Object *parent)
{
Evas_Object *box, *hbox, *frame, *label, *spinner, *check, *button, *preview;
Evas_Object *table, *combobox;
Evas_Object *table, *combobox, *slider;
Elm_Genlist_Item_Class *itc;
Edi_Theme *theme;
Eina_List *themes, *l;
@ -216,7 +248,7 @@ _edi_settings_display_create(Evas_Object *parent)
elm_table_pack(table, label, 0, 1, 1, 1);
evas_object_show(label);
// START OF COLOR SELECTOR
// START OF THEME SELECTOR
combobox = elm_combobox_add(table);
evas_object_size_hint_weight_set(combobox, 0.75, 0.0);
@ -246,17 +278,57 @@ _edi_settings_display_create(Evas_Object *parent)
elm_genlist_realized_items_update(combobox);
elm_genlist_item_class_free(itc);
// END OF COLOR SELECTOR
// END OF THEME SELECTOR
// START OF ALPHA SELECTOR
label = elm_label_add(table);
elm_object_text_set(label, _("Translucent"));
evas_object_size_hint_align_set(label, EVAS_HINT_EXPAND, 0.5);
elm_table_pack(table, label, 0, 2, 1, 1);
evas_object_show(label);
slider = elm_slider_add(table);
check = elm_check_add(box);
elm_check_state_set(check, _edi_project_config->gui.translucent);
evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(table, check, 1, 2, 1, 1);
evas_object_show(check);
evas_object_smart_callback_add(check, "changed",
_edi_settings_display_translucent_state_cb, slider);
label = elm_label_add(table);
elm_object_text_set(label, _("Alpha"));
evas_object_size_hint_align_set(label, EVAS_HINT_EXPAND, 0.5);
elm_table_pack(table, label, 0, 3, 1, 1);
evas_object_show(label);
elm_object_disabled_set(slider, !_edi_project_config->gui.translucent);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_slider_min_max_set(slider, 0, 255);
elm_slider_value_set(slider, _edi_project_config->gui.alpha);
elm_slider_span_size_set(slider, 255);
elm_slider_step_set(slider, 1);
elm_slider_units_format_function_set(slider, _edi_settings_display_alpha_format,
(void(*)(char*))eina_stringshare_del);
elm_slider_indicator_format_function_set(slider, _edi_settings_display_alpha_format,
(void(*)(char*))eina_stringshare_del);
elm_table_pack(table, slider, 1, 3, 1, 1);
evas_object_show(slider);
evas_object_smart_callback_add(slider, "slider,drag,stop", _edi_settings_display_alpha_changed_cb, NULL);
// END OF ALPHA SELECTOR
check = elm_check_add(box);
elm_object_text_set(check, _("Display whitespace"));
elm_check_state_set(check, _edi_project_config->gui.show_whitespace);
elm_box_pack_end(box, check);
evas_object_show(check);
evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(check, 0.0, 0.5);
evas_object_smart_callback_add(check, "changed",
_edi_settings_display_whitespace_cb, NULL);
evas_object_show(check);
hbox = elm_box_add(box);
elm_box_horizontal_set(hbox, EINA_TRUE);