- Toolbar pill button redirected to toggleToolbar: action, which passes the click on to Vim (fixes several toolbar bugs reported by Nico) - Tabline separator hide/show code has been fixed

git-svn-id: http://macvim.googlecode.com/svn/trunk@138 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-08-14 18:41:51 +00:00
parent 5e9bd1011d
commit 830ba6f4e2
5 changed files with 104 additions and 44 deletions
+29
View File
@@ -874,6 +874,35 @@ static int specialKeyToNSKey(int key);
if (menu) {
gui_menu_cb(menu);
}
} else if (ToggleToolbarMsgID == msgid) {
char_u go[sizeof(GO_ALL)+2];
char_u *p;
int len;
STRCPY(go, p_go);
p = vim_strchr(go, GO_TOOLBAR);
len = STRLEN(go);
if (p != NULL) {
char_u *end = go + len;
while (p < end) {
p[0] = p[1];
++p;
}
} else {
go[len] = GO_TOOLBAR;
go[len+1] = NUL;
}
set_option_value((char_u*)"guioptions", 0, go, 0);
// Force screen redraw (does it have to be this complicated?).
redraw_all_later(CLEAR);
update_screen(NOT_VALID);
setcursor();
out_flush();
gui_update_cursor(FALSE, FALSE);
gui_mch_flush();
} else if (ScrollbarEventMsgID == msgid) {
if (!data) return;
const void *bytes = [data bytes];
+14 -6
View File
@@ -306,10 +306,10 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
[windowController updateTabsWithData:data];
} else if (ShowTabBarMsgID == msgid) {
//NSLog(@"Showing tab bar");
[windowController showTabBar:self];
[windowController showTabBar:YES];
} else if (HideTabBarMsgID == msgid) {
//NSLog(@"Hiding tab bar");
[windowController hideTabBar:self];
[windowController showTabBar:NO];
} else if (SetTextDimensionsMsgID == msgid) {
const void *bytes = [data bytes];
int rows = *((int*)bytes); bytes += sizeof(int);
@@ -409,7 +409,17 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
[toolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[toolbar setSizeMode:NSToolbarSizeModeSmall];
[[windowController window] setToolbar:toolbar];
NSWindow *win = [windowController window];
[win setToolbar:toolbar];
// HACK! Redirect the pill button so that we can ask Vim to
// hide the toolbar.
NSButton *pillButton = [win
standardWindowButton:NSWindowToolbarButton];
if (pillButton) {
[pillButton setAction:@selector(toggleToolbar:)];
[pillButton setTarget:windowController];
}
}
} else if (title) {
[self addMenuWithTag:tag parent:parentTag title:title atIndex:idx];
@@ -518,9 +528,7 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
int size = flags & ToolbarSizeRegularFlag ? NSToolbarSizeModeRegular
: NSToolbarSizeModeSmall;
[toolbar setSizeMode:size];
[toolbar setDisplayMode:mode];
[toolbar setVisible:enable];
[windowController showToolbar:enable size:size mode:mode];
} else if (CreateScrollbarMsgID == msgid) {
const void *bytes = [data bytes];
long ident = *((long*)bytes); bytes += sizeof(long);
+3 -2
View File
@@ -56,10 +56,11 @@
- (void)setFont:(NSFont *)font;
- (void)processCommandQueueDidFinish;
- (void)popupMenu:(NSMenu *)menu atRow:(int)row column:(int)col;
- (void)showTabBar:(BOOL)on;
- (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode;
- (IBAction)addNewTab:(id)sender;
- (IBAction)showTabBar:(id)sender;
- (IBAction)hideTabBar:(id)sender;
- (IBAction)toggleToolbar:(id)sender;
@end
+57 -36
View File
@@ -169,6 +169,8 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
- (void)windowDidLoad
{
NSWindow *win = [self window];
// Called after window nib file is loaded.
[tablineSeparator setHidden:NO];
@@ -200,12 +202,12 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
addObserver:vimController
selector:@selector(windowWillClose:)
name:NSWindowWillCloseNotification
object:[self window]];
object:win];
[[NSNotificationCenter defaultCenter]
addObserver:vimController
selector:@selector(windowDidBecomeMain:)
name:NSWindowDidBecomeMainNotification
object:[self window]];
object:win];
}
- (MMVimController *)vimController
@@ -482,49 +484,66 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
[NSMenu popUpContextMenu:menu withEvent:event forView:textView];
}
- (void)showTabBar:(BOOL)on
{
[tabBarControl setHidden:!on];
if (!on) {
NSToolbar *toolbar = [[self window] toolbar];
[tablineSeparator setHidden:![toolbar isVisible]];
} else {
[tablineSeparator setHidden:on];
}
if (setupDone)
shouldUpdateWindowSize = YES;
}
- (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode
{
NSToolbar *toolbar = [[self window] toolbar];
if (!toolbar) return;
[toolbar setSizeMode:size];
[toolbar setDisplayMode:mode];
[toolbar setVisible:on];
if (!on) {
[tablineSeparator setHidden:YES];
} else {
[tablineSeparator setHidden:![tabBarControl isHidden]];
}
}
- (IBAction)addNewTab:(id)sender
{
// NOTE! This can get called a lot if the user holds down the key
// equivalent for this action, which causes the ports to fill up. If we
// wait for the message to be sent then the app might become unresponsive.
[vimController sendMessage:AddNewTabMsgID data:nil wait:NO];
// NOTE! This can get called a lot if the user holds down the key
// equivalent for this action, which causes the ports to fill up. If we
// wait for the message to be sent then the app might become unresponsive.
[vimController sendMessage:AddNewTabMsgID data:nil wait:NO];
}
- (IBAction)showTabBar:(id)sender
- (IBAction)toggleToolbar:(id)sender
{
[tablineSeparator setHidden:YES];
[tabBarControl setHidden:NO];
if (setupDone)
shouldUpdateWindowSize = YES;
[vimController sendMessage:ToggleToolbarMsgID data:nil wait:NO];
}
- (IBAction)hideTabBar:(id)sender
{
[tablineSeparator setHidden:NO];
[tabBarControl setHidden:YES];
if (setupDone)
shouldUpdateWindowSize = YES;
}
// -- PSMTabBarControl delegate ----------------------------------------------
- (void)tabView:(NSTabView *)theTabView didSelectTabViewItem:
(NSTabViewItem *)tabViewItem
(NSTabViewItem *)tabViewItem
{
// HACK! There seem to be a bug in NSTextView which results in the first
// responder not being set to the view of the tab item so it is done
// manually here.
[[self window] makeFirstResponder:[tabViewItem view]];
// HACK! There seem to be a bug in NSTextView which results in the first
// responder not being set to the view of the tab item so it is done
// manually here.
[[self window] makeFirstResponder:[tabViewItem view]];
// HACK! The selection message should not be propagated to the VimTask if
// the VimTask selected the tab (e.g. as opposed the user clicking the
// tab). The delegate method has no way of knowing who initiated the
// HACK! The selection message should not be propagated to the VimTask if
// the VimTask selected the tab (e.g. as opposed the user clicking the
// tab). The delegate method has no way of knowing who initiated the
// selection so a flag is set when the VimTask initiated the selection.
if (!vimTaskSelectedTab) {
// Propagate the selection message to the VimTask.
@@ -688,9 +707,10 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
size.width += [textView textContainerOrigin].x + right;
size.height += [textView textContainerOrigin].y + bot;
// A one pixel high separator is shown if tabline is hidden.
if ([tabBarControl isHidden]) ++size.height;
else size.height += [tabBarControl frame].size.height;
if (![tablineSeparator isHidden])
++size.height;
if (![tabBarControl isHidden])
size.height += [tabBarControl frame].size.height;
if (![ud boolForKey:MMStatuslineOffKey])
size.height += StatusLineHeight;
@@ -709,9 +729,10 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
{
NSRect rect = { 0, 0, contentSize.width, contentSize.height };
// A one pixel high separator is shown if tabline is hidden.
if ([tabBarControl isHidden]) --rect.size.height;
else rect.size.height -= [tabBarControl frame].size.height;
if (![tablineSeparator isHidden])
--rect.size.height;
if (![tabBarControl isHidden])
rect.size.height -= [tabBarControl frame].size.height;
if (![[NSUserDefaults standardUserDefaults]
boolForKey:MMStatuslineOffKey]) {
+1
View File
@@ -92,6 +92,7 @@ enum {
EnableMenuItemMsgID,
ExecuteMenuMsgID,
ShowToolbarMsgID,
ToggleToolbarMsgID,
CreateScrollbarMsgID,
DestroyScrollbarMsgID,
ShowScrollbarMsgID,