static void twin_clock_set_transform (twin_clock_t *clock, twin_path_t *path) { twin_fixed_t scale; scale = (TWIN_FIXED_ONE - TWIN_CLOCK_BORDER_WIDTH * 3) / 2; twin_path_scale (path, _twin_widget_width (clock) * scale, _twin_widget_height (clock) * scale); twin_path_translate (path, TWIN_FIXED_ONE + TWIN_CLOCK_BORDER_WIDTH * 3, TWIN_FIXED_ONE + TWIN_CLOCK_BORDER_WIDTH * 3); twin_path_rotate (path, -TWIN_ANGLE_90); }
static twin_dispatch_result_t _twin_box_configure (twin_box_t *box) { twin_coord_t width = _twin_widget_width (box); twin_coord_t height = _twin_widget_height (box); twin_coord_t actual; twin_coord_t pref; twin_coord_t delta; twin_coord_t delta_remain; twin_coord_t stretch = 0; twin_coord_t pos = 0; twin_widget_t *child; if (box->dir == TwinBoxHorz) { stretch = box->widget.preferred.stretch_width; actual = width; pref = box->widget.preferred.width; } else { stretch = box->widget.preferred.stretch_height; actual = height; pref = box->widget.preferred.height; } if (!stretch) stretch = 1; delta = delta_remain = actual - pref; for (child = box->children; child; child = child->next) { twin_event_t ev; twin_coord_t stretch_this; twin_coord_t delta_this; twin_rect_t extents; if (!child->next) delta_this = delta_remain; else { if (box->dir == TwinBoxHorz) stretch_this = child->preferred.stretch_width; else stretch_this = child->preferred.stretch_height; delta_this = delta * stretch_this / stretch; } if (delta_remain < 0) { if (delta_this < delta_remain) delta_this = delta_remain; } else { if (delta_this > delta_remain) delta_this = delta_remain; } delta_remain -= delta_this; if (box->dir == TwinBoxHorz) { twin_coord_t child_w = child->preferred.width; extents.top = 0; extents.bottom = height; extents.left = pos; pos = extents.right = pos + child_w + delta_this; } else { twin_coord_t child_h = child->preferred.height; extents.left = 0; extents.right = width; extents.top = pos; pos = extents.bottom = pos + child_h + delta_this; } if (extents.left != ev.u.configure.extents.left || extents.top != ev.u.configure.extents.top || extents.right != ev.u.configure.extents.right || extents.bottom != ev.u.configure.extents.bottom) { ev.kind = TwinEventConfigure; ev.u.configure.extents = extents; (*child->dispatch) (child, &ev); } } return TwinDispatchContinue; }