Nicer button for local history, fading history view, more readable blue for active item

svn path=/trunk/netsurf/; revision=11481
This commit is contained in:
Sven Weidauer 2011-01-25 09:53:39 +00:00
parent 7ff51a93d5
commit 15e7b87cac
8 changed files with 85 additions and 87 deletions

View File

@ -42,10 +42,10 @@
@property (readwrite, assign, nonatomic) struct browser_window *browser;
@property (readwrite, retain, nonatomic) NSTimer *caretTimer;
@property (readwrite, assign, nonatomic, getter=isResizing) BOOL resizing;
@property (readwrite, assign, nonatomic, getter=isHistoryVisible) BOOL historyVisible;
- (void) removeCaret;
- (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
- (void) toggleHistory;
@end

View File

@ -28,10 +28,6 @@
#import "cocoa/font.h"
@interface BrowserView () <HistoryViewDelegate>
@end
@implementation BrowserView
@ -182,7 +178,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
- (void) mouseUp: (NSEvent *)theEvent;
{
if (historyVisible) {
[self toggleHistory];
[self setHistoryVisible: NO];
return;
}
@ -339,29 +335,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_key_press( browser, KEY_PASTE );
}
- (void) toggleHistory;
{
if (!historyVisible) {
if (nil == history) {
history = [[HistoryView alloc] initWithBrowser: browser];
[history setDelegate: self];
}
[self addSubview: history];
historyVisible = YES;
} else {
[history removeFromSuperview];
historyVisible = NO;
}
}
- (void) historyViewDidSelectItem: (HistoryView *) history;
{
[history removeFromSuperview];
historyVisible = NO;
}
- (BOOL) acceptsFirstResponder;
{
return YES;
@ -377,4 +350,22 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
[super adjustFrame];
}
- (BOOL) isHistoryVisible;
{
return historyVisible;
}
- (void) setHistoryVisible: (BOOL) newVisible;
{
if (newVisible == historyVisible) return;
historyVisible = newVisible;
if (historyVisible) {
if (nil == history) history = [[HistoryView alloc] initWithBrowser: browser];
[history fadeIntoView: self];
} else {
[history fadeOut];
}
}
@end

View File

@ -151,9 +151,4 @@ static inline bool compare_float( float a, float b )
}
- (IBAction) showHistory: (id) sender;
{
[browserView toggleHistory];
}
@end

View File

@ -20,22 +20,16 @@
@class HistoryView;
@protocol HistoryViewDelegate
- (void) historyViewDidSelectItem: (HistoryView *) history;
@end
@interface HistoryView : NSView {
struct browser_window *browser;
id <HistoryViewDelegate> delegate;
}
@property (readwrite, assign, nonatomic) struct browser_window *browser;
@property (readwrite, assign, nonatomic) id <HistoryViewDelegate> delegate;
- (id) initWithBrowser: (struct browser_window *)bw;
- (void) updateHistory;
- (void) fadeIntoView: (NSView *) superView;
- (void) fadeOut;
@end

View File

