From e3f822a003c6d48c7b8ab3d2ad11edfa698e39f0 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 12 May 2016 20:18:22 -0400 Subject: [PATCH] Jiggled uiTab and uiGroup back to functioning properly when initially laid out. --- darwin/autolayout.m | 8 ++++++++ darwin/box.m | 2 +- darwin/group.m | 2 ++ darwin/tab.m | 2 ++ darwin/uipriv_darwin.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/darwin/autolayout.m b/darwin/autolayout.m index a5db3945..6f98faaf 100644 --- a/darwin/autolayout.m +++ b/darwin/autolayout.m @@ -18,6 +18,14 @@ NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRela return constraint; } +// 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 too, possibly others! +void jiggleViewLayout(NSView *view) +{ + [view setNeedsLayout:YES]; + [view layoutSubtreeIfNeeded]; +} + static CGFloat margins(int margined) { if (!margined) diff --git a/darwin/box.m b/darwin/box.m index 62f53e49..ece63679 100644 --- a/darwin/box.m +++ b/darwin/box.m @@ -2,7 +2,7 @@ #import "uipriv_darwin.h" // TODOs: -// - tab on page 2 is glitched initially and doesn't grow +// - tab on page 2 doesn't grow (groupbox does instead) // - page 3 doesn't work right; probably due to our shouldExpand logic being applied incorrectly // TODOs to confirm diff --git a/darwin/group.m b/darwin/group.m index 5c3bc63a..fd6e65e9 100644 --- a/darwin/group.m +++ b/darwin/group.m @@ -70,6 +70,8 @@ static void groupRelayout(uiGroup *g) uiDarwinControlHugsBottom(uiDarwinControl(g->child)), g->margined, @"uiGroup"); + // needed for some very rare drawing errors... + jiggleViewLayout(g->box); } // TODO rename these since I'm starting to get confused by what they mean by hugging diff --git a/darwin/tab.m b/darwin/tab.m index fb3a42bd..325099a3 100644 --- a/darwin/tab.m +++ b/darwin/tab.m @@ -124,6 +124,8 @@ static void tabRelayout(uiTab *t) for (page in t->pages) [page establishChildConstraints]; + // and this gets rid of some weird issues with regards to box alignment + jiggleViewLayout(t->tabview); } BOOL uiTabHugsTrailingEdge(uiDarwinControl *c) diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 5d1100b2..d2cd7da1 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -57,6 +57,7 @@ extern void uninitAlloc(void); // autolayout.m extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc); +extern void jiggleViewLayout(NSView *view); struct singleChildConstraints { NSLayoutConstraint *leadingConstraint; NSLayoutConstraint *topConstraint;