diff --git a/macosx/GroupsPrefsController.h b/macosx/GroupsPrefsController.h index 7838abf76..dc4277a29 100644 --- a/macosx/GroupsPrefsController.h +++ b/macosx/GroupsPrefsController.h @@ -39,6 +39,8 @@ IBOutlet NSWindow * fGroupRulesSheetWindow; IBOutlet NSPredicateEditor * fRuleEditor; + + IBOutlet NSLayoutConstraint * fRuleEditorHeightConstraint; } - (void) addRemoveGroup: (id) sender; diff --git a/macosx/GroupsPrefsController.m b/macosx/GroupsPrefsController.m index a5bc2916a..6103ec171 100644 --- a/macosx/GroupsPrefsController.m +++ b/macosx/GroupsPrefsController.m @@ -299,12 +299,16 @@ - (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 diff --git a/macosx/da.lproj/GroupRules.xib b/macosx/da.lproj/GroupRules.xib index 29f7a84d3..ab50c81b9 100644 --- a/macosx/da.lproj/GroupRules.xib +++ b/macosx/da.lproj/GroupRules.xib @@ -9,6 +9,7 @@ + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - + @@ -187,7 +188,7 @@ Gw - +