Mostly libmui general cleanup

Moved the new drwable control in it's own file. Removed unused headers
etc etc.

Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
Michel Pollet 2024-02-15 10:45:46 +00:00
parent d399b12a9d
commit ab8a746bc8
No known key found for this signature in database
17 changed files with 283 additions and 203 deletions

View File

@ -8,9 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui_priv.h"
@ -220,7 +218,7 @@ mui_timer_register(
void *param,
uint32_t delay)
{
if (ui->timer.map == (uint64_t)-1) {
if (ui->timer.map == (uint64_t)-1L) {
fprintf(stderr, "%s ran out of timers\n", __func__);
return -1;
}
@ -241,7 +239,7 @@ mui_timer_reset(
{
if (id >= MUI_TIMER_COUNT)
return 0;
if (!(ui->timer.map & (1 << id)) ||
if (!(ui->timer.map & (1L << id)) ||
ui->timer.timers[id].cb != cb) {
printf("%s: timer %d not active\n", __func__, id);
return 0;
@ -252,7 +250,7 @@ mui_timer_reset(
res = ui->timer.timers[id].when - now;
ui->timer.timers[id].when = now + delay;
if (delay == 0) {
ui->timer.map &= ~(1 << id);
ui->timer.map &= ~(1L << id);
printf("%s: timer %d removed\n", __func__, id);
}

View File

@ -327,7 +327,10 @@ typedef struct mui_drawable_t {
union pixman_image * pixman; // (try) not to use these directly
unsigned int pixman_clip_dirty: 1,
cg_clip_dirty : 1,
dispose_pixels : 1;
dispose_pixels : 1,
dispose_drawable : 1;
// not used internally, but useful for the application
unsigned int texture_id;
// (default) position in destination when drawing
c2_pt_t origin;
mui_clip_stack_t clip;
@ -339,6 +342,25 @@ DECLARE_C_ARRAY(mui_drawable_t *, mui_drawable_array, 4);
/*
* Drawable related
*/
/* create a new mui_draware of size w x h, bpp depth.
* Optionally allocate the pixels if pixels is NULL. Allocated pixels
* are not cleared. */
mui_drawable_t *
mui_drawable_new(
c2_pt_t size,
uint8_t bpp,
void * pixels, // if NULL, will allocate
uint32_t row_bytes);
/* initialize a mui_drawable_t structure with the given parameters
* note it is not assumed 'd' contains anything valid, it will be
* overwritten */
mui_drawable_t *
mui_drawable_init(
mui_drawable_t * d,
c2_pt_t size,
uint8_t bpp,
void * pixels, // if NULL, will allocate
uint32_t row_bytes);
void
mui_drawable_dispose(
mui_drawable_t * dr);
@ -684,20 +706,6 @@ mui_menubar_highlight(
mui_window_t * win,
bool ignored );
enum mui_control_type_e {
MUI_CONTROL_NONE = 0,
MUI_CONTROL_BUTTON,
MUI_CONTROL_GROUP,
MUI_CONTROL_SEPARATOR,
MUI_CONTROL_TEXTBOX,
MUI_CONTROL_GROUPBOX,
MUI_CONTROL_LISTBOX,
MUI_CONTROL_SCROLLBAR,
MUI_CONTROL_MENUTITLE,
MUI_CONTROL_MENUITEM,
MUI_CONTROL_SUBMENUITEM,
MUI_CONTROL_POPUP,
};
enum mui_button_style_e {
MUI_BUTTON_STYLE_NORMAL = 0,
@ -750,10 +758,16 @@ typedef struct mui_control_t {
/*
* Control related
*/
/*
* This is the 'low level' control creation function, you can pass the
* 'cdef' function pointer and a control 'type' that will be passed to it,
* so you can implement variants of controls.
* The instance_size is the size of the extended control record, if any.
*/
mui_control_t *
mui_control_new(
mui_window_t * win,
uint8_t type,
uint32_t type, // specific to the CDEF
mui_cdef_p cdef,
c2_rect_t frame,
const char * title,
@ -812,11 +826,23 @@ mui_control_set_title(
mui_control_t * c,
const char * text );
/* Drawable control is just an offscreen buffer (icon, pixel view) */
mui_control_t *
mui_drawable_control_new(
mui_window_t * win,
c2_rect_t frame,
mui_drawable_t * dr,
mui_drawable_t * mask,
uint16_t flags);
mui_drawable_t *
mui_drawable_control_get_drawable(
mui_control_t * c);
mui_control_t *
mui_button_new(
mui_window_t * win,
c2_rect_t frame,
uint8_t style,
uint8_t style, // one of mui_button_style_e
const char * title,
uint32_t uid );
/*

View File

@ -8,13 +8,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "cg.h"
enum {
MUI_CONTROL_GROUP = FCC('g','r','o','p'),
MUI_CONTROL_SEPARATOR = FCC('s','e','p','r'),
MUI_CONTROL_TEXTBOX = FCC('t','b','o','x'),
MUI_CONTROL_GROUPBOX = FCC('g','b','o','x'),
};
typedef struct mui_textbox_control_t {
mui_control_t control;
mui_font_t * font;
@ -156,7 +160,7 @@ mui_textbox_new(
mui_control_t * c = mui_control_new(
win, MUI_CONTROL_TEXTBOX, mui_cdef_boxes,
frame, text, 0, sizeof(mui_textbox_control_t));
mui_textbox_control_t *tb = (mui_textbox_control_t *)c;
mui_textbox_control_t *tb = (mui_textbox_control_t *)c;
tb->font = mui_font_find(win->ui, font ? font : "main");
tb->flags = flags;
return c;
@ -182,7 +186,7 @@ mui_groupbox_new(
mui_control_t * c = mui_control_new(
win, MUI_CONTROL_GROUPBOX, mui_cdef_boxes,
frame, title, 0, sizeof(mui_textbox_control_t));
mui_textbox_control_t *tb = (mui_textbox_control_t *)c;
mui_textbox_control_t *tb = (mui_textbox_control_t *)c;
tb->flags = flags;
return c;
}

View File

@ -8,13 +8,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "cg.h"
enum {
MUI_CONTROL_BUTTON = FCC('b','u','t','n'),
};
extern const mui_control_color_t mui_control_color[MUI_CONTROL_STATE_COUNT];

View File

@ -0,0 +1,116 @@
/*
* mui_cdef_drawable.c
*
* Copyright (C) 2023 Michel Pollet <buserror@gmail.com>
*
* SPDX-License-Identifier: MIT
*/
#include <stdio.h>
#include <stdlib.h>
#include "mui.h"
enum {
MUI_CONTROL_DRAWABLE = FCC('D','R','A','W'),
};
typedef struct mui_drawable_control_t {
mui_control_t control;
uint16_t flags;
mui_drawable_t * mask;
mui_drawable_array_t drawables;
} mui_drawable_control_t;
IMPLEMENT_C_ARRAY(mui_drawable_array);
static void
mui_drawable_draw(
mui_window_t * win,
mui_control_t * c,
mui_drawable_t *dr )
{
c2_rect_t f = c->frame;
c2_rect_offset(&f, win->content.l, win->content.t);
mui_drawable_clip_push(dr, &f);
mui_drawable_control_t *dc = (mui_drawable_control_t *)c;
for (int i = 0; i < (int)dc->drawables.count; i++) {
mui_drawable_t *d = dc->drawables.e[i];
if (!d->pix.pixels)
continue;
c2_rect_t src = C2_RECT_WH(0, 0,
d->pix.size.x,
d->pix.size.y);
c2_rect_offset(&src, d->origin.x, d->origin.y);
pixman_image_composite32(PIXMAN_OP_OVER,
mui_drawable_get_pixman(d),
mui_drawable_get_pixman(dc->mask),
mui_drawable_get_pixman(dr),
src.l, src.t, 0, 0,
f.l, f.t,
c2_rect_width(&src), c2_rect_height(&src));
}
mui_drawable_clip_pop(dr);
}
static bool
mui_cdef_drawable(
struct mui_control_t * c,
uint8_t what,
void * param)
{
switch (what) {
case MUI_CDEF_DRAW: {
mui_drawable_t * dr = param;
switch (c->type) {
case MUI_CONTROL_DRAWABLE:
mui_drawable_draw(c->win, c, dr);
break;
}
} break;
case MUI_CDEF_DISPOSE: {
switch (c->type) {
case MUI_CONTROL_DRAWABLE: {
mui_drawable_control_t *dc = (mui_drawable_control_t *)c;
for (int i = 0; i < (int)dc->drawables.count; i++) {
mui_drawable_t *d = dc->drawables.e[i];
mui_drawable_dispose(d);
}
mui_drawable_dispose(dc->mask);
mui_drawable_array_free(&dc->drawables);
} break;
}
} break;
}
return false;
}
mui_control_t *
mui_drawable_control_new(
mui_window_t * win,
c2_rect_t frame,
mui_drawable_t * dr,
mui_drawable_t * mask,
uint16_t flags)
{
mui_drawable_control_t *dc = (mui_drawable_control_t *)mui_control_new(
win, MUI_CONTROL_DRAWABLE, mui_cdef_drawable,
frame, NULL, 0, sizeof(mui_drawable_control_t));
dc->mask = mask;
dc->flags = flags;
if (dr)
mui_drawable_array_add(&dc->drawables, dr);
return &dc->control;
}
mui_drawable_t *
mui_drawable_control_get_drawable(
mui_control_t * c)
{
mui_drawable_control_t *dc = (mui_drawable_control_t *)c;
return dc->drawables.count ? dc->drawables.e[0] : NULL;
}

View File

@ -8,13 +8,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "cg.h"
enum {
MUI_CONTROL_LISTBOX = FCC('l','b','o','x'),
};
typedef struct mui_listbox_control_t {
mui_control_t control;
struct mui_control_t * scrollbar;

View File

@ -8,13 +8,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "cg.h"
enum {
MUI_CONTROL_SCROLLBAR = FCC('s','b','a','r'),
};
extern const mui_control_color_t mui_control_color[MUI_CONTROL_STATE_COUNT];

View File

@ -8,9 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
@ -53,7 +50,7 @@ mui_control_draw(
mui_control_t *
mui_control_new(
mui_window_t * win,
uint8_t type,
uint32_t type,
mui_cdef_p cdef,
c2_rect_t frame,
const char * title,
@ -198,7 +195,7 @@ mui_control_event(
return res;
switch (ev->type) {
case MUI_EVENT_KEYDOWN:
if (c->state != MUI_CONTROL_STATE_DISABLED &&
if (c->state != MUI_CONTROL_STATE_DISABLED &&
mui_event_match_key(ev, c->key_equ)) {
mui_control_set_state(c, MUI_CONTROL_STATE_CLICKED);
mui_timer_register(

View File

@ -8,8 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <pixman.h>
#include "mui.h"
@ -18,6 +16,43 @@
IMPLEMENT_C_ARRAY(mui_clip_stack);
// create a new mui_draware of size w x h, bpp depth.
// optionally allocate the pixels if pixels is NULL
mui_drawable_t *
mui_drawable_init(
mui_drawable_t * d,
c2_pt_t size,
uint8_t bpp,
void * pixels, // if NULL, will allocate
uint32_t row_bytes)
{
static const mui_drawable_t zero = {};
*d = zero;
d->pix.bpp = bpp;
d->pix.size = size;
d->pix.row_bytes = row_bytes == 0 ?
(uint32_t)((size.x * (bpp / 8)) + 3) & ~3 :
row_bytes;
d->pix.pixels = pixels ? pixels : malloc(d->pix.row_bytes * size.y);
d->dispose_pixels = pixels == NULL;
return d;
}
// create a new mui_draware of size w x h, bpp depth.
// optionally allocate the pixels if pixels is NULL
mui_drawable_t *
mui_drawable_new(
c2_pt_t size,
uint8_t bpp,
void * pixels, // if NULL, will allocate
uint32_t row_bytes)
{
mui_drawable_t *d = malloc(sizeof(mui_drawable_t));
mui_drawable_init(d, size, bpp, pixels, row_bytes);
d->dispose_drawable = 1;
return d;
}
void
mui_drawable_clear(
mui_drawable_t * dr)
@ -49,7 +84,8 @@ mui_drawable_dispose(
return;
mui_drawable_clear(dr);
mui_clip_stack_free(&dr->clip);
// free(dr);
if (dr->dispose_drawable)
free(dr);
}
static struct cg_ctx_t *

View File

@ -8,9 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#define STB_TRUETYPE_IMPLEMENTATION
#define STB_TTC_IMPLEMENTATION

View File

@ -8,9 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "mui_priv.h"
@ -20,6 +17,13 @@
#define D(_x) //_x
#endif
enum {
MUI_CONTROL_MENUTITLE = FCC('m','t','i','t'),
MUI_CONTROL_MENUITEM = FCC('m','i','t','m'),
MUI_CONTROL_SUBMENUITEM = FCC('s','m','i','t'),
MUI_CONTROL_POPUP = FCC('p','o','p','u'),
};
/* These are *window action* -- parameter 'target' is a mui_menu_t* */
enum mui_menu_action_e {
MUI_MENU_ACTION_NONE = 0,

View File

@ -8,9 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "mui.h"
#include "mui_priv.h"

View File

@ -9,13 +9,9 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <glob.h>
#include <libgen.h>
#ifdef __linux__
#define MUI_HAS_REGEXP
@ -26,7 +22,7 @@
#include "mui.h"
#include "c2_geometry.h"
#include <sys/types.h>
#include <libgen.h>
#include <dirent.h>
DECLARE_C_ARRAY(char*, string_array, 2);

View File

@ -8,10 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <execinfo.h>
#include "mui_priv.h"
#include "cg.h"

View File

@ -172,10 +172,10 @@ _init(
m_cpu_menu);
// mii_mui_configure_slots(g->ui, &g_machine_conf);
mii_mui_load_binary(g->ui, &g_loadbin_conf);
// mii_mui_load_binary(g->ui, &g_loadbin_conf);
// mii_mui_load_1mbrom(g->ui, &g_machine_conf.slot[0].conf.rom1mb);
// mii_mui_load_2dsk(g->ui, &g_machine_conf.slot[0].conf.disk2, MII_2DSK_DISKII);
// mii_mui_about(g->ui);
mii_mui_about(g->ui);
#if 0
mui_alert(ui, C2_PT(0,0),
"Testing one Two",
@ -183,7 +183,7 @@ _init(
"This operation cannot be cancelled.",
MUI_ALERT_WARN);
#endif
#if 0
#if 1
mui_stdfile_get(ui,
C2_PT(0, 0),
"Select image for SmartPort card",
@ -233,4 +233,4 @@ mui_plug_t mui_plug = {
.dispose = _dispose,
.draw = _draw,
.event = _event,
};
};

View File

@ -679,7 +679,7 @@ mii_x11_prepare_textures(
glTexImage2D(GL_TEXTURE_2D, 0, 4,
MII_VRAM_WIDTH,
MII_VRAM_HEIGHT, 0, GL_RGBA,
MII_VRAM_HEIGHT, 0, GL_BGRA, // note BGRA here, not RGBA
GL_UNSIGNED_BYTE,
mii->video.pixels);
// bind the mui texture using the GL_ARB_texture_rectangle as well
@ -1000,7 +1000,7 @@ main(
glPixelStorei(GL_UNPACK_ROW_LENGTH, ui->dr.pix.row_bytes / 4);
glTexSubImage2D(GL_TEXTURE_2D, 0, r.l, r.t,
c2_rect_width(&r), c2_rect_height(&r),
GL_RGBA, GL_UNSIGNED_BYTE,
GL_BGRA, GL_UNSIGNED_BYTE,
ui->dr.pix.pixels + (r.t * ui->dr.pix.row_bytes) + (r.l * 4));
}
}

View File

@ -1,7 +1,7 @@
/*
* mui_mui_about.c
*
* Copyright (C) 2023 Michel Pollet <buserror@gmail.com>
* Copyright (C) 2024 Michel Pollet <buserror@gmail.com>
*
* SPDX-License-Identifier: MIT
*/
@ -25,96 +25,16 @@ enum {
struct mui_drawable_control_t;
typedef struct mii_mui_about_t {
mui_window_t win;
struct mui_drawable_control_t * text;
mui_control_t * text;
uint8_t timer_id;
bool terminate;
} mii_mui_about_t;
//DECLARE_C_ARRAY(mui_drawable_t *, mui_drawable_array, 4);
typedef struct mui_drawable_control_t {
mui_control_t control;
uint16_t flags;
mui_drawable_t * mask;
mui_drawable_array_t drawables;
} mui_drawable_control_t;
IMPLEMENT_C_ARRAY(mui_drawable_array);
static void
mui_drawable_draw(
mui_window_t * win,
mui_control_t * c,
mui_drawable_t *dr )
{
c2_rect_t f = c->frame;
c2_rect_offset(&f, win->content.l, win->content.t);
mui_drawable_clip_push(dr, &f);
mui_drawable_control_t *dc = (mui_drawable_control_t *)c;
for (int i = 0; i < (int)dc->drawables.count; i++) {
mui_drawable_t *d = dc->drawables.e[i];
if (!d->pix.pixels)
continue;
c2_rect_t src = C2_RECT_WH(0, 0,
d->pix.size.x,
d->pix.size.y);
c2_rect_offset(&src, d->origin.x, d->origin.y);
pixman_image_composite32(PIXMAN_OP_OVER,
mui_drawable_get_pixman(d),
mui_drawable_get_pixman(dc->mask),
mui_drawable_get_pixman(dr),
src.l, src.t, 0, 0,
f.l, f.t,
c2_rect_width(&src), c2_rect_height(&src));
}
mui_drawable_clip_pop(dr);
}
static bool
mui_cdef_drawable(
struct mui_control_t * c,
uint8_t what,
void * param)
{
// mui_textbox_control_t *tb = (mui_textbox_control_t *)c;
switch (what) {
case MUI_CDEF_DRAW: {
mui_drawable_t * dr = param;
switch (c->type) {
case 0:
mui_drawable_draw(c->win, c, dr);
break;
}
} break;
case MUI_CDEF_DISPOSE: {
switch (c->type) {
case 0: {
mui_drawable_control_t *dc = (mui_drawable_control_t *)c;
for (int i = 0; i < (int)dc->drawables.count; i++) {
mui_drawable_t *d = dc->drawables.e[i];
mui_drawable_dispose(d);
free(d);
}
mui_drawable_dispose(dc->mask);
if (dc->mask)
free(dc->mask);
mui_drawable_array_free(&dc->drawables);
} break;
}
} break;
}
return false;
}
static mui_time_t
mui_about_timer_cb(
struct mui_t * mui,
mui_time_t now,
void * param)
struct mui_t * mui,
mui_time_t now,
void * param)
{
mii_mui_about_t * m = (mii_mui_about_t*)param;
@ -122,15 +42,13 @@ mui_about_timer_cb(
mui_window_dispose(&m->win);
return 0;
}
mui_drawable_control_t *dc = m->text;
mui_drawable_t * dr = dc->drawables.e[0];
mui_drawable_t * dr = mui_drawable_control_get_drawable(m->text);
dr->origin.y++;
int height = dr->pix.size.y + c2_rect_height(&dc->control.frame);
int height = dr->pix.size.y + c2_rect_height(&m->text->frame);
if (dr->origin.y > dr->pix.size.y)
dr->origin.y -= height;
// printf("Y: %d/%d\n", dr->origin.y, height);
mui_control_inval(&dc->control);
mui_control_inval(m->text);
return MUI_TIME_SECOND / 30;
}
@ -148,7 +66,7 @@ _mii_about_button_cb(
switch (what) {
case MUI_CONTROL_ACTION_SELECT:
printf("%s control %4.4s\n", __func__, (char*)&uid);
// printf("%s control %4.4s\n", __func__, (char*)&uid);
switch (uid) {
case MII_ABOUT_OK: {
m->terminate = true;
@ -159,6 +77,24 @@ _mii_about_button_cb(
return 0;
}
static int
_mii_about_action_cb(
mui_window_t * w,
void * cb_param,
uint32_t what,
void * param) // not used
{
printf("%s %4.4s\n", __func__, (char*)&what);
mii_mui_about_t * m = cb_param;
switch (what) {
case MUI_WINDOW_ACTION_CLOSE:
mui_timer_reset(w->ui, m->timer_id, mui_about_timer_cb, 0);
m->terminate = true;
break;
}
return 0;
}
#ifndef MII_VERSION
#define MII_VERSION "0.0.0"
@ -179,6 +115,7 @@ static const char * thanksto =
"Jef Raskin\n"
"Susan Kare\n"
"Thierry Magniez\n"
"Matthew Bloch\n"
"Charles \"regnips\" Springer\n"
"Jeroen \"Sprite_tm\" Domburg\n"
"Claude \"Claude\" Schwarz\n"
@ -207,6 +144,7 @@ mii_mui_about(
"About the MII " MUI_GLYPH_IIE " Emulator",
sizeof(mii_mui_about_t));
mui_window_set_id(w, MII_ABOUT_WINDOW_ID);
mui_window_set_action(w, _mii_about_action_cb, w);
mii_mui_about_t * m = (mii_mui_about_t*)w;
@ -221,52 +159,31 @@ mii_mui_about(
c->key_equ = MUI_KEY_EQU(0, 13);
mui_control_set_action(c, _mii_about_button_cb, w);
cf = C2_RECT_WH(margin, margin, mii_icon64[0], mii_icon64[1]);
/*
Icon
*/
c = mui_control_new(
w, 0, mui_cdef_drawable,
cf, NULL, 0, sizeof(mui_drawable_control_t));
mui_drawable_control_t *dc = (mui_drawable_control_t*)c;
mui_drawable_t *dr = calloc(1, sizeof(mui_drawable_t));
/* the Xorg icon is in fact using unsigned int (64 bits!) per pixels
* for some bizare reason. Here we convert it back to 32bpp */
dr->pix.bpp = 32;
dr->pix.size.x = mii_icon64[0];
dr->pix.size.y = mii_icon64[1];
dr->pix.row_bytes = dr->pix.size.x * 4;
dr->pix.pixels = calloc(1, dr->pix.row_bytes * dr->pix.size.y);
dr->dispose_pixels = true;
cf = C2_RECT_WH(margin, margin, mii_icon64[0], mii_icon64[1]);
mui_drawable_t *dr = mui_drawable_new(
C2_PT(mii_icon64[0], mii_icon64[1]),
32, NULL, 0);
/*
* if the clear color is 0, it means we are using OpenGL as a renderer
* this is not ideal as it means we need to reverse our internal format
* (ARGB) to the one used by OpenGL (ABGR)
* Silly icon is in 64bpp, due to xorg requiring 'unsigned long' pixels.
* We need to convert it to 32bpp
*/
for (int y = 0; y < dr->pix.size.y; y++) {
for (int x = 0; x < dr->pix.size.x; x++) {
uint32_t *p = (uint32_t*)dr->pix.pixels;
p += y * dr->pix.size.x + x;
uint32_t pix = mii_icon64[2 + y * dr->pix.size.x + x];
if (ui->color.clear.a == 0) {
// ARGB -> ABGR
*p = ((pix & 0xff00ff00) |
((pix & 0x00ff0000) >> 16) |
((pix & 0x000000ff) << 16));
} else
*p = pix;
*p = mii_icon64[2 + y * dr->pix.size.x + x];
}
}
mui_drawable_array_add(&dc->drawables, dr);
c = mui_drawable_control_new(w, cf, dr, NULL, 0);
/*
* Text in two parts
*/
cf = C2_RECT_WH(cf.r + margin, 10,
c2_rect_width(&w->frame) - cf.r - margin*2,
ok->frame.t - margin);
c2_rect_t tbox = cf;
c2_rect_offset(&tbox, -tbox.l, -tbox.t);
tbox.b = 1000;
@ -283,43 +200,35 @@ mii_mui_about(
about_frame.b = 0;
for (int li = 0; li < (int)lines_about.count; li++) {
mui_glyph_array_t * line = &lines_about.e[li];
// printf("line %d x %d y %d w %d\n", li, line->x, line->y, line->w);
about_frame.b = line->y;
}
mui_glyph_line_array_t lines_thanks = {};
mui_font_measure(geneva, tbox, thanksto, 0, &lines_thanks, MUI_TEXT_ALIGN_CENTER);
mui_font_measure(geneva, tbox, thanksto, 0, &lines_thanks,
MUI_TEXT_ALIGN_CENTER);
c2_rect_t frame_thanks = tbox;
frame_thanks.b = 0;
for (int li = 0; li < (int)lines_thanks.count; li++) {
mui_glyph_array_t * line = &lines_thanks.e[li];
// printf("line %d x %d y %d w %d\n", li, line->x, line->y, line->w);
frame_thanks.b = line->y;
}
c2_rect_offset(&frame_thanks, 0, about_frame.b + 0);
c = mui_control_new(
w, 0, mui_cdef_drawable,
cf, NULL, 0, sizeof(mui_drawable_control_t));
tbox.b = frame_thanks.b + 2;
dr = mui_drawable_new(
C2_PT(c2_rect_width(&tbox), c2_rect_height(&tbox)),
32, NULL, 0);
memset(dr->pix.pixels, 0, dr->pix.size.y * dr->pix.row_bytes);
m->text = c = mui_drawable_control_new(w, cf, dr, NULL, 0);
m->text = dc = (mui_drawable_control_t*)c;
dr = calloc(1, sizeof(mui_drawable_t));
dr->pix.bpp = 32;
dr->pix.size.x = c2_rect_width(&tbox);
dr->pix.size.y = c2_rect_height(&tbox);
dr->pix.row_bytes = dr->pix.size.x * 4;
dr->pix.pixels = calloc(1, dr->pix.row_bytes * dr->pix.size.y);
dr->dispose_pixels = true;
mui_color_t text_color = MUI_COLOR(0x000000ff);
mui_font_measure_draw(font, dr, tbox, &lines_about,
text_color, MUI_TEXT_ALIGN_CENTER);
mui_font_measure_draw(geneva, dr, frame_thanks, &lines_thanks,
text_color, MUI_TEXT_ALIGN_CENTER);
mui_drawable_array_add(&dc->drawables, dr);
mui_font_measure_clear(&lines_about);
mui_font_measure_clear(&lines_thanks);
m->timer_id = mui_timer_register(ui,
mui_about_timer_cb, m, MUI_TIME_SECOND);
return w;
}