From ba2651ce03a4832c6aea44b28f57f033b70614e9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 9 Aug 2015 00:20:28 -0400 Subject: [PATCH] Fixed other Spinbox issues. Rule for our Box is that both intrinsic dimensions MUST be provided. --- redo/osxaltest/spinbox.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/redo/osxaltest/spinbox.swift b/redo/osxaltest/spinbox.swift index 765b1315..0c4397e7 100644 --- a/redo/osxaltest/spinbox.swift +++ b/redo/osxaltest/spinbox.swift @@ -24,12 +24,21 @@ nspinbox++ cell.scrollable = true self.t.translatesAutoresizingMaskIntoConstraints = false + // make the textbox grow horizontally and vertically + setHorzHuggingPri(self.t, myNSLayoutPriorityDefaultLow) + setVertHuggingPri(self.t, myNSLayoutPriorityDefaultLow) + self.s = NSStepper(frame: NSZeroRect) self.s.increment = 1 self.s.valueWraps = false self.s.autorepeat = true self.s.translatesAutoresizingMaskIntoConstraints = false + // make the spinner grow vertically but not horizontally + // TODO Required instead? + setHorzHuggingPri(self.s, myNSLayoutPriorityDefaultHigh) + setVertHuggingPri(self.s, myNSLayoutPriorityDefaultLow) + self.parent = nil super.init(frame: NSZeroRect) @@ -54,6 +63,7 @@ nspinbox++ } // TODO leave only the required amount of space around the alignment rect + // TODO even with this the stepper sometimes gets cut off at the bottom *anyway* override var alignmentRectInsets: NSEdgeInsets { get { return NSEdgeInsetsMake(50, 50, 50, 50) @@ -69,11 +79,13 @@ nspinbox++ } // TODO justify this - // TODO restrict to the text field only? + // TODO no really, is this height the right way to go? + // TODO restrict width to the text field only? override var intrinsicContentSize: NSSize { get { var s = super.intrinsicContentSize s.width = 96 + s.height = max(self.t.intrinsicContentSize.height, self.s.intrinsicContentSize.height) return s } }