Skip to content

Commit

Permalink
bugfixes, v0.71b
Browse files Browse the repository at this point in the history
  • Loading branch information
milgra committed Dec 13, 2022
1 parent af5ad3f commit 89a7823
Show file tree
Hide file tree
Showing 36 changed files with 1,055 additions and 466 deletions.
6 changes: 3 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'wcp',
'c',
version: '0.7b',
version: '0.71b',
license: 'MIT',
default_options: ['c_std=gnu99']
)
Expand Down Expand Up @@ -97,8 +97,8 @@ wcp_inc = include_directories(
com_sources = ['src/wcp/ui.c',
'src/wcp/config.c',
'src/wcp/kvlist.c',

'src/mt_core_ext/mt_bitmap_ext.c',
'src/wcp/ku_bitmap_ext.c',

'src/mt_core_ext/mt_string_ext.c',
# 'src/mt_core_ext/mt_map_ext.c',

Expand Down
80 changes: 43 additions & 37 deletions src/kinetic_ui/egl/ku_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void ku_gl_init(int max_dev_width, int max_dev_height)

if (binsize > value) binsize = value;

mt_log_info("Texture size will be %i", binsize);
mt_log_debug("texture size will be %i", binsize);

kugl.texturesize = binsize;

Expand Down Expand Up @@ -230,13 +230,11 @@ void ku_gl_add_textures(mt_vector_t* views, int force)
if (kugl.texturesize != kugl.atlas->width)
{
/* resize texture if needed */

ku_gl_delete_texture(kugl.texture);
kugl.texture = ku_gl_create_texture(0, kugl.texturesize, kugl.texturesize);
}

/* reset atlas */

if (kugl.atlas) REL(kugl.atlas);
kugl.atlas = ku_gl_atlas_new(kugl.texturesize, kugl.texturesize);
}
Expand All @@ -251,72 +249,80 @@ void ku_gl_add_textures(mt_vector_t* views, int force)
{
ku_view_t* view = views->data[index];

/* does it fit into the texture atlas? */
/* does it have texture? */
if (view->texture.bitmap)
{
/* does it fit into the texture atlas? */
if (view->texture.bitmap->w < kugl.texturesize &&
view->texture.bitmap->h < kugl.texturesize)
{
/* do we have to upload it? */
if (view->texture.uploaded == 0 || force)
ku_gl_atlas_coords_t coords = ku_gl_atlas_get(kugl.atlas, view->id);

/* did it's size change */
if (view->texture.bitmap->w != coords.w || view->texture.bitmap->h != coords.h || force)
{
ku_gl_atlas_coords_t coords = ku_gl_atlas_get(kugl.atlas, view->id);
int success = ku_gl_atlas_put(kugl.atlas, view->id, view->texture.bitmap->w, view->texture.bitmap->h);

/* did it's size change */
if (view->texture.bitmap->w != coords.w || view->texture.bitmap->h != coords.h || force)
if (success < 0)
{
int success = ku_gl_atlas_put(kugl.atlas, view->id, view->texture.bitmap->w, view->texture.bitmap->h);

if (success < 0)
/* force reset */
mt_log_debug("Texture Atlas Reset");
if (force == 0)
{
/* force reset */

mt_log_debug("Texture Atlas Reset\n");
if (force == 0) reset = 1;
break;
reset = 1;
}

coords = ku_gl_atlas_get(kugl.atlas, view->id);
else
{
/* reset is already forced so the only thing we can do is increase texture size */
int texturesize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texturesize);

if (kugl.texturesize < texturesize)
{
mt_log_info("Texture size will be %i", kugl.texturesize);
kugl.texturesize = texturesize;
reset = 1;
}
}
break;
}

/* upload texture */

glTexSubImage2D(
GL_TEXTURE_2D,
0,
coords.x,
coords.y,
coords.w,
coords.h,
GL_RGBA,
GL_UNSIGNED_BYTE,
view->texture.bitmap->data);

view->texture.uploaded = 1;
coords = ku_gl_atlas_get(kugl.atlas, view->id);
}

/* upload texture */
glTexSubImage2D(
GL_TEXTURE_2D,
0,
coords.x,
coords.y,
coords.w,
coords.h,
GL_RGBA,
GL_UNSIGNED_BYTE,
view->texture.bitmap->data);
}
else
{
if (force == 0)
{
/* increase texture and atlas size to fit texture */

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &kugl.texturesize);

mt_log_info("Texture size will be %i", kugl.texturesize);
break;

reset = 1;
}

/* TODO : auto test texture resize */
}

/* TODO : auto test texture resize */
}
}

glBindTexture(GL_TEXTURE_2D, 0);

/* in case of reset do the whole thing once again with forced reset*/

