From 834cc1229993597b5a90710c796d0828d312b490 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 26 May 2016 21:25:32 -0400 Subject: [PATCH] Named the margins and padding. Made them functions that can take parameters in the future to allow more complex spacing options in the future. --- README.md | 3 +++ darwin/autolayout.m | 12 +++++++++++- darwin/box.m | 2 +- ui_darwin.h | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fabcc379..f7d98762 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ This README is being written.
*Note that today's entry may be updated later today.* +* **26 May 2016** + * Two OS X-specific functions have been added: `uiDarwinMarginAmount()` and `uiDarwinPaddingAmount()`. These return the amount of margins and padding, respectively, to give to a control, and are intended for container implementations. These are suitable for the constant of a NSLayoutConstraint. They both take a pointer parameter that is reserved for future use and should be `NULL`. + * **25 May 2016** * uiDrawTextLayout attributes are now specified in units of *graphemes* on all platforms. This means characters as seen from a user's perspective, not Unicode codepoints or UTF-8 bytes. So a long string of combining marker codepoints after one codepoint would still count as one grapheme. diff --git a/darwin/autolayout.m b/darwin/autolayout.m index 81530e75..99f71130 100644 --- a/darwin/autolayout.m +++ b/darwin/autolayout.m @@ -18,6 +18,16 @@ NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRela return constraint; } +CGFloat uiDarwinMarginAmount(void *reserved) +{ + return 20.0; +} + +CGFloat uiDarwinPaddingAmount(void *reserved) +{ + return 8.0; +} + // this is needed for NSSplitView to work properly; see http://stackoverflow.com/questions/34574478/how-can-i-set-the-position-of-a-nssplitview-nowadays-setpositionofdivideratind (stal in irc.freenode.net/#macdev came up with the exact combination) // turns out it also works on NSTabView and NSBox too, possibly others! // and for bonus points, it even seems to fix unsatisfiable-constraint-autoresizing-mask issues with NSTabView and NSBox too!!! this is nuts @@ -31,7 +41,7 @@ static CGFloat margins(int margined) { if (!margined) return 0.0; - return 20.0; // TODO named constant + return uiDarwinMarginAmount(NULL); } void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc) diff --git a/darwin/box.m b/darwin/box.m index a5cf41b0..7e480285 100644 --- a/darwin/box.m +++ b/darwin/box.m @@ -147,7 +147,7 @@ struct uiBox { { if (!self->padded) return 0.0; - return 8.0; // TODO named constant + return uiDarwinPaddingAmount(NULL); } // TODO something about spinbox hugging diff --git a/ui_darwin.h b/ui_darwin.h index 387e6829..a9b49cba 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -200,6 +200,10 @@ _UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL); // TODO document _UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *); +// TODO document +_UI_EXTERN CGFloat uiDarwinMarginAmount(void *reserved); +_UI_EXTERN CGFloat uiDarwinPaddingAmount(void *reserved); + #ifdef __cplusplus } #endif