options_themepv: add color mode
This commit is contained in:
parent
f82f1b25ac
commit
ac1bc02293
|
@ -61,7 +61,8 @@ _cb_op_theme_content_get(void *data, Evas_Object *obj, const char *part)
|
|||
theme_path_get(t->name),
|
||||
NULL,
|
||||
128 * elm_config_scale_get(),
|
||||
64 * elm_config_scale_get());
|
||||
64 * elm_config_scale_get(),
|
||||
EINA_FALSE);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,135 @@ _row_set(Evas_Object *o, int y, const char *txt)
|
|||
evas_object_textgrid_update_add(o, 0, y, tw, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_gyw_textgrid(Evas_Object *o)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
int tw, th;
|
||||
Evas_Textgrid_Cell *tc;
|
||||
const char *FGs[] = {
|
||||
" ",
|
||||
" ",
|
||||
" 0",
|
||||
"b0",
|
||||
" 1",
|
||||
"b1",
|
||||
" 2",
|
||||
"b2",
|
||||
" 3",
|
||||
"b3",
|
||||
" 4",
|
||||
"b4",
|
||||
" 5",
|
||||
"b5",
|
||||
" 6",
|
||||
"b6",
|
||||
" 7",
|
||||
"b7",
|
||||
NULL
|
||||
};
|
||||
const char *fg_string;
|
||||
const char *title = " 0 1 2 3 4 5 6 7";
|
||||
const char *s;
|
||||
|
||||
evas_object_textgrid_size_get(o, &tw, &th);
|
||||
|
||||
/* write title line */
|
||||
s = title;
|
||||
tc = evas_object_textgrid_cellrow_get(o, 0);
|
||||
if (!tc)
|
||||
return;
|
||||
for (x = 0; x < tw && *s; x++, s++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = s[0],
|
||||
};
|
||||
}
|
||||
for (; x < tw; x++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = ' ',
|
||||
};
|
||||
}
|
||||
|
||||
for (fg_string = FGs[0], y = 1;
|
||||
fg_string && y < th;
|
||||
fg_string = FGs[y], y++)
|
||||
{
|
||||
int fg, bg;
|
||||
Eina_Bool bold = (y % 2) == 0;
|
||||
|
||||
fg = (y - 1) / 2;
|
||||
if (bold)
|
||||
fg += 12;
|
||||
bg = COL_INVIS;
|
||||
x = 0;
|
||||
|
||||
tc = evas_object_textgrid_cellrow_get(o, y);
|
||||
if (!tc) return;
|
||||
|
||||
/* write color fg */
|
||||
for (s = fg_string; x < tw && *s; x++, s++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = s[0],
|
||||
};
|
||||
}
|
||||
|
||||
/* write colors */
|
||||
for (bg = 0; bg <= 8; bg++)
|
||||
{
|
||||
if (x < tw)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = ' ',
|
||||
};
|
||||
x++;
|
||||
}
|
||||
for (s = "gYw"; x < tw && *s; x++, s++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = fg,
|
||||
.bg = (bg == 0) ? COL_INVIS : bg,
|
||||
.bold = bold,
|
||||
.codepoint = s[0],
|
||||
};
|
||||
}
|
||||
}
|
||||
for (; x < tw; x++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = ' ',
|
||||
};
|
||||
}
|
||||
}
|
||||
for (; y < th; ++y)
|
||||
{
|
||||
tc = evas_object_textgrid_cellrow_get(o, y);
|
||||
if (!tc) return;
|
||||
|
||||
for (x = 0; x < tw; x++)
|
||||
{
|
||||
tc[x] = (Evas_Textgrid_Cell) {
|
||||
.fg = COL_DEF,
|
||||
.bg = COL_INVIS,
|
||||
.codepoint = ' ',
|
||||
};
|
||||
}
|
||||
}
|
||||
evas_object_textgrid_update_add(o, 0, 0, tw, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_resize(void *_data EINA_UNUSED,
|
||||
Evas *_e EINA_UNUSED,
|
||||
|
@ -98,7 +227,8 @@ options_theme_preview_add(Evas_Object *parent,
|
|||
const Config *config,
|
||||
const char *file,
|
||||
const Color_Scheme *cs,
|
||||
Evas_Coord w, Evas_Coord h)
|
||||
Evas_Coord w, Evas_Coord h,
|
||||
Eina_Bool colors_mode)
|
||||
{
|
||||
Evas_Object *o, *oo, *obase, *oe, *obg;
|
||||
Evas *evas;
|
||||
|
@ -157,7 +287,7 @@ options_theme_preview_add(Evas_Object *parent,
|
|||
|
||||
// create a texgrid and swallow pack into grid
|
||||
o = evas_object_textgrid_add(evas);
|
||||
colors_term_init(o, obg, config);
|
||||
colors_term_init(o, obg);
|
||||
evas_object_scale_set(o, elm_config_scale_get());
|
||||
if (config->font.bitmap)
|
||||
{
|
||||
|
@ -169,12 +299,17 @@ options_theme_preview_add(Evas_Object *parent,
|
|||
}
|
||||
else
|
||||
evas_object_textgrid_font_set(o, config->font.name, config->font.size);
|
||||
evas_object_textgrid_size_set(o, 80, 24);
|
||||
evas_object_textgrid_size_set(o, COLOR_MODE_PREVIEW_WIDTH,
|
||||
COLOR_MODE_PREVIEW_HEIGHT);
|
||||
|
||||
evas_object_textgrid_cell_size_get(o, &ww, &hh);
|
||||
if (ww < 1) ww = 1;
|
||||
if (hh < 1) hh = 1;
|
||||
|
||||
if (colors_mode)
|
||||
_fill_gyw_textgrid(o);
|
||||
else
|
||||
{
|
||||
// cmds:
|
||||
// \x01 = set fg
|
||||
// \x02 = set bg
|
||||
|
@ -200,7 +335,8 @@ options_theme_preview_add(Evas_Object *parent,
|
|||
_row_set(o, 2, F("\x06")"blue"X" "F("\x07")"mag"X" "F("\x08")"cyan"X" "F("\x09")"white");
|
||||
_row_set(o, 3, F("\x12")"black"X" "F("\x13")"red"X" "F("\x14")"green"X" "F("\x15")"yellow");
|
||||
_row_set(o, 4, F("\x16")"blue"X" "F("\x17")"mag"X" "F("\x18")"cyan"X" "F("\x19")"white");
|
||||
for (y = 5; y < 24; y++) _row_set(o, y, "");
|
||||
for (y = 5; y < 10; y++) _row_set(o, y, "");
|
||||
}
|
||||
|
||||
evas_object_show(o);
|
||||
evas_object_data_set(oo, "textgrid", o);
|
||||
|
|
|
@ -8,6 +8,8 @@ options_theme_preview_add(Evas_Object *parent,
|
|||
const char *file,
|
||||
const Color_Scheme *cs,
|
||||
Evas_Coord w,
|
||||
Evas_Coord h);
|
||||
|
||||
Evas_Coord h,
|
||||
Eina_Bool colors_mode);
|
||||
#define COLOR_MODE_PREVIEW_WIDTH 39
|
||||
#define COLOR_MODE_PREVIEW_HEIGHT 20
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue