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.
This commit is contained in:
Davide Andreoli 2014-02-08 20:09:42 +01:00
parent 402d04f55a
commit 00e1bb3b23
4 changed files with 203 additions and 49 deletions

View File

@ -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 {

View File

@ -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";

View File

@ -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);

View File

@ -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 =
"<title>Elementary typography</title><br>"
"<ps>"
"<subtitle>Basic tags</subtitle><br>"
"Elm by default provide the <b>bold</b>, the <i>italic</i>, the "
"<hilight>hilight</hilight> and the <link>link</link> tags.<br>"
"<ps>"
"<subtitle>Font sizes</subtitle><br>"
"You can also use the <big>big</big> or <bigger>bigger</bigger> and "
"the <small>small</small> or <smaller>smaller</smaller> tags.<br>"
"<ps>"
"<subtitle>Status indicators</subtitle><br>"
"<info>info</info>, <success>success</success>, <warning>warning</warning> and <failure>failure</failure><br>"
"<ps>"
"<subtitle>Forms attributes</subtitle><br>"
"<name>Song:</name> <val>The show must go on</val><br>"
"<name>Artist:</name> <val>Queen</val><br>"
"<name>Album:</name> <val>Innuendo</val><br>"
"<ps>"
"<subtitle>Syntax highlight</subtitle><br>"
"<code>"
"<preprocessor>#include</preprocessor> <string>&lt;stdlib.h&gt;</string><br>"
"<preprocessor>#include</preprocessor> <string>&lt;Evas.h&gt;</string><br>"
"<br>"
"<preprocessor>#define</preprocessor> MESSAGE <string>\"Hello World\"</string><br>"
"<br>"
"<comment>/* Prints a message to standard output */</comment><br>"
"<type>void</type> <function>print_message</function><brace>(</brace><type>const char</type> *msg<brace>)</brace> <brace>{</brace><br>"
" printf<brace>(</brace><string>\"%s\\n\"</string>, msg<brace>)</brace>;<br>"
"<brace>}</brace><br>"
"<br>"
"<type>int</type> <function>main</function><brace>(</brace><type>int</type> argc, <type>char</type> *argv[]<brace>)</brace> <brace>{</brace><br>"
" <type>int</type> num_int = <number>123</number>;<br>"
" <type>float</type> num_float = <number>0.999</number>;<br>"
" <type>char</type> *str = <string>\"This is a string\"</string>;<br>"
" <type>Evas_Object</type> *obj = <keyword>NULL</keyword>;<br>"
" print_message<brace>(</brace>MESSAGE<brace>)</brace>;<br>"
" <keyword>return</keyword> <number>0</number>;<br>"
"<brace>}</brace><br>"
"<ps>"
"<line_added>+diff line added</line_added><br>"
"<line_removed>-diff line removed</line_removed><br>"
"<line_changed> diff line changed</line_changed><br>"
"</code>";
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)