Skip to content

Commit

Permalink
Fixes #284 — option to toggle segmented controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
emsquared committed Jul 5, 2012
1 parent fb28b00 commit 488ebc3
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 48 deletions.
45 changes: 24 additions & 21 deletions Classes/Controllers/TXMasterController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (void)awakeFromNib
#endif

[self.window makeMainWindow];

[TPCPreferences setMasterController:self];
[TPCPreferences initPreferences];

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Classes/Dialogs/Preferences/TDCPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
1 change: 0 additions & 1 deletion Classes/Headers/TDCPreferencesController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Classes/Headers/TPCPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef enum TXHostmaskBanFormat : NSInteger {
+ (BOOL)sandboxEnabled;
+ (BOOL)securityScopedBookmarksAvailable;

- (TXMasterController *)masterController;
+ (TXMasterController *)masterController;
+ (void)setMasterController:(TXMasterController *)master;

+ (NSInteger)startTime;
Expand Down Expand Up @@ -134,6 +134,7 @@ typedef enum TXHostmaskBanFormat : NSInteger {
+ (BOOL)showInlineImages;
+ (BOOL)showJoinLeave;
+ (BOOL)invertSidebarColors;
+ (BOOL)hideMainWindowSegmentedController;
+ (BOOL)displayServerMOTD;
+ (BOOL)rightToLeftFormatting;
+ (BOOL)removeAllFormatting;
Expand Down
1 change: 1 addition & 0 deletions Classes/Headers/TVCInputTextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- (void)updateTextDirection;
- (void)resetTextFieldCellSize;
- (void)redrawOriginPoints;

- (void)setReturnActionWithSelector:(SEL)selector owner:(id)owner;

Expand Down
2 changes: 2 additions & 0 deletions Classes/IRC/IRCWorld.m
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ - (void)reloadTheme

[self.master.serverSplitView setNeedsDisplay:YES];
[self.master.memberSplitView setNeedsDisplay:YES];

[self.text redrawOriginPoints];
}

- (void)changeTextSize:(BOOL)bigger
Expand Down
7 changes: 6 additions & 1 deletion Classes/Preferences/TPCPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @implementation TPCPreferences
The master control has pointers to everything. */

- (TXMasterController *)masterController
+ (TXMasterController *)masterController
{
return internalMasterController;
}
Expand Down Expand Up @@ -480,6 +480,11 @@ + (BOOL)invertSidebarColors
return [_NSUserDefaults() boolForKey:@"InvertSidebarColors"];
}

+ (BOOL)hideMainWindowSegmentedController
{
return [_NSUserDefaults() boolForKey:@"DisableMainWindowSegmentedController"];
}

+ (BOOL)trackConversations
{
return [_NSUserDefaults() boolForKey:@"TrackConversationsWithColorHashing"];
Expand Down
60 changes: 49 additions & 11 deletions Classes/Views/Input Text Field/TVCInputTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#define _InputBoxBackgroundHeightMultiplier 14.0
#define _WindowContentBorderDefaultHeight 38.0

#define _WindowSegmentedControllerDefaultX 10.0
#define _InputTextFieldOriginDefaultX 144.0

@implementation TVCInputTextField
{
NSInteger _lastDrawnLineCount;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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];
Expand All @@ -264,10 +306,6 @@ - (void)drawRect:(NSRect)dirtyRect

[controlColor set];
[controlPath fill];

if (_finishedFirstDraw == NO) {
_finishedFirstDraw = YES;
}
}

@end
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<key>TXBundleBuildCodeName</key>
<string>Turtle Soup</string>
<key>TXBundleBuildNumber</key>
<string>11773</string>
<string>11781</string>
<key>TXBundleBuildReference</key>
<string>2.1.1-228-g9129bf7-debug,llvm4.0</string>
<string>2.1.1-229-gfb28b00-debug,llvm4.0</string>
</dict>
</plist>
Loading

0 comments on commit 488ebc3

Please sign in to comment.