better color picker

isolation_bkp/dynres
Dominik Madarász 2021-05-15 17:48:15 +02:00
parent 0fdc718e44
commit 8623c18127
4 changed files with 833 additions and 914 deletions

Binary file not shown.

View File

@ -1,138 +1,56 @@
#define PARAM(k,n,v) { .kind = k, .name = n, .str = v }
static td_op default_ops[] = { static td_op default_ops[] = {
{ {
OP(TOP_CLEAR), OP(TOP_CLEAR),
.num_params = 1, .num_params = 1,
.params = (td_param[]) { .params = (td_param[]) {
{ PARAM(TPARAM_COLOR, "color", "ffffffff"),
.kind = TPARAM_COLOR,
.name = "color",
.str = "ffffffff"
}
} }
}, },
{ {
OP(TOP_DRAW_RECT), OP(TOP_DRAW_RECT),
.num_params = 5, .num_params = 5,
.params = (td_param[]) { .params = (td_param[]) {
{ PARAM(TPARAM_INT, "x", "0"),
.kind = TPARAM_INT, PARAM(TPARAM_INT, "y", "0"),
.name = "x", PARAM(TPARAM_INT, "w", "10"),
.str = "0" PARAM(TPARAM_INT, "h", "10"),
}, PARAM(TPARAM_COLOR, "color", "0"),
{
.kind = TPARAM_INT,
.name = "y",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "w",
.str = "10"
},
{
.kind = TPARAM_INT,
.name = "h",
.str = "10"
},
{
.kind = TPARAM_COLOR,
.name = "color",
.str = "ff0000ff"
},
} }
}, },
{ {
OP(TOP_DRAW_LINE), OP(TOP_DRAW_LINE),
.num_params = 5, .num_params = 5,
.params = (td_param[]) { .params = (td_param[]) {
{ PARAM(TPARAM_INT, "x1", "0"),
.kind = TPARAM_INT, PARAM(TPARAM_INT, "y1", "0"),
.name = "x1", PARAM(TPARAM_INT, "x2", "64"),
.str = "0" PARAM(TPARAM_INT, "y2", "64"),
}, PARAM(TPARAM_COLOR, "color", "0"),
{
.kind = TPARAM_INT,
.name = "y1",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "x2",
.str = "64"
},
{
.kind = TPARAM_INT,
.name = "y2",
.str = "64"
},
{
.kind = TPARAM_COLOR,
.name = "color",
.str = "ffff00ff"
},
} }
}, },
{ {
OP(TOP_DITHER), OP(TOP_DITHER),
.num_params = 4, .num_params = 4,
.params = (td_param[]) { .params = (td_param[]) {
{ PARAM(TPARAM_INT, "r_bpp", "8"),
.kind = TPARAM_INT, PARAM(TPARAM_INT, "g_bpp", "8"),
.name = "r_bpp", PARAM(TPARAM_INT, "b_bpp", "8"),
.str = "8", PARAM(TPARAM_INT, "a_bpp", "8"),
},
{
.kind = TPARAM_INT,
.name = "g_bpp",
.str = "8",
},
{
.kind = TPARAM_INT,
.name = "b_bpp",
.str = "8",
},
{
.kind = TPARAM_INT,
.name = "a_bpp",
.str = "8",
},
} }
}, },
{ {
OP(TOP_LOAD_IMAGE), OP(TOP_LOAD_IMAGE),
.num_params = 6, .num_params = 6,
.params = (td_param[]) { .params = (td_param[]) {
{ PARAM(TPARAM_STRING, "src", "art/natives/test.png"),
.kind = TPARAM_STRING, PARAM(TPARAM_INT, "x", "0"),
.name = "src", PARAM(TPARAM_INT, "y", "0"),
.str = "" PARAM(TPARAM_INT, "w", "-1"),
}, PARAM(TPARAM_INT, "h", "-1"),
{ PARAM(TPARAM_COLOR, "tint", "ffffffff"),
.kind = TPARAM_INT,
.name = "x",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "y",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "w",
.str = "-1"
},
{
.kind = TPARAM_INT,
.name = "h",
.str = "-1"
},
{
.kind = TPARAM_COLOR,
.name = "tint",
.str = "ffffffff",
},
} }
} }
}; };

View File

@ -182,13 +182,14 @@ void texed_draw_props_pane(zpl_aabb2 r) {
switch (p->kind) { switch (p->kind) {
case TPARAM_COLOR: { case TPARAM_COLOR: {
if (!p->edit_mode && GuiTextBox(aabb2_ray(tbox_r), p->str, 64, p->edit_mode)) { if (GuiTextBox(aabb2_ray(tbox_r), p->str, 64, p->edit_mode)) {
p->edit_mode = true; p->edit_mode = true;
} }
if (p->edit_mode) { if (p->edit_mode) {
zpl_aabb2 ok_r = zpl_aabb2_cut_left(&tbox_r, 50.0f); zpl_aabb2 extra_r = zpl_aabb2_add_bottom(&tbox_r, prop_height);
p->color = GuiColorPicker(aabb2_ray(tbox_r), p->color); zpl_aabb2 ok_r = zpl_aabb2_cut_left(&extra_r, 50.0f);
p->color = GuiColorPicker(aabb2_ray(extra_r), p->color);
if (GuiButton(aabb2_ray(ok_r), "OK")) { if (GuiButton(aabb2_ray(ok_r), "OK")) {
p->edit_mode = false; p->edit_mode = false;

1612
code/vendors/raygui.h vendored

File diff suppressed because it is too large Load Diff