From 488ebc36f7a00a03657593531329fc07f6f868d0 Mon Sep 17 00:00:00 2001 From: emsquared Date: Thu, 5 Jul 2012 09:49:59 -0400 Subject: [PATCH] =?UTF-8?q?Fixes=20#284=20=E2=80=94=20option=20to=20toggle?= =?UTF-8?q?=20segmented=20controller.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Controllers/TXMasterController.m | 45 +++++---- .../Preferences/TDCPreferencesController.m | 3 - Classes/Headers/TDCPreferencesController.h | 1 - Classes/Headers/TPCPreferences.h | 3 +- Classes/Headers/TVCInputTextField.h | 1 + Classes/IRC/IRCWorld.m | 2 + Classes/Preferences/TPCPreferences.m | 7 +- .../Input Text Field/TVCInputTextField.m | 60 +++++++++--- Resources/Info.plist | 4 +- .../English.lproj/TDCPreferences.xib | 95 +++++++++++++++++-- 10 files changed, 173 insertions(+), 48 deletions(-) diff --git a/Classes/Controllers/TXMasterController.m b/Classes/Controllers/TXMasterController.m index 253054b9ef..6b93689630 100755 --- a/Classes/Controllers/TXMasterController.m +++ b/Classes/Controllers/TXMasterController.m @@ -31,7 +31,7 @@ - (void)awakeFromNib #endif [self.window makeMainWindow]; - + [TPCPreferences setMasterController:self]; [TPCPreferences initPreferences]; @@ -60,6 +60,7 @@ - (void)awakeFromNib [self.window setAlphaValue:[TPCPreferences themeTransparency]]; [self.text setReturnActionWithSelector:@selector(textEntered) owner:self]; + [self.text redrawOriginPoints]; [TLOLanguagePreferences setThemeForLocalization:self.viewTheme.path]; @@ -170,23 +171,23 @@ - (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification } else { NSRect visibleRect = [_NSMainScreen() visibleFrame]; NSRect windowRect = self.window.frame; - + BOOL redrawFrame = NO; if (visibleRect.size.height < windowRect.size.height) { windowRect.size.height = visibleRect.size.height; windowRect.origin.x = visibleRect.origin.x; - + redrawFrame = YES; } if (visibleRect.size.width < windowRect.size.width) { windowRect.size.width = visibleRect.size.width; windowRect.origin.y = visibleRect.origin.y; - + redrawFrame = YES; } - + if (redrawFrame) { [self.window setFrame:windowRect display:YES animate:YES]; } @@ -593,7 +594,7 @@ - (void)saveWindowState [_NSUserDefaults() setBool:[self.text isGrammarCheckingEnabled] forKey:@"TextFieldAutomaticGrammarCheck"]; [_NSUserDefaults() setBool:[self.text isContinuousSpellCheckingEnabled] forKey:@"TextFieldAutomaticSpellCheck"]; [_NSUserDefaults() setBool:[self.text isAutomaticSpellingCorrectionEnabled] forKey:@"TextFieldAutomaticSpellCorrection"]; - + [TPCPreferences stopUsingTranscriptFolderBookmarkResources]; [TPCPreferences saveWindowState:dic name:@"Window -> Main Window"]; [TPCPreferences sync]; @@ -619,12 +620,12 @@ - (void)themeStyleDidChange:(NSNotification *)note [sf appendString:TXTLS(@"ThemeChangeOverridePromptChannelFont")]; [sf appendString:NSStringNewlinePlaceholder]; } - + if (self.viewTheme.other.forceInvertSidebarColors) { [sf appendString:TXTLS(@"ThemeChangeOverridePromptWindowColors")]; [sf appendString:NSStringNewlinePlaceholder]; } - + [self.text updateTextDirection]; sf = (NSMutableString *)[sf trim]; @@ -1342,20 +1343,22 @@ - (void)registerKeyHandlers - (void)updateSegmentedController { - [self.windowButtonController setEnabled:(self.world.clients.count >= 1)]; - - /* Selection Settings. */ - IRCClient *u = self.world.selectedClient; - IRCChannel *c = self.world.selectedChannel; - - if (PointerIsEmpty(c)) { - [self.windowButtonController setMenu:self.serverMenu.submenu forSegment:1]; - } else { - [self.windowButtonController setMenu:self.channelMenu.submenu forSegment:1]; + if ([TPCPreferences hideMainWindowSegmentedController] == NO) { + [self.windowButtonController setEnabled:(self.world.clients.count >= 1)]; + + /* Selection Settings. */ + IRCClient *u = self.world.selectedClient; + IRCChannel *c = self.world.selectedChannel; + + if (PointerIsEmpty(c)) { + [self.windowButtonController setMenu:self.serverMenu.submenu forSegment:1]; + } else { + [self.windowButtonController setMenu:self.channelMenu.submenu forSegment:1]; + } + + /* Open Address Book. */ + [self.windowButtonController setEnabled:(PointerIsNotEmpty(u) && u.isConnected) forSegment:2]; } - - /* Open Address Book. */ - [self.windowButtonController setEnabled:(PointerIsNotEmpty(u) && u.isConnected) forSegment:2]; } - (void)buildSegmentedController diff --git a/Classes/Dialogs/Preferences/TDCPreferencesController.m b/Classes/Dialogs/Preferences/TDCPreferencesController.m index b674d74b2d..4140f5544c 100755 --- a/Classes/Dialogs/Preferences/TDCPreferencesController.m +++ b/Classes/Dialogs/Preferences/TDCPreferencesController.m @@ -54,9 +54,6 @@ - (void)show [self updateTranscriptFolder]; [self setUpToolbarItemsAndMenus]; [self onHighlightTypeChanged:nil]; - - [self.toggleDarkenedThemeCheck setTarget:self]; - [self.toggleDarkenedThemeCheck setAction:@selector(onStyleChanged:)]; [self firstPane:self.generalView selectedItem:0]; } diff --git a/Classes/Headers/TDCPreferencesController.h b/Classes/Headers/TDCPreferencesController.h index 86ec6992df..7b84969e38 100755 --- a/Classes/Headers/TDCPreferencesController.h +++ b/Classes/Headers/TDCPreferencesController.h @@ -39,7 +39,6 @@ @property (nonatomic, strong) NSPopUpButton *alertSoundButton; @property (nonatomic, strong) NSButton *useGrowlButton; @property (nonatomic, strong) NSButton *disableAlertWhenAwayButton; -@property (nonatomic, strong) NSButton *toggleDarkenedThemeCheck; @property (nonatomic, strong) NSMenu *installedScriptsMenu; @property (nonatomic, strong) NSTextField *scriptLocationField; @property (nonatomic, strong) NSToolbar *preferenceSelectToolbar; diff --git a/Classes/Headers/TPCPreferences.h b/Classes/Headers/TPCPreferences.h index 4b348f0298..96664d6b5d 100755 --- a/Classes/Headers/TPCPreferences.h +++ b/Classes/Headers/TPCPreferences.h @@ -48,7 +48,7 @@ typedef enum TXHostmaskBanFormat : NSInteger { + (BOOL)sandboxEnabled; + (BOOL)securityScopedBookmarksAvailable; -- (TXMasterController *)masterController; ++ (TXMasterController *)masterController; + (void)setMasterController:(TXMasterController *)master; + (NSInteger)startTime; @@ -134,6 +134,7 @@ typedef enum TXHostmaskBanFormat : NSInteger { + (BOOL)showInlineImages; + (BOOL)showJoinLeave; + (BOOL)invertSidebarColors; ++ (BOOL)hideMainWindowSegmentedController; + (BOOL)displayServerMOTD; + (BOOL)rightToLeftFormatting; + (BOOL)removeAllFormatting; diff --git a/Classes/Headers/TVCInputTextField.h b/Classes/Headers/TVCInputTextField.h index ba87b927a5..e24434d45b 100755 --- a/Classes/Headers/TVCInputTextField.h +++ b/Classes/Headers/TVCInputTextField.h @@ -10,6 +10,7 @@ - (void)updateTextDirection; - (void)resetTextFieldCellSize; +- (void)redrawOriginPoints; - (void)setReturnActionWithSelector:(SEL)selector owner:(id)owner; diff --git a/Classes/IRC/IRCWorld.m b/Classes/IRC/IRCWorld.m index efefac4184..d9aeca680f 100755 --- a/Classes/IRC/IRCWorld.m +++ b/Classes/IRC/IRCWorld.m @@ -612,6 +612,8 @@ - (void)reloadTheme [self.master.serverSplitView setNeedsDisplay:YES]; [self.master.memberSplitView setNeedsDisplay:YES]; + + [self.text redrawOriginPoints]; } - (void)changeTextSize:(BOOL)bigger diff --git a/Classes/Preferences/TPCPreferences.m b/Classes/Preferences/TPCPreferences.m index 8e47d05901..66152f6737 100755 --- a/Classes/Preferences/TPCPreferences.m +++ b/Classes/Preferences/TPCPreferences.m @@ -22,7 +22,7 @@ @implementation TPCPreferences The master control has pointers to everything. */ -- (TXMasterController *)masterController ++ (TXMasterController *)masterController { return internalMasterController; } @@ -480,6 +480,11 @@ + (BOOL)invertSidebarColors return [_NSUserDefaults() boolForKey:@"InvertSidebarColors"]; } ++ (BOOL)hideMainWindowSegmentedController +{ + return [_NSUserDefaults() boolForKey:@"DisableMainWindowSegmentedController"]; +} + + (BOOL)trackConversations { return [_NSUserDefaults() boolForKey:@"TrackConversationsWithColorHashing"]; diff --git a/Classes/Views/Input Text Field/TVCInputTextField.m b/Classes/Views/Input Text Field/TVCInputTextField.m index bf2dad22a1..402e086a25 100755 --- a/Classes/Views/Input Text Field/TVCInputTextField.m +++ b/Classes/Views/Input Text Field/TVCInputTextField.m @@ -15,6 +15,9 @@ #define _InputBoxBackgroundHeightMultiplier 14.0 #define _WindowContentBorderDefaultHeight 38.0 +#define _WindowSegmentedControllerDefaultX 10.0 +#define _InputTextFieldOriginDefaultX 144.0 + @implementation TVCInputTextField { NSInteger _lastDrawnLineCount; @@ -42,6 +45,44 @@ - (id)initWithCoder:(NSCoder *)coder return self; } +- (void)redrawOriginPoints +{ + TXMasterController *master = [TPCPreferences masterController]; + + NSInteger defaultSegmentX = _WindowSegmentedControllerDefaultX; + NSInteger defaultInputbxX = _InputTextFieldOriginDefaultX; + + NSInteger resultOriginX = 0; + NSInteger resultSizeWth = (defaultInputbxX - defaultSegmentX); + + if ([TPCPreferences hideMainWindowSegmentedController]) { + [master.windowButtonController setHidden:YES]; + + resultOriginX = defaultSegmentX; + } else { + [master.windowButtonController setHidden:NO]; + + resultOriginX = defaultInputbxX; + resultSizeWth *= -1; + } + + NSRect fronFrame = [self.scrollView frame]; + NSRect backFrame = [self.backgroundView frame]; + + if (NSDissimilarObjects(resultOriginX, fronFrame.origin.x) && + NSDissimilarObjects(resultOriginX, backFrame.origin.x)) { + + fronFrame.size.width += resultSizeWth; + backFrame.size.width += resultSizeWth; + + fronFrame.origin.x = resultOriginX; + backFrame.origin.x = resultOriginX; + + [self.scrollView setFrame:fronFrame]; + [self.backgroundView setFrame:backFrame]; + } +} + - (NSView *)splitterView { return (self.superview.superview.superview.subviews)[0]; @@ -201,12 +242,16 @@ - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector @end @implementation TVCInputTextFieldBackground -{ - BOOL _finishedFirstDraw; -} - (void)setWindowIsActive:(BOOL)value { + /* We set a property stating we are active instead of + calling our NSWindow and asking it because there are + times that we are going to be drawing to a focused + window, but it has not became visible yet. Therefore, + the call to NSWindow would tell us to draw an inactive + input box when it should be active. */ + if (NSDissimilarObjects(value, self.windowIsActive)) { _windowIsActive = value; } @@ -235,10 +280,7 @@ - (void)drawRect:(NSRect)dirtyRect /* Black Outline. */ controlFrame = NSMakeRect(0.0, 1.0, cellBounds.size.width, (cellBounds.size.height - 1.0)); - /* We force focused color during first run because we draw before - our window has finished coming to the front so the wrong color - is used for our border. */ - if (self.windowIsActive || _finishedFirstDraw == NO) { + if (self.windowIsActive) { controlColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.4]; } else { controlColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.23]; @@ -264,10 +306,6 @@ - (void)drawRect:(NSRect)dirtyRect [controlColor set]; [controlPath fill]; - - if (_finishedFirstDraw == NO) { - _finishedFirstDraw = YES; - } } @end \ No newline at end of file diff --git a/Resources/Info.plist b/Resources/Info.plist index 45da3607dc..3c0089ba5b 100755 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -47,8 +47,8 @@ TXBundleBuildCodeName Turtle Soup TXBundleBuildNumber - 11773 + 11781 TXBundleBuildReference - 2.1.1-228-g9129bf7-debug,llvm4.0 + 2.1.1-229-gfb28b00-debug,llvm4.0 diff --git a/Resources/Localization/English.lproj/TDCPreferences.xib b/Resources/Localization/English.lproj/TDCPreferences.xib index a3b1dcff99..bff421cfcb 100755 --- a/Resources/Localization/English.lproj/TDCPreferences.xib +++ b/Resources/Localization/English.lproj/TDCPreferences.xib @@ -2,9 +2,9 @@ 1060 - 12A248 + 12A256 2541 - 1183 + 1185 622.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -190,6 +190,7 @@ -2044182528 2 + 400 @@ -4998,7 +4999,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {{10, 229}, {357, 18}} - + _NS:239 YES @@ -5022,7 +5023,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 268 - {{10, 201}, {201, 18}} + {{10, 173}, {201, 18}} @@ -5046,6 +5047,33 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA NO + + + 268 + {{10, 201}, {275, 18}} + + + + _NS:9 + YES + + -2080374784 + 268435456 + Hide the buttons left of the input text field. + + _NS:9 + + 1211912448 + 2 + + + + + 200 + 25 + + NO + {{10, 25}, {495, 380}} @@ -6170,12 +6198,20 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 7151 - - toggleDarkenedThemeCheck + + onStyleChanged: - 7259 + 7268 + + + + onStyleChanged: + + + + 7269 @@ -8022,6 +8058,22 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 7263 + + + value: values.DisableMainWindowSegmentedController + + + + + + value: values.DisableMainWindowSegmentedController + value + values.DisableMainWindowSegmentedController + 2 + + + 7270 + @@ -10381,6 +10433,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA + @@ -10895,6 +10948,19 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA + + 7264 + + + + + + + + 7265 + + + @@ -11644,18 +11710,31 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 7263 + 7270 TDCPreferencesController NSWindowController + + onStyleChanged: + id + + + onStyleChanged: + + onStyleChanged: + id + + IBProjectSource ./Classes/TDCPreferencesController.h