Skip to content

Commit ab7f302

Browse files
committed
#2485: Fix display of type info popup in structure view when dark mode is in use.
1 parent 41633a8 commit ab7f302

File tree

2 files changed

+14
-64
lines changed

2 files changed

+14
-64
lines changed

Source/SPTableStructure.h

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,62 +41,54 @@
4141
@class SPExtendedTableInfo;
4242
@class SPTableInfo;
4343

44-
@interface SPFieldTypeHelp : NSObject {
44+
@interface SPFieldTypeHelp : NSObject
45+
{
4546
NSString *typeName;
4647
NSString *typeDefinition;
4748
NSString *typeRange;
4849
NSString *typeDescription;
4950
}
51+
5052
@property(readonly) NSString *typeName;
5153
@property(readonly) NSString *typeDefinition;
5254
@property(readonly) NSString *typeRange;
5355
@property(readonly) NSString *typeDescription;
56+
5457
@end
5558

56-
@interface SPTableStructure : NSObject
57-
#ifdef SP_CODA
58-
<NSTableViewDelegate, NSTableViewDataSource, NSComboBoxCellDataSource>
59-
#endif
59+
@interface SPTableStructure : NSObject <NSTableViewDelegate, NSTableViewDataSource, NSComboBoxCellDataSource>
6060
{
6161
IBOutlet SPTablesList *tablesListInstance;
6262
IBOutlet SPTableData *tableDataInstance;
6363
IBOutlet SPDatabaseDocument *tableDocumentInstance;
64-
#ifndef SP_CODA /* ivars */
6564
IBOutlet SPTableInfo *tableInfoInstance;
6665
IBOutlet SPExtendedTableInfo *extendedTableInfoInstance;
67-
#endif
6866
IBOutlet SPIndexesController *indexesController;
6967
IBOutlet SPDatabaseData *databaseDataInstance;
7068

7169
IBOutlet NSPanel *structureHelpPanel;
7270
IBOutlet NSTextView *structureHelpText;
73-
74-
#ifndef SP_CODA /* ivars */
71+
7572
IBOutlet id keySheet;
7673
IBOutlet id resetAutoIncrementSheet;
7774
IBOutlet id resetAutoIncrementValue;
7875
IBOutlet id resetAutoIncrementLine;
79-
#endif
8076
IBOutlet SPTableView* tableSourceView;
8177
IBOutlet id addFieldButton;
8278
IBOutlet id duplicateFieldButton;
8379
IBOutlet id removeFieldButton;
8480
IBOutlet id reloadFieldsButton;
85-
#ifndef SP_CODA /* ivars */
8681
IBOutlet id chooseKeyButton;
8782
IBOutlet id structureGrabber;
8883
IBOutlet id editTableButton;
8984
IBOutlet id addIndexButton;
9085
IBOutlet id removeIndexButton;
9186
IBOutlet id refreshIndexesButton;
92-
#endif
9387
IBOutlet SPTableView* indexesTableView;
94-
#ifndef SP_CODA /* ivars */
9588
IBOutlet NSSplitView *tablesIndexesSplitView;
9689
IBOutlet NSButton *indexesShowButton;
9790

9891
IBOutlet id viewColumnsMenu;
99-
#endif
10092
IBOutlet NSPopUpButtonCell *encodingPopupCell;
10193

10294
SPMySQLConnection *mySQLConnection;
@@ -118,23 +110,6 @@
118110
BOOL isEditingRow, isEditingNewRow, isSavingRow, alertSheetOpened;
119111
}
120112

121-
#ifdef SP_CODA
122-
@property (assign) SPIndexesController* indexesController;
123-
@property (assign) id indexesTableView;
124-
@property (assign) id addFieldButton;
125-
@property (assign) id duplicateFieldButton;
126-
@property (assign) id removeFieldButton;
127-
@property (assign) id reloadFieldsButton;
128-
#endif
129-
130-
#ifdef SP_CODA /* method decls */
131-
- (void)setDatabaseDocument:(SPDatabaseDocument*)doc;
132-
- (void)setTableListInstance:(SPTablesList*)list;
133-
- (void)setTableDataInstance:(SPTableData*)data;
134-
- (void)setDatabaseDataInstance:(SPDatabaseData*)data;
135-
- (void)setTableSourceView:(SPTableView*)tv;
136-
- (void)setEncodingPopupCell:(NSPopUpButtonCell*)cell;
137-
#endif
138113
- (void)showErrorSheetWith:(NSDictionary *)errorDictionary;
139114

140115
// Edit methods

Source/SPTableStructure.m

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,19 @@ - (id)init
160160

161161
- (void)awakeFromNib
162162
{
163-
#ifndef SP_CODA /* ui manipulation */
164163
// Set the structure and index view's vertical gridlines if required
165164
[tableSourceView setGridStyleMask:[prefs boolForKey:SPDisplayTableViewVerticalGridlines] ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
166165
[indexesTableView setGridStyleMask:[prefs boolForKey:SPDisplayTableViewVerticalGridlines] ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
167-
#endif
168166

169167
// Set the double-click action in blank areas of the table to create new rows
170168
[tableSourceView setEmptyDoubleClickAction:@selector(addField:)];
171169

172-
#ifndef SP_CODA /* set font from prefs */
173170
BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts];
174171
NSInteger monospacedFontSize = [prefs integerForKey:SPMonospacedFontSize] > 0 ? [prefs integerForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
175172

176173
// Set the strutcture and index view's font
177174
[tableSourceView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
178175
[indexesTableView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
179-
#endif
180176

181177
extraFieldSuggestions = [@[
182178
@"None",
@@ -250,17 +246,12 @@ - (void)awakeFromNib
250246
name:SPDocumentTaskEndNotification
251247
object:tableDocumentInstance];
252248

253-
#ifndef SP_CODA /* add prefs observer */
254249
[prefs addObserver:indexesController forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL];
255-
#endif
256250

257-
#ifndef SP_CODA
258251
// Init the view column submenu according to saved hidden status;
259252
// menu items are identified by their tag number which represents the initial column index
260253
for (NSMenuItem *item in [viewColumnsMenu itemArray]) [item setState:NSOnState]; // Set all items to NSOnState
261-
#endif
262254

263-
#ifndef SP_CODA /* patch */
264255
for (NSTableColumn *col in [tableSourceView tableColumns])
265256
{
266257
if ([col isHidden]) {
@@ -274,24 +265,7 @@ - (void)awakeFromNib
274265
[[viewColumnsMenu itemWithTag:12] setState:NSOffState];
275266
}
276267
}
277-
#else
278-
/*
279-
for (NSTableColumn *col in [tableSourceView tableColumns])
280-
{
281-
if ([col isHidden]) {
282-
if ([[col identifier] isEqualToString:@"Key"])
283-
[[viewColumnsMenu itemAtIndex:[viewColumnsMenu indexOfItemWithTag:7]] setState:NSOffState];
284-
else if ([[col identifier] isEqualToString:@"encoding"])
285-
[[viewColumnsMenu itemAtIndex:[viewColumnsMenu indexOfItemWithTag:10]] setState:NSOffState];
286-
else if ([[col identifier] isEqualToString:@"collation"])
287-
[[viewColumnsMenu itemAtIndex:[viewColumnsMenu indexOfItemWithTag:11]] setState:NSOffState];
288-
else if ([[col identifier] isEqualToString:@"comment"])
289-
[[viewColumnsMenu itemAtIndex:[viewColumnsMenu indexOfItemWithTag:12]] setState:NSOffState];
290-
}
291-
}
292-
*/
293-
#endif
294-
268+
295269
[tableSourceView reloadData];
296270
}
297271

@@ -2478,20 +2452,20 @@ - (void)_displayFieldTypeHelpIfPossible:(SPComboBoxCell *)cell
24782452

24792453
const SPFieldTypeHelp *help = [[self class] helpForFieldType:selected];
24802454

2481-
if(help) {
2455+
if (help) {
24822456
NSMutableAttributedString *as = [[NSMutableAttributedString alloc] init];
24832457

24842458
//title
24852459
{
2486-
NSDictionary *titleAttr = @{NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]]};
2460+
NSDictionary *titleAttr = @{NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSForegroundColorAttributeName: [NSColor controlTextColor]};
24872461
NSAttributedString *title = [[NSAttributedString alloc] initWithString:[help typeDefinition] attributes:titleAttr];
24882462
[as appendAttributedString:[title autorelease]];
24892463
[[as mutableString] appendString:@"\n"];
24902464
}
24912465

24922466
//range
2493-
if([[help typeRange] length]) {
2494-
NSDictionary *rangeAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]};
2467+
if ([[help typeRange] length]) {
2468+
NSDictionary *rangeAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]], NSForegroundColorAttributeName: [NSColor controlTextColor]};
24952469
NSAttributedString *range = [[NSAttributedString alloc] initWithString:[help typeRange] attributes:rangeAttr];
24962470
[as appendAttributedString:[range autorelease]];
24972471
[[as mutableString] appendString:@"\n"];
@@ -2501,7 +2475,7 @@ - (void)_displayFieldTypeHelpIfPossible:(SPComboBoxCell *)cell
25012475

25022476
//description
25032477
{
2504-
NSDictionary *descAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]]};
2478+
NSDictionary *descAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]], NSForegroundColorAttributeName: [NSColor controlTextColor]};
25052479
NSAttributedString *desc = [[NSAttributedString alloc] initWithString:[help typeDescription] attributes:descAttr];
25062480
[as appendAttributedString:[desc autorelease]];
25072481
}
@@ -2522,7 +2496,7 @@ - (void)_displayFieldTypeHelpIfPossible:(SPComboBoxCell *)cell
25222496
NSPoint topRightCorner = NSMakePoint(popUpFrame.origin.x, NSMaxY(popUpFrame));
25232497
NSRect screenRect = [NSScreen rectOfScreenAtPoint:topRightCorner];
25242498

2525-
if(NSMaxX(popUpFrame)+10+winRect.size.width > NSMaxX(screenRect)-10) {
2499+
if (NSMaxX(popUpFrame)+10+winRect.size.width > NSMaxX(screenRect)-10) {
25262500
// exceeds right border, display on the left
25272501
winRect.origin.x = popUpFrame.origin.x - 10 - winRect.size.width;
25282502
}
@@ -2533,6 +2507,7 @@ - (void)_displayFieldTypeHelpIfPossible:(SPComboBoxCell *)cell
25332507

25342508
winRect.size.height = rect.size.height + winAddonSize;
25352509
winRect.origin.y = NSMaxY(popUpFrame) - winRect.size.height;
2510+
25362511
[structureHelpPanel setFrame:winRect display:YES];
25372512

25382513
[structureHelpPanel orderFront:nil];

0 commit comments

Comments
 (0)