summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-11-24 20:25:46 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-11-24 20:25:46 +0000
commit01ff5b2958a62b4412a4a031a750c5ebd9ebebb2 (patch)
tree3b69ae4ae4a899b9532fcd69b30c8854b69298a7 /src
parent03f6b0bfe6ebeb9dce0c36ecea047a0b7b8d3f8a (diff)
downloadenlightenment-01ff5b2958a62b4412a4a031a750c5ebd9ebebb2.tar.gz
paledit - make the major colors uses bigger 4x4 items in pal thumb
Diffstat (limited to 'src')
-rw-r--r--src/bin/tools/paledit/palimg.c71
1 files changed, 67 insertions, 4 deletions
diff --git a/src/bin/tools/paledit/palimg.c b/src/bin/tools/paledit/palimg.c
index fe718ead0b..e40110bc44 100644
--- a/src/bin/tools/paledit/palimg.c
+++ b/src/bin/tools/paledit/palimg.c
@@ -1,5 +1,18 @@
#include "main.h"
+static Elm_Palette_Color *
+_find_col(Eina_List *colors, const char *name)
+{
+ Eina_List *l;
+ Elm_Palette_Color *col;
+
+ EINA_LIST_FOREACH(colors, l, col)
+ {
+ if ((col->name) && (!strcmp(col->name, name))) return col;
+ }
+ return NULL;
+}
+
void
palimg_update(Evas_Object *img, Elm_Palette *pal)
{
@@ -7,17 +20,67 @@ palimg_update(Evas_Object *img, Elm_Palette *pal)
int w, h, stride;
Eina_List *l;
Elm_Palette_Color *col;
- int x = 0, pixn = 0;
+ Elm_Palette_Color *cols[8];
+ int x = 0, pixn = 0, xx, yy;
+ int i, n, r, g, b, a;
if (!pal) return;
evas_object_image_size_get(img, &w, &h);
stride = evas_object_image_stride_get(img);
pix = evas_object_image_data_get(img, EINA_TRUE);
lin = p = pix;
+ memset(pix, 0, stride * h);
+#define PIX_WRITE(r, g, b, a) \
+ for (yy = 0; yy < 4; yy++) \
+ { \
+ for (xx = 0; xx < 4; xx++) \
+ { \
+ ((int *)(void *)(p + (yy * stride)))[xx] = \
+ (a << 24) | (r << 16) | (g << 8) | (b); \
+ } \
+ } \
+ pixn += 16; \
+ x += 4; \
+ p += 16; \
+ if (x == w) \
+ { \
+ lin += stride * 4; \
+ p = lin; \
+ x = 0; \
+ } \
+ if (pixn >= 256) break
+
+ n = 0;
+ cols[n] = _find_col(pal->colors, ":bg"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":fg"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":selected"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":bg-dark"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":fg-light"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":selected-alt"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":selected2"); if (cols[n]) n++;
+ cols[n] = _find_col(pal->colors, ":selected3"); if (cols[n]) n++;
+ i = 0;
while (pixn < 256)
{
+ if (i >= n) break;
+ r = cols[i]->r;
+ g = cols[i]->g;
+ b = cols[i]->b;
+ a = cols[i]->a;
+ evas_color_argb_premul(a, &r, &g, &b);
+ PIX_WRITE(r, g, b, a);
+ i++;
+ }
+#undef PIX_WRITE
+ if (!((i == 0) || (i == 4) || (i == 8)))
+ {
+ lin += stride * 4;
+ p = lin;
+ x = 0;
+ }
+
#define PIX_WRITE(r, g, b, a) \
- *((int *)(void *)p) = (a << 24) | (r << 16) | (g << 8) | (b); \
+ ((int *)(void *)p)[0] = (a << 24) | (r << 16) | (g << 8) | (b); \
p += sizeof(int); \
pixn++; \
x++; \
@@ -28,6 +91,8 @@ palimg_update(Evas_Object *img, Elm_Palette *pal)
x = 0; \
} \
if (pixn >= 256) break
+ while (pixn < 256)
+ {
if (!pal->colors)
{
PIX_WRITE(0, 0, 0, 0);
@@ -36,8 +101,6 @@ palimg_update(Evas_Object *img, Elm_Palette *pal)
{
EINA_LIST_FOREACH(pal->colors, l, col)
{
- int r, g, b, a;
-
r = col->r;
g = col->g;
b = col->b;