From 00e1bb3b235d96c8c2fbad1b69098f8b76ed0c92 Mon Sep 17 00:00:00 2001 From: davemds Date: Sat, 8 Feb 2014 20:09:42 +0100 Subject: [PATCH] New textblock tags for elm entry widget. This commit add the following new tags: title, subtitle, bigger, big, small, smaller, code, comment, string, number, brace, type, class, function, param, keyword, preprocessor, line_added, line_removed, line_changed. Tags has been unified in 3 new utility macros: COMMON_TEXTBLOCK_TAGS, ENABLED_TEXTBLOCK_TAGS, and DISABLED_TEXTBLOCK_TAGS to avoid repeating too much in the theme. Also a new test is in: "Entry Style Default" that show all the new styles. Docs will follow soon. --- .../elementary/data/themes/edc/elm/entry.edc | 72 ++++------ legacy/elementary/data/themes/fonts.edc | 48 +++++++ legacy/elementary/src/bin/test.c | 4 +- legacy/elementary/src/bin/test_entry.c | 128 ++++++++++++++++++ 4 files changed, 203 insertions(+), 49 deletions(-) diff --git a/legacy/elementary/data/themes/edc/elm/entry.edc b/legacy/elementary/data/themes/edc/elm/entry.edc index fccab82cfe..09c527bfab 100644 --- a/legacy/elementary/data/themes/edc/elm/entry.edc +++ b/legacy/elementary/data/themes/edc/elm/entry.edc @@ -436,24 +436,18 @@ group { name: "elm/entry/base/default"; styles { style { name: "entry_style"; base: "font="FN" font_size=10 color=#ffffff style=shadow,bottom shadow_color=#00000080 wrap=word text_class=entry color_class=entry left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff"; - tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; + COMMON_TEXTBLOCK_TAGS + ENABLED_TEXTBLOCK_TAGS } style { name: "entry_disabled_style"; base: "font="FN" font_size=10 color=#151515 style=shadow,bottom shadow_color=#ffffff19 wrap=word text_class=entry color_class=entry_disabled left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff88 underline=on underline_color=#3399ff88"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff88"; - tag: "preedit_sel" "+ backing=on backing_color=#000 color=#888888"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } style { name: "entry_guide_style"; base: "font="FN" font_size=10 color=#000000 style=shadow,bottom shadow_color=#ffffff19 wrap=word text_class=entry color_class=entry_guide left_margin=2 right_margin=2 ellipsis=0.0"; - tag: "em" "+ font_style=Oblique"; - tag: "hilight" "+ font_weight=Bold"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } } // data.item: "context_menu_orientation" "horizontal"; @@ -561,24 +555,18 @@ group { name: "elm/entry/base-mixedwrap/default"; styles { style { name: "entry_style_mixedwrap"; base: "font="FN" font_size=10 color=#ffffff style=shadow,bottom shadow_color=#00000080 wrap=mixed text_class=entry color_class=entry left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff"; - tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; + COMMON_TEXTBLOCK_TAGS + ENABLED_TEXTBLOCK_TAGS } style { name: "entry_disabled_style_mixedwrap"; base: "font="FN" font_size=10 color=#151515 style=shadow,bottom shadow_color=#ffffff19 wrap=mixed text_class=entry color_class=entry_disabled left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff88 underline=on underline_color=#3399ff88"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff88"; - tag: "preedit_sel" "+ backing=on backing_color=#000 color=#888888"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } style { name: "entry_guide_style_mixedwrap"; base: "font="FN" font_size=10 color=#000000 style=shadow,bottom shadow_color=#ffffff19 wrap=mixed text_class=entry color_class=entry_guide left_margin=2 right_margin=2 ellipsis=0.0"; - tag: "em" "+ font_style=Oblique"; - tag: "hilight" "+ font_weight=Bold"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } } parts { @@ -620,24 +608,18 @@ group { name: "elm/entry/base-charwrap/default"; styles { style { name: "entry_style_charwrap"; base: "font="FN" font_size=10 color=#ffffff style=shadow,bottom shadow_color=#00000080 wrap=char text_class=entry color_class=entry left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff"; - tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; + COMMON_TEXTBLOCK_TAGS + ENABLED_TEXTBLOCK_TAGS } style { name: "entry_disabled_style_charwrap"; base: "font="FN" font_size=10 color=#151515 style=shadow,bottom shadow_color=#ffffff19 wrap=char text_class=entry color_class=entry_disabled left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff88 underline=on underline_color=#3399ff88"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff88"; - tag: "preedit_sel" "+ backing=on backing_color=#000 color=#888888"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } style { name: "entry_guide_style_charwrap"; base: "font="FN" font_size=10 color=#000000 style=shadow,bottom shadow_color=#ffffff19 wrap=char text_class=entry color_class=entry_guide left_margin=2 right_margin=2 ellipsis=0.0"; - tag: "em" "+ font_style=Oblique"; - tag: "hilight" "+ font_weight=Bold"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } } parts { @@ -714,24 +696,18 @@ group { name: "elm/entry/base-single/default"; styles { style { name: "entry_single_style"; base: "font="FN" font_size=10 color=#ffffff style=shadow,bottom shadow_color=#00000080 wrap=none text_class=entry color_class=entry left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff"; - tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; + COMMON_TEXTBLOCK_TAGS + ENABLED_TEXTBLOCK_TAGS } style { name: "entry_single_disabled_style"; base: "font="FN" font_size=10 color=#151515 style=shadow,bottom shadow_color=#ffffff19 wrap=none text_class=entry color_class=entry_disabled left_margin=2 right_margin=2"; - tag: "em" "+ font_style=Oblique"; - tag: "link" "+ color=#3399ff88 underline=on underline_color=#3399ff88"; - tag: "hilight" "+ font_weight=Bold"; - tag: "preedit" "+ underline=on underline_color=#3399ff88"; - tag: "preedit_sel" "+ backing=on backing_color=#000 color=#888888"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } style { name: "entry_single_guide_style"; base: "font="FN" font_size=10 color=#000000 style=shadow,bottom shadow_color=#ffffff19 wrap=none text_class=entry color_class=entry_guide left_margin=2 right_margin=2 ellipsis=0.0"; - tag: "em" "+ font_style=Oblique"; - tag: "hilight" "+ font_weight=Bold"; + COMMON_TEXTBLOCK_TAGS + DISABLED_TEXTBLOCK_TAGS } } parts { diff --git a/legacy/elementary/data/themes/fonts.edc b/legacy/elementary/data/themes/fonts.edc index a926e76b57..fb8fae4d62 100644 --- a/legacy/elementary/data/themes/fonts.edc +++ b/legacy/elementary/data/themes/fonts.edc @@ -18,3 +18,51 @@ #define FN_COL_DEFAULT 255 255 255 255; color3: 0 0 0 128 #define FN_COL_HIGHLIGHT 51 153 255 255; color2: 51 153 255 24; color3: 51 153 255 18 #define FN_COL_DISABLE 21 21 21 255; color3: 255 255 255 25; + + +#define COMMON_TEXTBLOCK_TAGS \ + tag: "em" "+ font_style=Oblique"; \ + tag: "title" "+ font_size=26"; \ + tag: "subtitle" "+ font_size=18"; \ + tag: "bigger" "+ font_size=12"; \ + tag: "big" "+ font_size=11"; \ + tag: "small" "+ font_size=8"; \ + tag: "smaller" "+ font_size=7"; \ + tag: "code" "+ font=Mono style=plain color=#ffffff"; \ + tag: "comment" "+ color=#00B000"; \ + tag: "string" "+ color=#ff3a35"; \ + tag: "number" "+ color=#D4D42A font_weight=Bold"; \ + tag: "brace" "+ color=#656565"; \ + tag: "type" "+ color=#3399ff"; \ + tag: "class" "+ color=#72AAD4 font_weight=Bold"; \ + tag: "function" "+ color=#72AAD4 font_weight=Bold"; \ + tag: "param" "+ color=#ffffff"; \ + tag: "keyword" "+ color=#f90 font_weight=Bold"; \ + tag: "preprocessor" "+ color=#3399ff font_weight=Bold"; \ + tag: "line_added" "+ color=#00B000"; \ + tag: "line_removed" "+ color=#ff3a35"; \ + tag: "line_changed" "+ color=#f90"; + +#define ENABLED_TEXTBLOCK_TAGS \ + tag: "hilight" "+ font_weight=Bold style=glow glow_color=#3399ff80"; \ + tag: "link" "+ color=#3399ff underline=on underline_color=#3399ff"; \ + tag: "preedit" "+ underline=on underline_color=#3399ff"; \ + tag: "preedit_sel" "+ backing=on backing_color=#000000 color=#ffffff"; \ + tag: "name" "+ color=#888888"; \ + tag: "val" "+ color=#ffffff"; \ + tag: "info" "+ color=#3399ff style=glow glow_color=#3399ff40"; \ + tag: "success" "+ color=#00cc00 style=glow glow_color=#00cc0040"; \ + tag: "warning" "+ color=#ff7c00 style=glow glow_color=#ff7c0040"; \ + tag: "failure" "+ color=#ff0000 style=glow glow_color=#ff000040"; + +#define DISABLED_TEXTBLOCK_TAGS \ + tag: "hilight" "+ font_weight=Bold style=glow glow_color=#3399ff20"; \ + tag: "link" "+ color=#3399ff88 underline=on underline_color=#3399ff88"; \ + tag: "preedit" "+ underline=on underline_color=#3399ff88"; \ + tag: "preedit_sel" "+ backing=on backing_color=#000 color=#888888"; \ + tag: "name" "+ color=#666666"; \ + tag: "val" "+ color=#151515"; \ + tag: "info" "+ color=#174878 style=glow glow_color=#17487820"; \ + tag: "success" "+ color=#006600 style=glow glow_color=#00440020"; \ + tag: "warning" "+ color=#703700 style=glow glow_color=#70370020"; \ + tag: "failure" "+ color=#660000 style=glow glow_color=#66000020"; diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c index f3cdfeec4e..75e8061250 100644 --- a/legacy/elementary/src/bin/test.c +++ b/legacy/elementary/src/bin/test.c @@ -50,6 +50,7 @@ void test_hover2(void *data, Evas_Object *obj, void *event_info); void test_hover3(void *data, Evas_Object *obj, void *event_info); void test_entry(void *data, Evas_Object *obj, void *event_info); void test_entry_style_user(void *data, Evas_Object *obj, void *event_info); +void test_entry_style_default(void *data, Evas_Object *obj, void *event_info); void test_entry_scrolled(void *data, Evas_Object *obj, void *event_info); void test_entry3(void *data, Evas_Object *obj, void *event_info); void test_entry4(void *data, Evas_Object *obj, void *event_info); @@ -549,7 +550,8 @@ add_tests: //------------------------------// ADD_TEST(NULL, "Entries", "Entry", test_entry); - ADD_TEST(NULL, "Entries", "Entry Style", test_entry_style_user); + ADD_TEST(NULL, "Entries", "Entry Style Default", test_entry_style_default); + ADD_TEST(NULL, "Entries", "Entry Style User", test_entry_style_user); ADD_TEST(NULL, "Entries", "Entry Scrolled", test_entry_scrolled); ADD_TEST(NULL, "Entries", "Entry 3", test_entry3); ADD_TEST(NULL, "Entries", "Entry 4", test_entry4); diff --git a/legacy/elementary/src/bin/test_entry.c b/legacy/elementary/src/bin/test_entry.c index 9371692277..7aa04f06db 100644 --- a/legacy/elementary/src/bin/test_entry.c +++ b/legacy/elementary/src/bin/test_entry.c @@ -854,6 +854,134 @@ test_entry_style_user(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void evas_object_show(win); } + +static char *default_style_text = + "Elementary typography
" + "" + "Basic tags
" + "Elm by default provide the bold, the italic, the " + "hilight and the link tags.
" + "" + "Font sizes
" + "You can also use the big or bigger and " + "the small or smaller tags.
" + "" + "Status indicators
" + "info, success, warning and failure
" + "" + "Forms attributes
" + "Song: The show must go on
" + "Artist: Queen
" + "Album: Innuendo
" + "" + "Syntax highlight
" + "" + "#include <stdlib.h>
" + "#include <Evas.h>
" + "
" + "#define MESSAGE \"Hello World\"
" + "
" + "/* Prints a message to standard output */
" + "void print_message(const char *msg) {
" + " printf(\"%s\\n\", msg);
" + "}
" + "
" + "int main(int argc, char *argv[]) {
" + " int num_int = 123;
" + " float num_float = 0.999;
" + " char *str = \"This is a string\";
" + " Evas_Object *obj = NULL;
" + " print_message(MESSAGE);
" + " return 0;
" + "}
" + "" + "+diff line added
" + "-diff line removed
" + " diff line changed
" + "
"; + +static void +ent_bt_def_style_disabled(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *en = data; + elm_object_disabled_set(en, elm_check_state_get(obj)); +} + +static void +ent_bt_def_style_scrollable(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *en = data; + elm_entry_scrollable_set(en, elm_check_state_get(obj)); +} + +static void +ent_bt_def_style_markup(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + Evas_Object *en = data; + + if (elm_check_state_get(obj)) + { + char *markup = elm_entry_utf8_to_markup(default_style_text); + elm_object_text_set(en, markup); + free(markup); + } + else + elm_object_text_set(en, default_style_text); +} + +void +test_entry_style_default(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Evas_Object *win, *bx, *vbx, *en, *o; + + win = elm_win_util_standard_add("entry-style", "Entry Default Style"); + elm_win_autodel_set(win, EINA_TRUE); + evas_object_resize(win, 400, 400); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + en = elm_entry_add(win); + evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(en, default_style_text); + elm_entry_editable_set(en, EINA_TRUE); + elm_box_pack_end(bx, en); + evas_object_show(en); + + o = elm_separator_add(win); + elm_separator_horizontal_set(o, EINA_TRUE); + elm_box_pack_end(bx, o); + evas_object_show(o); + + vbx = elm_box_add(win); + elm_box_horizontal_set(vbx, EINA_TRUE); + elm_box_pack_end(bx, vbx); + evas_object_show(vbx); + + o = elm_check_add(win); + elm_object_text_set(o, "show markup"); + evas_object_smart_callback_add(o, "changed", ent_bt_def_style_markup, en); + elm_box_pack_end(vbx, o); + evas_object_show(o); + + o = elm_check_add(win); + elm_object_text_set(o, "disabled"); + evas_object_smart_callback_add(o, "changed", ent_bt_def_style_disabled, en); + elm_box_pack_end(vbx, o); + evas_object_show(o); + + o = elm_check_add(win); + elm_object_text_set(o, "scrollable"); + evas_object_smart_callback_add(o, "changed", ent_bt_def_style_scrollable, en); + elm_box_pack_end(vbx, o); + evas_object_show(o); + + evas_object_show(win); +} + static void _entry_activated_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)