commit - 16946472422902f8b4a9feb948e6e73d605a6e76
commit + a3b5b286f3bc8991a6fa36dbcadb098b5e4b0be2
blob - a885c16166113b3772919d9d01bf5d3e4f32b7d3
blob + b24b74b8223102c8100367fcaf6aea99fe427e4a
--- aui.h
+++ aui.h
struct aui_packpar {
unsigned char anchor;
- unsigned char expand;
-#define AUI_FILL_NONE 0
-#define AUI_FILL_X 1
-#define AUI_FILL_Y 2
-#define AUI_FILL_BOTH 3
- unsigned char fill;
- int padx[2];
- int pady[2];
#define AUI_SIDE_TOP 1
#define AUI_SIDE_RIGHT 2
#define AUI_SIDE_LEFT 3
blob - 98c86a341a67860a50f01948937df86b56ad35f3
blob + c3835f2fa4c36cfd1df65f0362a1b099240e53c6
--- button.c
+++ button.c
button_set_geometry(struct aui_widget *widget, struct aui_geometry *geom)
{
struct aui_button *button = (struct aui_button *)widget;
- struct aui_geometry fgeom = { .x = geom->x + 1,
- .y = geom->y + 1,
- .width = geom->width - 2,
- .height = geom->height - 2 };
+ struct aui_geometry fgeom = { 0 };
struct aui_geometry tgeom = driver->ops->get_text_geometry(widget->primitives.list[2]);
int tx = geom->x + geom->width / 2 - tgeom.width / 2;
int ty = geom->y + geom->height / 2 + tgeom.height / 2;
+ fgeom.x = geom->x + 1;
+ fgeom.y = geom->y + 1;
+ fgeom.width = geom->width - 2;
+ fgeom.height = geom->height - 2;
+
memcpy(&widget->geom, geom, sizeof(struct aui_geometry));
driver->ops->set_rectangle_geometry(widget->window, widget->primitives.list[0], geom);
driver->ops->set_rectangle_geometry(widget->window, widget->primitives.list[1], &fgeom);
struct aui_geometry geom = driver->ops->get_text_geometry(widget->primitives.list[2]);
struct aui_button *button = (struct aui_button *)widget;
- geom.width = (geom.width < 20) ? geom.width = 20 : geom.width + 20;
+ geom.width = (geom.width < 30) ? geom.width = 30 : geom.width + 30;
geom.height = (button->config.text == NULL) ? 12 + 20 : geom.height + 20;
return geom;
blob - 25f5fe46830eb47cb866b852d54ef82b5163a416
blob + 920984852cc2190f7582bb59cff1b68acc2ee2ea
--- layout.c
+++ layout.c
}
break;
}
+ /*
+ * As far as I'm aware of, Tk's pack is just a rectangle that shrinks
+ * depending on the side of the widget being added.
+ */
case AUI_LAYOUT_PACK: {
- unsigned int cell_size[] = { 50, 50 };
- struct aui_geometry geom = { 0 };
- struct aui_placepar *par = NULL;
- int dx = 0, dy = 0;
+ struct aui_geometry space = widget->in_ops->get_min_size(widget);
TAILQ_FOREACH(child, &widget->queue, entries) {
- geom.height = cell_size[1];
- geom.width = cell_size[0];
- geom.y = dy;
- geom.x = widget->geom.x + widget->geom.width/2 - geom.width / 2;
+ if (child->mapped == 0)
+ continue;
- dy += geom.height;
- child->in_ops->set_geometry(child, &geom);
+ struct aui_geometry cgeom = child->in_ops->get_min_size(child);
+
+ switch (child->packpar.side) {
+ case AUI_SIDE_TOP:
+ cgeom.width = (cgeom.width > space.width) ? space.width : cgeom.width;
+ cgeom.height = (cgeom.height > space.height) ? space.height : cgeom.height;
+ cgeom.x = space.x + space.width / 2 - cgeom.width / 2;
+ cgeom.y = space.y;
+ space.y += cgeom.height;
+ space.height -= cgeom.height;
+ break;
+ case AUI_SIDE_LEFT:
+ cgeom.width = (cgeom.width > space.width) ? space.width : cgeom.width;
+ cgeom.height = (cgeom.height > space.height) ? space.height : cgeom.height;
+ cgeom.x = space.x;
+ cgeom.y = space.y + space.height / 2 - cgeom.height / 2;
+ space.width -= cgeom.width;
+ space.x += cgeom.width;
+ break;
+ case AUI_SIDE_RIGHT:
+ cgeom.width = (cgeom.width > space.width) ? space.width : cgeom.width;
+ cgeom.height = (cgeom.height > space.height) ? space.height : cgeom.height;
+ cgeom.x = space.x + space.width - cgeom.width;
+ cgeom.y = space.y + space.height / 2 - cgeom.height / 2;
+ space.width -= cgeom.width;
+ break;
+ case AUI_SIDE_BOTTOM:
+ cgeom.width = (cgeom.width > space.width) ? space.width : cgeom.width;
+ cgeom.height = (cgeom.height > space.height) ? space.height : cgeom.height;
+ cgeom.x = space.x + space.width / 2 - cgeom.width / 2;
+ cgeom.y = space.y + space.height - cgeom.height;
+ space.height -= cgeom.height;
+ break;
+ default:
+ continue;
+ }
+ child->in_ops->set_geometry(child, &cgeom);
}
TAILQ_FOREACH(child, &widget->queue, entries) {
blob - dfa6125bc9d4bf7473ccbd60eb42299430f7a074
blob + cd3f35f503057c9db280654aa530b7ce9d8072bb
--- ui.c
+++ ui.c
struct aui_event_resize *rze = (struct aui_event_resize *)ev;
struct aui_window *aw = ev->aw;
+ aw->config.width = rze->new_w;
+ aw->config.height = rze->new_h;
+
driver->ops->resize_window(aw);
free((void *)rze);
blob - 6c91aa4e9996a5df3de2272b9a8aff291dd2dc18
blob + 15256c1c92b57321638eae18c58b770b1ddaf469
--- window.c
+++ window.c
static void window_mouse_press(struct aui_widget *, uint16_t, uint16_t, uint8_t);
static void window_mouse_release(struct aui_widget *, uint16_t, uint16_t, uint8_t);
static void window_free(struct aui_widget *);
+static struct aui_geometry window_get_min_size(struct aui_widget *);
static struct widget_ops window_ops = {
window_mouse_hover,
window_mouse_release,
NULL, /* set geomtry */
window_free,
+ window_get_min_size,
};
static struct aui_windowconfig default_config = {
window_mouse_hover(widget, x, y);
}
}
+
+static struct aui_geometry
+window_get_min_size(struct aui_widget *widget)
+{
+ struct aui_window *aw = (struct aui_window *)widget;
+ struct aui_geometry geom = { 0 };
+ geom.width = aw->config.width;
+ geom.height = aw->config.height;
+ return geom;
+}