Auto-layout: Update file browser and HTML output

This commit is contained in:
Allan Odgaard
2012-09-14 12:41:14 +02:00
parent 4d95db8f66
commit 2b9c27263d
3 changed files with 20 additions and 17 deletions

View File

@@ -5,6 +5,11 @@
@implementation HOBrowserView
@synthesize webView;
+ (BOOL)requiresConstraintBasedLayout
{
return YES;
}
- (NSSize)intrinsicContentSize
{
return NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
@@ -14,16 +19,11 @@
{
if(self = [super initWithFrame:frame])
{
NSRect webViewFrame = NSMakeRect(0, OakStatusBarHeight, NSWidth(frame), NSHeight(frame) - OakStatusBarHeight);
NSRect statusBarFrame = NSMakeRect(0, 0, NSWidth(frame), OakStatusBarHeight);
webView = [[WebView alloc] initWithFrame:webViewFrame];
webView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
webView = [[WebView alloc] initWithFrame:NSZeroRect];
[self addSubview:webView];
statusBar = [[HOStatusBar alloc] initWithFrame:statusBarFrame];
statusBar.autoresizingMask = NSViewWidthSizable;
statusBar.delegate = webView;
statusBar = [[HOStatusBar alloc] initWithFrame:NSZeroRect];
statusBar.delegate = webView;
[self addSubview:statusBar];
webViewDelegateHelper = [HOWebViewDelegateHelper new];
@@ -32,6 +32,12 @@
webView.resourceLoadDelegate = webViewDelegateHelper;
webView.UIDelegate = webViewDelegateHelper;
webView.frameLoadDelegate = self;
NSDictionary* views = NSDictionaryOfVariableBindings(webView, statusBar);
for(id key in views)
[views[key] setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[webView(==statusBar)]|" options:NSLayoutFormatAlignAllTop metrics:nil views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[webView][statusBar]|" options:NSLayoutFormatAlignAllLeading metrics:nil views:views]];
}
return self;
}

View File

@@ -733,7 +733,6 @@ static bool is_binary (std::string const& path)
- (void)setupViewWithSize:(NSSize)viewSize resizeIndicatorOnRight:(BOOL)flag state:(NSDictionary*)fileBrowserState
{
self.view = [[[OakFileBrowserView alloc] initWithFrame:(NSRect){ NSZeroPoint, viewSize }] autorelease];
view.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
[view setShowsResizeIndicator:YES onRight:flag];
historyController.state = fileBrowserState;
if(!historyController.currentURL)

View File

@@ -71,6 +71,12 @@ OAK_DEBUG_VAR(FileBrowser_View);
[outlineView addTableColumn:tableColumn];
[outlineView setOutlineTableColumn:tableColumn];
[outlineView sizeLastColumnToFit];
NSDictionary* views = NSDictionaryOfVariableBindings(headerView, scrollView);
for(id key in views)
[views[key] setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[headerView(==scrollView)]|" options:0 metrics:nil views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[headerView][scrollView]|" options:0 metrics:nil views:views]];
}
// ========
@@ -96,14 +102,6 @@ OAK_DEBUG_VAR(FileBrowser_View);
[super setNextResponder:self.persistentNextResponder];
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize
{
headerView.frame = NSMakeRect(0, NSHeight(self.frame) - OakStatusBarHeight, NSWidth(self.frame), OakStatusBarHeight);
outlineView.enclosingScrollView.frame = NSMakeRect(0, 0, NSWidth(self.frame), NSHeight(self.frame) - NSHeight(headerView.frame));
[[NSUserDefaults standardUserDefaults] setInteger:NSWidth(self.frame) forKey:kUserDefaultsFileBrowserWidthKey];
}
- (BOOL)isOpaque
{
return YES;