From 536ea04c34ba761d7031eeabb6d50adab0f0f2bd Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Thu, 16 Apr 2020 18:17:56 +0200 Subject: rework grid layout Fractional expand is now supported like Qt, and also per row/column instead of as a widget attribute. Instead of margins, you're now supposed to use empty rows/columns instead. Spacer is also gone, use empty rows/columns with minimum size. Layout engine is prepared to directly calculate edit, button, etc. sizes without subclassing these controls --- alf/alflayout.h | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'alf/alflayout.h') diff --git a/alf/alflayout.h b/alf/alflayout.h index e326490..10fa09d 100644 --- a/alf/alflayout.h +++ b/alf/alflayout.h @@ -6,22 +6,35 @@ typedef struct { ALFListHeader list; HWND hwnd; - UINT x; - UINT y; - UINT cptWidth; - UINT cptHeight; - UINT cptMarginTop; - UINT cptMarginRight; - UINT cptMarginBottom; - UINT cptMarginLeft; + int x; + int y; + int width; + int height; DWORD flags; } ALFWidgetPriv; typedef struct { - int minWidth; + HWND hwnd; + int x; + int y; + int width; + int height; + DWORD flags; +} ALFAddWidgetParams; + +typedef struct { + // properties set by user + int requestedMinWidth; + int requestedExpandNumerator; + int requestedFlags; + + // calculated properties + int calculatedMinWidth; + int calculatedExpandNumerator; + + // allocated size for layout application int allocatedWidth; int allocatedPosition; - int expand : 1; } ALFLayoutRowOrColumn; #define ALF_LAYOUT_NEED_RECALC ((DWORD)1) @@ -35,8 +48,10 @@ typedef struct { int nRows; int totalMinWidth; int totalMinHeight; - int expandoColumnCount; - int expandoRowCount; + int columnExpandDenominator; + int rowExpandDenominator; + int biggestColumnNo; + int biggestRowNo; DWORD layoutValididityFlags; } ALFLayout; @@ -53,22 +68,16 @@ void ALF_Layout_Apply(ALFLayout *layout, HWND window); void -ALF_Layout_AddWidget(ALFLayout *layout, HWND window, const ALFWidgetLayoutParams *params); +ALF_Layout_AddWidget(ALFLayout *layout, HWND window, const ALFAddWidgetParams *params); BOOL ALF_Layout_RemoveWidget(ALFLayout *layout, HWND window, HWND widget, BOOL destroy); -BOOL -ALF_Layout_SetWidgetParams(ALFLayout *layout, HWND window, const ALFWidgetLayoutParams *params, HWND widget); - -BOOL -ALF_Layout_GetWidgetParams(ALFLayout *layout, ALFWidgetLayoutParams *params, HWND widget); - BOOL ALF_Layout_HandleMessage(ALFLayout *layout, HWND window, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *ret); HWND -ALF_Layout_WidgetAtPos(ALFLayout *layout, UINT x, UINT y); +ALF_Layout_WidgetAtPos(ALFLayout *layout, int x, int y); void ALF_Layout_Invalidate(ALFLayout *layout, HWND window); -- cgit v1.2.3