mirror of
https://github.com/binaryage/totalterminal.git
synced 2026-05-11 03:00:08 -04:00
Added Quart animation background with proper transparency handling
This commit is contained in:
BIN
src/ChangeThemeBackgroundColor.png
Normal file
BIN
src/ChangeThemeBackgroundColor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
@@ -1,26 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>VisorAnimationSpeed</key>
|
||||
<real>0.29999999999999999</real>
|
||||
<key>VisorUseFade</key>
|
||||
<true/>
|
||||
<key>VisorUseSlide</key>
|
||||
<true/>
|
||||
<key>VisorShowStatusItem</key>
|
||||
<true/>
|
||||
<key>VisorShowOnReopen</key>
|
||||
<true/>
|
||||
<key>VisorCopyOnSelect</key>
|
||||
<false/>
|
||||
<key>VisorHideOnEscape</key>
|
||||
<false/>
|
||||
<key>VisorScreen</key>
|
||||
<integer>0</integer>
|
||||
<key>VisorPosition</key>
|
||||
<string>Top-Stretch</string>
|
||||
<key>VisorOnEverySpace</key>
|
||||
<true/>
|
||||
<key>VisorAnimationSpeed</key>
|
||||
<real>0.3</real>
|
||||
<key>VisorUseFade</key>
|
||||
<true/>
|
||||
<key>VisorUseSlide</key>
|
||||
<true/>
|
||||
<key>VisorShowStatusItem</key>
|
||||
<true/>
|
||||
<key>VisorShowOnReopen</key>
|
||||
<true/>
|
||||
<key>VisorCopyOnSelect</key>
|
||||
<false/>
|
||||
<key>VisorHideOnEscape</key>
|
||||
<false/>
|
||||
<key>VisorScreen</key>
|
||||
<integer>0</integer>
|
||||
<key>VisorPosition</key>
|
||||
<string>Top-Stretch</string>
|
||||
<key>VisorOnEverySpace</key>
|
||||
<true/>
|
||||
<key>VisorUseBackgroundAnimation</key>
|
||||
<false/>
|
||||
<key>VisorBackgroundAnimationOpacity</key>
|
||||
<integer>100</integer>
|
||||
<key>VisorBackgroundAnimationFile</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
</plist>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
NSStatusItem* statusItem;
|
||||
IBOutlet NSMenu* statusMenu;
|
||||
IBOutlet NSWindow* settingsWindow;
|
||||
IBOutlet NSPanel* transparencyHelpPanel;
|
||||
IBOutlet WebView* infoLine; // bottom info line on Visor preferences pane
|
||||
EventHotKeyRef hotKey_;
|
||||
NSUInteger hotModifiers_;
|
||||
@@ -43,9 +44,13 @@
|
||||
- (void)setOriginalPreferencesSize:(CGSize)size;
|
||||
- (CGSize)prefPaneSize;
|
||||
|
||||
- (IBAction)showTransparencyHelpPanel:(id)sender;
|
||||
- (IBAction)closeTransparencyHelpPanel:(id)sender;
|
||||
- (IBAction)chooseBackgroundComposition:(id)sender;
|
||||
- (IBAction)pinAction:(id)sender;
|
||||
- (IBAction)toggleVisor:(id)sender;
|
||||
- (IBAction)showPrefs:(id)sender;
|
||||
- (IBAction)visitHomepage:(id)sender;
|
||||
|
||||
@property (readonly, nonatomic) NSNumber *shouldShowTransparencyAlert;
|
||||
@end
|
||||
64
src/Visor.m
64
src/Visor.m
@@ -94,6 +94,7 @@ int main(int argc, char *argv[]) {
|
||||
[toolbar setSelectedItemIdentifier:@"Visor"];
|
||||
NSTabView* tabView = [self valueForKey:@"tabView"];
|
||||
[tabView selectTabViewItemWithIdentifier:@"VisorPane"];
|
||||
[visor updateShouldShowTransparencyAlert];
|
||||
}
|
||||
|
||||
- (id)Visor_TTAppPrefsController_toolbar:(id)arg1 itemForItemIdentifier:(id)arg2 willBeInsertedIntoToolbar:(BOOL)arg3 {
|
||||
@@ -588,6 +589,10 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
if (![ud objectForKey:@"VisorHotKeyEnabled"]) {
|
||||
[ud setBool:YES forKey:@"VisorHotKeyEnabled"];
|
||||
}
|
||||
|
||||
if (![ud objectForKey:@"VisorBackgroundAnimationOpacity"]) {
|
||||
[ud setInteger:100 forKey:@"VisorBackgroundAnimationOpacity"];
|
||||
}
|
||||
// by default disable HotKey2 but set it to double Control
|
||||
if (![ud objectForKey:@"VisorHotKey2"]) {
|
||||
[ud setObject:[NSDictionary dictionaryWithObjectsAndKeys: \
|
||||
@@ -697,6 +702,7 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
[udc addObserver:self forKeyPath:@"values.VisorPosition" options:0 context:nil];
|
||||
[udc addObserver:self forKeyPath:@"values.VisorHideOnEscape" options:0 context:nil];
|
||||
[udc addObserver:self forKeyPath:@"values.VisorUseBackgroundAnimation" options:0 context:nil];
|
||||
[udc addObserver:self forKeyPath:@"values.VisorBackgroundAnimationOpacity" options:0 context:nil];
|
||||
[[[self class] getVisorProfile] addObserver:self forKeyPath:@"BackgroundColor" options:0 context:@"Update bkg"];
|
||||
|
||||
if ([ud boolForKey:@"VisorUseBackgroundAnimation"]) {
|
||||
@@ -705,6 +711,16 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (float)getVisorAnimationBackgroundAlpha {
|
||||
return [[NSUserDefaults standardUserDefaults] integerForKey:@"VisorBackgroundAnimationOpacity"] / 100.0f;
|
||||
}
|
||||
- (void)updateAnimationAlpha {
|
||||
if (background != nil && !isHidden) {
|
||||
float bkgAlpha = [self getVisorAnimationBackgroundAlpha];
|
||||
[background setAlphaValue:bkgAlpha];
|
||||
}
|
||||
}
|
||||
|
||||
- (float)getVisorProfileBackgroundAlpha {
|
||||
id bckColor = background ? [[[self class] getVisorProfile] valueForKey:@"BackgroundColor"] : nil;
|
||||
return bckColor ? [bckColor alphaComponent] : 1.0;
|
||||
@@ -722,8 +738,7 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
[background setReleasedWhenClosed:YES];
|
||||
[background setLevel:NSFloatingWindowLevel];
|
||||
[background setHasShadow:NO];
|
||||
float bkgAlpha = [self getVisorProfileBackgroundAlpha];
|
||||
[background setAlphaValue:bkgAlpha];
|
||||
[self updateAnimationAlpha];
|
||||
|
||||
QCView *content = [[[QCView alloc]init]autorelease];
|
||||
|
||||
@@ -1155,7 +1170,7 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
#define ALPHA_DIRECTION(d,x) (d?(1.0f-(x)):(x))
|
||||
|
||||
- (void)slideWindows:(BOOL)direction fast:(bool)fast { // true == down
|
||||
float bkgAlpha = [self getVisorProfileBackgroundAlpha];
|
||||
float bkgAlpha = [self getVisorAnimationBackgroundAlpha];
|
||||
if (!fast) {
|
||||
BOOL doSlide = [[NSUserDefaults standardUserDefaults]boolForKey:@"VisorUseSlide"];
|
||||
BOOL doFade = [[NSUserDefaults standardUserDefaults]boolForKey:@"VisorUseFade"];
|
||||
@@ -1237,6 +1252,11 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
[self updateStatusMenu];
|
||||
}
|
||||
|
||||
- (void)updateShouldShowTransparencyAlert {
|
||||
[self willChangeValueForKey:@"shouldShowTransparencyAlert"];
|
||||
[self didChangeValueForKey:@"shouldShowTransparencyAlert"];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||
LOG(@"observeValueForKeyPath %@", keyPath);
|
||||
if ([keyPath isEqualToString:@"values.VisorShowStatusItem"]) {
|
||||
@@ -1262,15 +1282,39 @@ static const size_t kModifierEventTypeSpecSize = sizeof(kModifierEventTypeSpec)
|
||||
}
|
||||
if ([keyPath isEqualToString:@"values.VisorUseBackgroundAnimation"]) {
|
||||
[self updateBackgroundFrame];
|
||||
[self updateShouldShowTransparencyAlert];
|
||||
}
|
||||
if (background != nil &&
|
||||
!isHidden &&
|
||||
[keyPath isEqualToString:@"BackgroundColor"] &&
|
||||
context != nil &&
|
||||
[context isEqualToString:@"Update bkg"]) {
|
||||
float bkgAlpha = [self getVisorProfileBackgroundAlpha];
|
||||
[background setAlphaValue:bkgAlpha];
|
||||
if ([keyPath isEqualToString:@"values.VisorBackgroundAnimationOpacity"]) {
|
||||
[self updateAnimationAlpha];
|
||||
}
|
||||
if ([keyPath isEqualToString:@"BackgroundColor"] &&
|
||||
context != nil &&
|
||||
[context isEqualToString:@"Update bkg"])
|
||||
{
|
||||
[self updateAnimationAlpha];
|
||||
[self updateShouldShowTransparencyAlert];
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)theKey {
|
||||
if ([theKey isEqualToString:@"shouldShowTransparencyAlert"])
|
||||
return NO;
|
||||
return [super automaticallyNotifiesObserversForKey:theKey];
|
||||
}
|
||||
|
||||
- (NSNumber *)shouldShowTransparencyAlert {
|
||||
return ([[NSUserDefaults standardUserDefaults] boolForKey:@"VisorUseBackgroundAnimation"] &&
|
||||
((float)[self getVisorProfileBackgroundAlpha] >= 1.0f))
|
||||
? kCFBooleanTrue : kCFBooleanFalse;
|
||||
}
|
||||
|
||||
- (IBAction)showTransparencyHelpPanel:(id)sender {
|
||||
[NSApp beginSheet:transparencyHelpPanel modalForWindow:[[NSClassFromString(@"TTAppPrefsController")
|
||||
sharedPreferencesController] window] modalDelegate:self didEndSelector:NULL contextInfo:nil];
|
||||
}
|
||||
- (IBAction)closeTransparencyHelpPanel:(id)sender {
|
||||
[transparencyHelpPanel orderOut:nil];
|
||||
[NSApp endSheet:transparencyHelpPanel];
|
||||
}
|
||||
|
||||
- (void)updateHotKeyRegistration {
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
0708B0F612ADA36100A0F345 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0708B0F512ADA36100A0F345 /* Quartz.framework */; };
|
||||
0708B0F812ADA36100A0F345 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0708B0F712ADA36100A0F345 /* QuartzCore.framework */; };
|
||||
07CA8A0712ADAC6C00A6D8BF /* Visor.qtz in Resources */ = {isa = PBXBuildFile; fileRef = 07CA8A0612ADAC6C00A6D8BF /* Visor.qtz */; };
|
||||
07CA8BD712B499F600A6D8BF /* error.png in Resources */ = {isa = PBXBuildFile; fileRef = 07CA8BD612B499F600A6D8BF /* error.png */; };
|
||||
07CA8C6212B58C0700A6D8BF /* ChangeThemeBackgroundColor.png in Resources */ = {isa = PBXBuildFile; fileRef = 07CA8C6112B58C0700A6D8BF /* ChangeThemeBackgroundColor.png */; };
|
||||
26C7384F11045EBF00E5058E /* PasteOnRightclick.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C7384E11045EBF00E5058E /* PasteOnRightclick.m */; };
|
||||
7F849AAC0A457E2200963040 /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7F849AA60A457DE100963040 /* Defaults.plist */; };
|
||||
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
|
||||
@@ -40,6 +42,8 @@
|
||||
0708B0F512ADA36100A0F345 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = "<absolute>"; };
|
||||
0708B0F712ADA36100A0F345 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
|
||||
07CA8A0612ADAC6C00A6D8BF /* Visor.qtz */ = {isa = PBXFileReference; lastKnownFileType = "video.quartz-composer"; path = Visor.qtz; sourceTree = "<group>"; };
|
||||
07CA8BD612B499F600A6D8BF /* error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = error.png; sourceTree = "<group>"; };
|
||||
07CA8C6112B58C0700A6D8BF /* ChangeThemeBackgroundColor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ChangeThemeBackgroundColor.png; sourceTree = "<group>"; };
|
||||
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
@@ -129,6 +133,8 @@
|
||||
089C167CFE841241C02AAC07 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
07CA8C6112B58C0700A6D8BF /* ChangeThemeBackgroundColor.png */,
|
||||
07CA8BD612B499F600A6D8BF /* error.png */,
|
||||
07CA8A0612ADAC6C00A6D8BF /* Visor.qtz */,
|
||||
D671706A1065D14300970560 /* RestoreApp.scpt */,
|
||||
D6716FBC1065B54100970560 /* Control.pdf */,
|
||||
@@ -285,7 +291,9 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
07CA8C6212B58C0700A6D8BF /* ChangeThemeBackgroundColor.png in Resources */,
|
||||
D67170711065D19D00970560 /* RestoreApp.scpt in Resources */,
|
||||
07CA8BD712B499F600A6D8BF /* error.png in Resources */,
|
||||
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */,
|
||||
7F849AAC0A457E2200963040 /* Defaults.plist in Resources */,
|
||||
D6FB33E90F3843E20067F941 /* Visor.xib in Resources */,
|
||||
|
||||
983
src/Visor.xib
983
src/Visor.xib
File diff suppressed because it is too large
Load Diff
BIN
src/error.png
Executable file
BIN
src/error.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 666 B |
Reference in New Issue
Block a user