layout2.h
The declarative solver underneath every box. It is a flexbox for one dimensional runs and a css inspired grid for two.
#include "isolenui/ui/layout2.h". The guide starts at Flexbox.
Rounded clips
Explained in Raw layout.
lay_masklay_clip_masklay_style::roundlay_style::insetlay_node::maskSizes
Explained in Sizing and minimums.
lay_boxlay_kindlay_kind_fitlay_kind_pxlay_kind_growlay_kind_pctlay_sizelay_fitlay_pxlay_growlay_pctlay_minlay_maxlay_clampISOLEN_LAY_UNBOUNDEDISOLEN_LAY_MAX_EXTENTFlexbox
Explained in Flexbox.
lay_dirlay_dir_rowlay_dir_collay_dir_row_revlay_dir_col_revlay_alignlay_align_startlay_align_centrelay_align_endlay_align_stretchlay_align_betweenlay_align_aroundlay_align_evenlylay_align_autolay_wraplay_wrap_nonelay_wrap_onlay_stylelay_rowlay_collay_style chain
Explained in Flexbox.
lay_style::sizelay_style::widthlay_style::heightlay_style::growlay_style::shrinklay_style::flexlay_style::padlay_style::pad_xylay_style::pad4lay_style::spacinglay_style::wrapslay_style::reverselay_style::justifylay_style::itemslay_style::alignlay_style::centrelay_style::align_selflay_style::place_selflay_style::columnlay_style::rowlay_style::spanlay_style::area_oflay_style::arealay_style::clipslay_style::scrolls_xlay_style::scrolls_ylay_style::overflowlay_style::scrollbarGrid
Explained in Grid.
lay_grid_speclay_grid_spec::columnslay_grid_spec::rowslay_grid_spec::areaslay_grid_spec::auto_columnslay_grid_spec::auto_rowslay_grid_spec::gaplay_grid_spec::flowlay_grid_spec::place_itemslay_grid_spec::place_contentlay_breadth_kindlay_br_pxlay_br_pctlay_br_frlay_br_autolay_br_min_contentlay_br_max_contentlay_br_fit_contentlay_breadthlay_tracklay_templatelay_template::addlay_repeatlay_repeat_nonelay_repeat_filllay_repeat_fitlay_arealay_areaslay_line_kindlay_line_autolay_line_atlay_line_spanlay_linelay_flowlay_flow_rowlay_flow_columnlay_lenlay_percentlay_frlay_autolay_min_contentlay_max_contentlay_trlay_minmaxlay_fit_contentlay_trackslay_areas_parselay_namelay_atlay_spanlay_auto_lineISOLEN_LAY_TEMPLATE_MAXISOLEN_LAY_AREAS_MAXISOLEN_LAY_GRIDS_MAXISOLEN_LAY_TRACK_POOLISOLEN_LAY_AREA_POOLISOLEN_LAY_GRID_MINORISOLEN_LAY_GRID_MAJORISOLEN_LAY_UNPLACEDOverflow and scroll bars
Explained in Overflow and views.
lay_overflowlay_overflow_visiblelay_overflow_autolay_overflow_scrolllay_overflow_hiddenlay_bar_stylelay_bar_defaultlay_scroll_infolay_scroll_x_infolay_scroll_y_infoISOLEN_LAY_SCROLL_XISOLEN_LAY_SCROLL_YFloating and shift
Explained in Floating and shift.
lay_style::floatslay_style::shiftlay_style::shift_pctDirection
Explained in Direction and bidi.
lay_directionlay_direction_inheritlay_direction_ltrlay_direction_rtllay_style::directionlay_style::pad_slay_style::pad_elay_style::ltrlay_style::rtllay_style::pad_inlinelay_root_directionlay_rtllay_scroll_info::mirroredVirtualisation
Explained in Virtual lists.
lay_virtuallay_virtualizelay_virtualize_prefixThe raw solver
Explained in Raw layout.
lay_ctxlay_nodelay_grid_reclay_measure_w_fnlay_measure_h_fnlay_beginlay_openlay_closelay_leaflay_grid_openlay_idlay_solvelay_rectlay_clip_rectlay_countlay_hitlay_scopelay_grid_scopelay_open_rootlay_portal_arealay_translateISOLEN_LAY_MAX_NODESISOLEN_LAY_MAX_DEPTHISOLEN_LAY_INVALIDExample
raw_lay.cpp
#include "isolenui/ui/layout2.h"
#include <stdio.h>
// the raw solver underneath ui::ctx, for code that only wants rectangles.
// lay_ctx holds 2048 nodes plus the grid pools, so it lives static
static lay_ctx g_lay;
static float g_scroll_y = 0.0f;
static float row_height(void* user, float width)
{
(void)user;
(void)width;
return 28.0f;
}
static void solve_three_panes(float width, float height, float wheel_y)
{
lay_begin(&g_lay, width, height);
const uint32_t root =
lay_open(&g_lay, lay_row().spacing(8.0f).width(width).height(height));
const uint32_t left = lay_leaf(&g_lay, lay_col().width(240.0f), nullptr,
nullptr, nullptr);
// a raw box scrolls only when it asks to, overflow auto brings up a bar
// once the rows do not fit and scroll_y is the offset it rolls by
lay_style list = lay_col().grow().overflow(lay_overflow_visible, lay_overflow_auto);
list.scroll_y = g_scroll_y;
const uint32_t centre = lay_open(&g_lay, list);
for (uint32_t i = 0; i < 200; ++i) {
lay_leaf(&g_lay, lay_row().height(28.0f), nullptr, row_height, nullptr);
}
lay_close(&g_lay);
const uint32_t right = lay_leaf(&g_lay, lay_col().width(280.0f), nullptr,
nullptr, nullptr);
lay_close(&g_lay);
lay_solve(&g_lay);
// the solve reports how far the list can roll, the caller owns the offset
const lay_scroll_info info = lay_scroll_y_info(&g_lay, centre);
if (info.active) {
g_scroll_y += wheel_y;
g_scroll_y = g_scroll_y < 0.0f ? 0.0f : g_scroll_y;
g_scroll_y = g_scroll_y > info.max_offset ? info.max_offset : g_scroll_y;
}
const lay_box l = lay_rect(&g_lay, left);
const lay_box c = lay_rect(&g_lay, centre);
const lay_box r = lay_rect(&g_lay, right);
printf("left %.0fx%.0f centre %.0fx%.0f right %.0fx%.0f\n", l.w, l.h, c.w,
c.h, r.w, r.h);
printf("thumb at %.0f, %.0f of %.0f px rolled\n", info.thumb.y,
info.offset, info.max_offset);
(void)root;
}