if (reset == 1) ku_gl_add_textures(views, 1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/kinetic_ui/handler/vh_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void vh_button_evt(ku_view_t* view, ku_event_t ev)

if (vh->enabled)
{
if (ev.type == KU_EVENT_MDOWN)
if (ev.type == KU_EVENT_MOUSE_DOWN)
{
if (vh->type == VH_BUTTON_NORMAL)
{
Expand All @@ -83,7 +83,7 @@ void vh_button_evt(ku_view_t* view, ku_event_t ev)
if (vh->onview) vh_anim_alpha(vh->onview, 0.0, 1.0, 10, AT_LINEAR);
}
}
else if (ev.type == KU_EVENT_MUP)
else if (ev.type == KU_EVENT_MOUSE_UP)
{
if (vh->type == VH_BUTTON_TOGGLE)
{
Expand Down
8 changes: 4 additions & 4 deletions src/kinetic_ui/handler/vh_cv_evnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void vh_cv_evnt_evt(ku_view_t* view, ku_event_t ev)
else if (ev.type == KU_EVENT_RESIZE)
{
}
else if (ev.type == KU_EVENT_MMOVE)
else if (ev.type == KU_EVENT_MOUSE_MOVE)
{
// show scroll
if (!vh->scroll_visible)
Expand All @@ -163,7 +163,7 @@ void vh_cv_evnt_evt(ku_view_t* view, ku_event_t ev)
vh->mx = ev.x;
vh->my = ev.y;
}
else if (ev.type == KU_EVENT_MMOVE_OUT)
else if (ev.type == KU_EVENT_MOUSE_MOVE_OUT)
{
// hide scroll
if (vh->scroll_visible)
Expand All @@ -172,7 +172,7 @@ void vh_cv_evnt_evt(ku_view_t* view, ku_event_t ev)
vh_cv_scrl_hide(vh->tscrl_view);
}
}
else if (ev.type == KU_EVENT_MDOWN)
else if (ev.type == KU_EVENT_MOUSE_DOWN)
{
if (ev.x > view->frame.global.x + view->frame.global.w - SCROLLBAR)
{
Expand All @@ -187,7 +187,7 @@ void vh_cv_evnt_evt(ku_view_t* view, ku_event_t ev)
vh_cv_evnt_event_t event = {.id = VH_CV_EVENT_CLICK};
if (vh->on_event) (*vh->on_event)(event);
}
else if (ev.type == KU_EVENT_MUP)
else if (ev.type == KU_EVENT_MOUSE_UP)
{
vh->scroll_drag = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/kinetic_ui/handler/vh_drag.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void vh_drag_drag(ku_view_t* view, ku_view_t* item);

void vh_drag_evt(ku_view_t* view, ku_event_t ev)
{
if (ev.type == KU_EVENT_MMOVE && ev.drag)
if (ev.type == KU_EVENT_MOUSE_MOVE && ev.drag)
{
vh_drag_t* vh = view->handler_data;

Expand All @@ -50,7 +50,7 @@ void vh_drag_evt(ku_view_t* view, ku_event_t ev)
if (vh->on_event) (*vh->on_event)(event);
}
}
if (ev.type == KU_EVENT_MUP && ev.drag)
if (ev.type == KU_EVENT_MOUSE_UP && ev.drag)
{
vh_drag_t* vh = view->handler_data;

Expand Down
2 changes: 1 addition & 1 deletion src/kinetic_ui/handler/vh_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void vh_key_add(ku_view_t* view, void (*on_event)(vh_key_event_t));

void vh_key_evt(ku_view_t* view, ku_event_t ev)
{
if (ev.type == KU_EVENT_KDOWN)
if (ev.type == KU_EVENT_KEY_DOWN)
{
vh_key_t* vh = view->handler_data;
vh_key_event_t event = {.ev = ev, .vh = vh, .view = view};
Expand Down
2 changes: 1 addition & 1 deletion src/kinetic_ui/handler/vh_knob.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct _vh_knob_t

void vh_knob_evt(ku_view_t* view, ku_event_t ev)
{
if (ev.type == KU_EVENT_MDOWN || (ev.type == KU_EVENT_MMOVE && ev.drag))
if (ev.type == KU_EVENT_MOUSE_DOWN || (ev.type == KU_EVENT_MOUSE_MOVE && ev.drag))
{
vh_knob_t* vh = view->handler_data;

Expand Down
4 changes: 2 additions & 2 deletions src/kinetic_ui/handler/vh_roll.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void vh_roll_add(ku_view_t* view, void (*on_event)(vh_roll_event_t));

void vh_roll_evt(ku_view_t* view, ku_event_t ev)
{
if (ev.type == KU_EVENT_MMOVE)
if (ev.type == KU_EVENT_MOUSE_MOVE)
{
vh_roll_t* vh = view->handler_data;
ku_rect_t frame = view->frame.global;
Expand All @@ -52,7 +52,7 @@ void vh_roll_evt(ku_view_t* view, ku_event_t ev)
}
}
}
else if (ev.type == KU_EVENT_MMOVE_OUT)
else if (ev.type == KU_EVENT_MOUSE_MOVE_OUT)
{
vh_roll_t* vh = view->handler_data;
ku_rect_t frame = view->frame.global;
Expand Down
2 changes: 1 addition & 1 deletion src/kinetic_ui/handler/vh_slider.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void vh_slider_evt(ku_view_t* view, ku_event_t ev)

if (vh->enabled)
{
if (ev.type == KU_EVENT_MDOWN || (ev.type == KU_EVENT_MMOVE && ev.drag))
if (ev.type == KU_EVENT_MOUSE_DOWN || (ev.type == KU_EVENT_MOUSE_MOVE && ev.drag))
{
float dx = ev.x - view->frame.global.x;
vh->ratio = dx / view->frame.global.w;
Expand Down
Loading

0 comments on commit 89a7823

Please sign in to comment.