summaryrefslogtreecommitdiff
path: root/alf/alflayout.h
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-16 18:17:56 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-04-16 18:17:56 +0200
commit536ea04c34ba761d7031eeabb6d50adab0f0f2bd (patch)
tree7def1b680705497636c2f5e5649c0ffeb477539c /alf/alflayout.h
parent5cbb664bd49cd2b9c035ccfc3024aa436d28c36c (diff)
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
Diffstat (limited to 'alf/alflayout.h')
-rw-r--r--alf/alflayout.h49
1 files changed, 29 insertions, 20 deletions
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);