Merge pull request #1056 from ychin/add-titlebar-hidden-pref-panel

Add new appearance option for hiding title bar
This commit is contained in:
Yee Cheng Chin
2020-07-06 03:40:52 -07:00
committed by GitHub
6 changed files with 57 additions and 23 deletions
+22 -6
View File
@@ -227,11 +227,11 @@
<point key="canvasLocation" x="137.5" y="382"/>
</customView>
<customView id="hr4-G4-3ZG" userLabel="Appearance">
<rect key="frame" x="0.0" y="0.0" width="483" height="224"/>
<rect key="frame" x="0.0" y="0.0" width="483" height="244"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fw0-VK-Nbz" userLabel="Dark mode selection">
<rect key="frame" x="19" y="46" width="433" height="156"/>
<rect key="frame" x="19" y="66" width="433" height="156"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T40-Os-PUf" userLabel="Dark mode selection">
@@ -292,11 +292,11 @@
</subviews>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7af-iK-4r7" userLabel="Titlebar appearance">
<rect key="frame" x="19" y="20" width="433" height="18"/>
<rect key="frame" x="19" y="20" width="433" height="38"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7ie-0J-0Zr" userLabel="Auto-install updates">
<rect key="frame" x="189" y="-1" width="244" height="18"/>
<rect key="frame" x="189" y="19" width="244" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<string key="toolTip">MacVim will automatically download and install updates without prompting. The updated version will be used the next time MacVim starts.</string>
<buttonCell key="cell" type="check" title="Transparent" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="hzd-hj-Pth">
@@ -312,7 +312,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9Rk-gT-kVC" userLabel="Titlebar appearance">
<rect key="frame" x="-2" y="0.0" width="187" height="17"/>
<rect key="frame" x="-2" y="20" width="187" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Titlebar appearance:" id="HEH-Lo-v4I" userLabel="Titlebar appearance:">
<font key="font" metaFont="system"/>
@@ -320,10 +320,26 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hqh-Ql-2od">
<rect key="frame" x="189" y="1" width="244" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<string key="toolTip">MacVim will automatically download and install updates without prompting. The updated version will be used the next time MacVim starts.</string>
<buttonCell key="cell" type="check" title="Hidden" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="W40-cB-m1U">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<connections>
<binding destination="58" name="enabled" keyPath="values.SUCheckAtStartup" id="c7R-qa-q9c"/>
</connections>
</buttonCell>
<connections>
<action selector="appearanceChanged:" target="-2" id="WQA-OC-F4I"/>
<binding destination="58" name="value" keyPath="values.MMNoTitleBarWindow" id="CKL-mo-ZhZ"/>
</connections>
</button>
</subviews>
</customView>
</subviews>
<point key="canvasLocation" x="137.5" y="384"/>
<point key="canvasLocation" x="137.5" y="394"/>
</customView>
<customView id="620" userLabel="Advanced">
<rect key="frame" x="0.0" y="0.0" width="483" height="318"/>
Binary file not shown.
+2
View File
@@ -191,6 +191,8 @@ enum {
// we have to do it manually.
[NSApp changeWindowsItem:self title:[target title] filename:NO];
}
[self setAppearance:target.appearance];
[self setOpaque:[target isOpaque]];
+1 -5
View File
@@ -686,11 +686,7 @@ static BOOL isUnsafeMessage(int msgid);
NSString *string = [[NSString alloc] initWithBytes:(void*)bytes
length:len encoding:NSUTF8StringEncoding];
// While in live resize the window title displays the dimensions of the
// window so don't clobber this with a spurious "set title" message
// from Vim.
if (![[windowController vimView] inLiveResize])
[windowController setTitle:string];
[windowController setTitle:string];
[string release];
} else if (SetDocumentFilenameMsgID == msgid) {
+1
View File
@@ -75,6 +75,7 @@
- (void)setScrollbarThumbValue:(float)val proportion:(float)prop
identifier:(int32_t)ident;
- (unsigned int)calculateStyleMask;
- (void)setBackgroundOption:(int)dark;
- (void)refreshApperanceMode;
+31 -12
View File
@@ -477,6 +477,17 @@
- (void)setTitle:(NSString *)title
{
// Save the original title, if we haven't already.
[lastSetTitle release];
lastSetTitle = [title retain];
// While in live resize the window title displays the dimensions of the
// window so don't clobber this with the new title. We have already set
// lastSetTitle above so once live resize is done we will set it back.
if ([vimView inLiveResize]) {
return;
}
if (!title)
return;
@@ -579,29 +590,41 @@
// Transparent title bar setting
decoratedWindow.titlebarAppearsTransparent = [[NSUserDefaults standardUserDefaults]
boolForKey:MMTitlebarAppearsTransparentKey];
// No title bar setting
if ([[NSUserDefaults standardUserDefaults]
boolForKey:MMNoTitleBarWindowKey]) {
[decoratedWindow setStyleMask:([decoratedWindow styleMask] & ~NSWindowStyleMaskTitled)];
} else {
[decoratedWindow setStyleMask:([decoratedWindow styleMask] | NSWindowStyleMaskTitled)];
}
// Title may have been lost if we hid the title-bar. Reset it.
[self setTitle:lastSetTitle];
// Dark mode only works on 10.14+ because that's when dark mode was
// introduced.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if (@available(macos 10.14, *)) {
NSAppearance* desiredAppearance;
switch ([[NSUserDefaults standardUserDefaults] integerForKey:MMAppearanceModeSelectionKey])
{
case MMAppearanceModeSelectionLight:
{
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
break;
}
case MMAppearanceModeSelectionDark:
{
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
break;
}
case MMAppearanceModeSelectionBackgroundOption:
{
if (backgroundDark) {
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua];
} else {
decoratedWindow.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
desiredAppearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
}
break;
}
@@ -609,10 +632,13 @@
default:
{
// Use the system appearance. This will also auto-switch when OS changes mode.
decoratedWindow.appearance = nil;
desiredAppearance = nil;
break;
}
}
decoratedWindow.appearance = desiredAppearance;
fullScreenWindow.appearance = desiredAppearance;
}
#endif
}
@@ -821,11 +847,6 @@
{
if (!setupDone) return;
// Save the original title, if we haven't already.
if (lastSetTitle == nil) {
lastSetTitle = [[decoratedWindow title] retain];
}
// NOTE: During live resize Cocoa goes into "event tracking mode". We have
// to add the backend connection to this mode in order for resize messages
// from Vim to reach MacVim. We do not wish to always listen to requests
@@ -849,8 +870,6 @@
// If we saved the original title while resizing, restore it.
if (lastSetTitle != nil) {
[decoratedWindow setTitle:lastSetTitle];
[lastSetTitle release];
lastSetTitle = nil;
}
// If we are in the middle of rapid resize (e.g. double-clicking on the border/corner