add container margin
the margin also counts for resizing allowing for small borders
This commit is contained in:
parent
8dc34e7114
commit
e8c7a65f52
80
ugui.c
80
ugui.c
@ -59,13 +59,14 @@ static const ug_style_t default_style = {
|
|||||||
},
|
},
|
||||||
.cnt = {
|
.cnt = {
|
||||||
.bg_color = RGB_FORMAT(0x0000ff),
|
.bg_color = RGB_FORMAT(0x0000ff),
|
||||||
.border.t = SIZE_PX(3),
|
.border.t = SIZE_PX(1),
|
||||||
.border.b = SIZE_PX(3),
|
.border.b = SIZE_PX(1),
|
||||||
.border.l = SIZE_PX(3),
|
.border.l = SIZE_PX(1),
|
||||||
.border.r = SIZE_PX(3),
|
.border.r = SIZE_PX(1),
|
||||||
.border.color = RGB_FORMAT(0x00ff00),
|
.border.color = RGB_FORMAT(0x00ff00),
|
||||||
.titlebar.height = SIZE_PX(20),
|
.titlebar.height = SIZE_PX(20),
|
||||||
.titlebar.bg_color = RGB_FORMAT(0xbababa),
|
.titlebar.bg_color = RGB_FORMAT(0xbababa),
|
||||||
|
.margin = SIZE_PX(3),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -402,36 +403,47 @@ static int position_container(ug_ctx_t *ctx, ug_container_t *cnt)
|
|||||||
* Container style:
|
* Container style:
|
||||||
*
|
*
|
||||||
* rca
|
* rca
|
||||||
* v
|
* v v Border Top v
|
||||||
* +-----------------------------------------------+
|
* +--------------------------------------------------------+
|
||||||
* | Titlebar |
|
* +--------------------------------------------------------+
|
||||||
* +-----------------------------------------------+
|
* | Titlebar |
|
||||||
* |+---------------------------------------------+|
|
* +--------------------------------------------------------+
|
||||||
* ||\ ^ Border Top ^ ||
|
* |+------------------------------------------------------+|
|
||||||
* || \_ rect(0,0) ||
|
* || .................................................... ||
|
||||||
* || ||
|
* || .\ ^ Border Top ^ . ||
|
||||||
* || ||
|
* || . \_ rect(0,0) . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* || < Border Left ||
|
* || . . ||
|
||||||
* || Border Right > ||
|
* || . . ||
|
||||||
* || ||
|
* || . < Border Left . ||
|
||||||
* || ||
|
* || . + Margin Border Right >. ||
|
||||||
* || ||
|
* || . + Margin . ||
|
||||||
* || ||
|
* || . . ||
|
||||||
* |+---------------------------------------------+|
|
* || . . ||
|
||||||
* +-----------------------------------------------+
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || . . ||
|
||||||
|
* || .................................................... ||
|
||||||
|
* |+------------------------------------------------------+|
|
||||||
|
* +--------------------------------------------------------+
|
||||||
* ^ Border Bottom ^
|
* ^ Border Bottom ^
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ug_style_t *s = ctx->style_px;
|
const ug_style_t *s = ctx->style_px;
|
||||||
int bl = s->cnt.border.l.size.i;
|
int bl = s->cnt.border.l.size.i + s->cnt.margin.size.i;
|
||||||
int br = s->cnt.border.r.size.i;
|
int br = s->cnt.border.r.size.i + s->cnt.margin.size.i;
|
||||||
int bt = s->cnt.border.t.size.i;
|
int bt = s->cnt.border.t.size.i + s->cnt.margin.size.i;
|
||||||
int bb = s->cnt.border.b.size.i;
|
int bb = s->cnt.border.b.size.i + s->cnt.margin.size.i;
|
||||||
int hh = s->cnt.titlebar.height.size.i;
|
int hh = s->cnt.titlebar.height.size.i;
|
||||||
int cx = ctx->origin.x;
|
int cx = ctx->origin.x;
|
||||||
int cy = ctx->origin.y;
|
int cy = ctx->origin.y;
|
||||||
@ -496,10 +508,10 @@ static int handle_container(ug_ctx_t *ctx, ug_container_t *cnt)
|
|||||||
rca = &cnt->rca;
|
rca = &cnt->rca;
|
||||||
|
|
||||||
const ug_style_t *s = ctx->style_px;
|
const ug_style_t *s = ctx->style_px;
|
||||||
int bl = s->cnt.border.l.size.i;
|
int bl = s->cnt.border.l.size.i + s->cnt.margin.size.i;
|
||||||
int br = s->cnt.border.r.size.i;
|
int br = s->cnt.border.r.size.i + s->cnt.margin.size.i;
|
||||||
int bt = s->cnt.border.t.size.i;
|
int bt = s->cnt.border.t.size.i + s->cnt.margin.size.i;
|
||||||
int bb = s->cnt.border.b.size.i;
|
int bb = s->cnt.border.b.size.i + s->cnt.margin.size.i;
|
||||||
int hh = s->cnt.titlebar.height.size.i;
|
int hh = s->cnt.titlebar.height.size.i;
|
||||||
|
|
||||||
ug_vec2_t mpos = ctx->mouse.pos;
|
ug_vec2_t mpos = ctx->mouse.pos;
|
||||||
|
5
ugui.h
5
ugui.h
@ -74,6 +74,7 @@ typedef struct {
|
|||||||
ug_size_t t, b, l, r;
|
ug_size_t t, b, l, r;
|
||||||
ug_color_t color;
|
ug_color_t color;
|
||||||
} border;
|
} border;
|
||||||
|
ug_size_t margin;
|
||||||
// titlebar only gets applied to movable containers
|
// titlebar only gets applied to movable containers
|
||||||
struct {
|
struct {
|
||||||
ug_size_t height;
|
ug_size_t height;
|
||||||
@ -231,6 +232,10 @@ int ug_container_body(ug_ctx_t *ctx, const char *name);
|
|||||||
int ug_container_remove(ug_ctx_t *ctx, const char *name);
|
int ug_container_remove(ug_ctx_t *ctx, const char *name);
|
||||||
|
|
||||||
|
|
||||||
|
// layouts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Input functions
|
// Input functions
|
||||||
int ug_input_mousemove(ug_ctx_t *ctx, int x, int y);
|
int ug_input_mousemove(ug_ctx_t *ctx, int x, int y);
|
||||||
int ug_input_mousedown(ug_ctx_t *ctx, unsigned int mask);
|
int ug_input_mousedown(ug_ctx_t *ctx, unsigned int mask);
|
||||||
|
Loading…
Reference in New Issue
Block a user