IBOutlet NSWindow * fGroupRulesSheetWindow;
IBOutlet NSPredicateEditor * fRuleEditor;
+
+ IBOutlet NSLayoutConstraint * fRuleEditorHeightConstraint;
}
- (void) addRemoveGroup: (id) sender;
- (void) ruleEditorRowsDidChange: (NSNotification *) notification
{
- const CGFloat heightDifference = [fRuleEditor numberOfRows] * [fRuleEditor rowHeight] - [fRuleEditor frame].size.height;
- NSRect windowFrame = [fRuleEditor window].frame;
- windowFrame.size.height += heightDifference;
- windowFrame.origin.y -= heightDifference;
+ NSScrollView * ruleEditorScrollView = [fRuleEditor enclosingScrollView];
- [fRuleEditor.window setFrame: windowFrame display: YES animate: YES];
+ const CGFloat rowHeight = [fRuleEditor rowHeight];
+ const CGFloat bordersHeight = [ruleEditorScrollView frame].size.height - [ruleEditorScrollView contentSize].height;
+
+ const CGFloat requiredRowCount = [fRuleEditor numberOfRows];
+ const CGFloat maxVisibleRowCount = (long)((NSHeight([[[fRuleEditor window] screen] visibleFrame]) * 2 / 3) / rowHeight);
+
+ [fRuleEditorHeightConstraint setConstant: MIN(requiredRowCount, maxVisibleRowCount) * rowHeight + bordersHeight];
+ [ruleEditorScrollView setHasVerticalScroller: requiredRowCount > maxVisibleRowCount];
}
@end
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>
<connections>
<outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
<outlet property="fRuleEditor" destination="34" id="56"/>
+ <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
- <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+ <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
<rect key="frame" x="-100" y="-100" width="360" height="15"/>