@ -33,7 +33,6 @@ static NSRect cocoa_history_rect( struct browser_window *bw )
@implementation HistoryView
@synthesize browser;
@synthesize delegate;
- (id)initWithBrowser: (struct browser_window *)bw;
{
@ -48,30 +47,42 @@ static NSRect cocoa_history_rect( struct browser_window *bw )
- (void) updateHistory;
{
[self setFrameSize: cocoa_history_rect( browser ).size];
NSView *superView = [self superview];
if (nil != superView) {
NSRect visibleRect = [superView visibleRect];
NSRect rect = [self frame];
NSRect frame = [superView frame];
rect.origin.x = visibleRect.origin.x + (NSWidth( visibleRect ) - NSWidth( rect )) / 2.0;
rect.origin.x = MAX( rect.origin.x, frame.origin.x );
rect.origin.y = visibleRect.origin.y + (NSHeight( visibleRect ) - NSHeight( rect )) / 2.0;
rect.origin.y = MAX( rect.origin.y, frame.origin.y );
[self setFrameOrigin: rect.origin];
}
[self setNeedsDisplay: YES];
}
- (void) recenter;
- (void) fadeIntoView: (NSView *) superView;
{
NSView *superView = [self superview];
NSRect visibleRect = [superView visibleRect];
NSRect rect = [self frame];
NSRect frame = [superView frame];
rect.origin.x = visibleRect.origin.x + (NSWidth( visibleRect ) - NSWidth( rect )) / 2.0;
rect.origin.x = MAX( rect.origin.x, frame.origin.x );
rect.origin.y = visibleRect.origin.y + (NSHeight( visibleRect ) - NSHeight( rect )) / 2.0;
rect.origin.y = MAX( rect.origin.y, frame.origin.y );
[self setFrameOrigin: rect.origin];
[self setAlphaValue: 0];
[superView addSubview: self];
[[self animator] setAlphaValue: 1.0];
}
- (void) fadeOut;
{
[[self animator] setAlphaValue: 0.0];
[self performSelector: @selector(removeFromSuperview) withObject: nil
afterDelay: [[NSAnimationContext currentContext] duration]];
}
- (void) viewDidMoveToSuperview;
{
[self updateHistory];
[self recenter];
}
- (void) drawRect: (NSRect)rect;
@ -95,9 +106,7 @@ static NSRect cocoa_history_rect( struct browser_window *bw )
{
const NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
const bool newWindow = [theEvent modifierFlags] & NSCommandKeyMask;
if (history_click( browser, browser->history, location.x, location.y, newWindow )) {
[delegate historyViewDidSelectItem: self];
}
history_click( browser, browser->history, location.x, location.y, newWindow );
}
- (BOOL) isFlipped;

View File

@ -7,4 +7,5 @@
#undef offsetof
#define HISTORY_COLOUR_BACKGROUND 0x000000
#define HISTORY_COLOUR_FOREGROUND 0xFFFFFF
#define HISTORY_COLOUR_FOREGROUND 0xFFFFFF
#define HISTORY_COLOUR_SELECTED 0xFF6D27

View File

@ -254,6 +254,7 @@ void gui_window_remove_caret(struct gui_window *g)
void gui_window_new_content(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] setHistoryVisible: NO];
}
bool gui_window_scroll_start(struct gui_window *g)

View File

@ -78,14 +78,12 @@
<string key="NSToolbarItemPaletteLabel">History</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSButton" key="NSToolbarItemView" id="229385913">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{8, 14}, {30, 25}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="296571644">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="770988704">
@ -94,7 +92,7 @@
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="229385913"/>
<int key="NSButtonFlags">-2033958657</int>
<int key="NSButtonFlags">918831359</int>
<int key="NSButtonFlags2">163</int>
<object class="NSCustomResource" key="NSNormalImage" id="235904051">
<string key="NSClassName">NSImage</string>
@ -125,11 +123,9 @@
<string key="NSToolbarItemPaletteLabel">Back/Forward</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSSegmentedControl" key="NSToolbarItemView" id="692457026">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{5, 14}, {71, 25}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSegmentedCell" key="NSCell" id="845979064">
<int key="NSCellFlags">67239424</int>
@ -188,11 +184,9 @@
<string key="NSToolbarItemPaletteLabel">URL</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSTextField" key="NSToolbarItemView" id="77748234">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{0, 14}, {96, 22}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1053649244">
<int key="NSCellFlags">-1804468671</int>
@ -450,6 +444,7 @@
<string>processing</string>
<string>title</string>
<string>isProcessing</string>
<string>browserView.historyVisible</string>
</object>
<string key="NSObjectClassName">BrowserViewController</string>
<bool key="NSEditable">YES</bool>
@ -627,6 +622,22 @@
</object>
<int key="connectionID">78</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: selection.browserView.historyVisible</string>
<reference key="source" ref="296571644"/>
<reference key="destination" ref="177599630"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="296571644"/>
<reference key="NSDestination" ref="177599630"/>
<string key="NSLabel">value: selection.browserView.historyVisible</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">selection.browserView.historyVisible</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">79</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -861,9 +872,9 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{{343, 318}, {774, 554}}</string>
<string>{{276, 318}, {774, 554}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{343, 318}, {774, 554}}</string>
<string>{{276, 318}, {774, 554}}</string>
<integer value="1"/>
<string>{196, 240}</string>
<string>{{202, 428}, {480, 270}}</string>
@ -920,7 +931,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">78</int>
<int key="maxID">79</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -928,17 +939,6 @@
<object class="IBPartialClassDescription">
<string key="className">BrowserView</string>
<string key="superclassName">ScrollableView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showHistory:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showHistory:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">showHistory:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BrowserView.h</string>
@ -956,6 +956,7 @@
<string>goForward:</string>
<string>navigate:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
<string>stopLoading:</string>
<string>zoomIn:</string>
<string>zoomOriginal:</string>
@ -972,6 +973,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@ -983,6 +985,7 @@
<string>goForward:</string>
<string>navigate:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
<string>stopLoading:</string>
<string>zoomIn:</string>
<string>zoomOriginal:</string>
@ -1010,6 +1013,10 @@
<string key="name">reloadPage:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showHistory:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">stopLoading:</string>
<string key="candidateClassName">id</string>