summaryrefslogtreecommitdiff
path: root/src/video/cocoa/cocoa_wnd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video/cocoa/cocoa_wnd.h')
-rw-r--r--src/video/cocoa/cocoa_wnd.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/video/cocoa/cocoa_wnd.h b/src/video/cocoa/cocoa_wnd.h
index 3ddd5a4f0..0b5c51b99 100644
--- a/src/video/cocoa/cocoa_wnd.h
+++ b/src/video/cocoa/cocoa_wnd.h
@@ -11,6 +11,8 @@
#define COCOA_WND_H
#import <Cocoa/Cocoa.h>
+#include "toolbar_gui.h"
+#include "table/sprites.h"
class VideoDriver_Cocoa;
@@ -28,8 +30,67 @@ extern NSString *OTTDMainLaunchGameEngine;
+ (NSCursor *) clearCocoaCursor;
@end
+#ifdef HAVE_OSX_1015_SDK
+/* 9 items can be displayed on the touch bar when using default buttons. */
+static NSArray *touchBarButtonIdentifiers = @[
+ @"openttd.pause",
+ @"openttd.fastforward",
+ @"openttd.zoom_in",
+ @"openttd.zoom_out",
+ @"openttd.build_rail",
+ @"openttd.build_road",
+ @"openttd.build_tram",
+ @"openttd.build_docks",
+ @"openttd.build_airport",
+ NSTouchBarItemIdentifierOtherItemsProxy
+];
+
+static NSDictionary *touchBarButtonSprites = @{
+ @"openttd.pause": [NSNumber numberWithInt:SPR_IMG_PAUSE],
+ @"openttd.fastforward": [NSNumber numberWithInt:SPR_IMG_FASTFORWARD],
+ @"openttd.zoom_in": [NSNumber numberWithInt:SPR_IMG_ZOOMIN],
+ @"openttd.zoom_out": [NSNumber numberWithInt:SPR_IMG_ZOOMOUT],
+ @"openttd.build_rail": [NSNumber numberWithInt:SPR_IMG_BUILDRAIL],
+ @"openttd.build_road": [NSNumber numberWithInt:SPR_IMG_BUILDROAD],
+ @"openttd.build_tram": [NSNumber numberWithInt:SPR_IMG_BUILDTRAMS],
+ @"openttd.build_docks": [NSNumber numberWithInt:SPR_IMG_BUILDWATER],
+ @"openttd.build_airport": [NSNumber numberWithInt:SPR_IMG_BUILDAIR],
+};
+
+static NSDictionary *touchBarButtonActions = @{
+ @"openttd.pause": [NSNumber numberWithInt:MTHK_PAUSE],
+ @"openttd.fastforward": [NSNumber numberWithInt:MTHK_FASTFORWARD],
+ @"openttd.zoom_in": [NSNumber numberWithInt:MTHK_ZOOM_IN],
+ @"openttd.zoom_out": [NSNumber numberWithInt:MTHK_ZOOM_OUT],
+ @"openttd.build_rail": [NSNumber numberWithInt:MTHK_BUILD_RAIL],
+ @"openttd.build_road": [NSNumber numberWithInt:MTHK_BUILD_ROAD],
+ @"openttd.build_tram": [NSNumber numberWithInt:MTHK_BUILD_TRAM],
+ @"openttd.build_docks": [NSNumber numberWithInt:MTHK_BUILD_DOCKS],
+ @"openttd.build_airport": [NSNumber numberWithInt:MTHK_BUILD_AIRPORT],
+};
+
+static NSDictionary *touchBarFallbackText = @{
+ @"openttd.pause": @"Pause",
+ @"openttd.fastforward": @"Fast Forward",
+ @"openttd.zoom_in": @"Zoom In",
+ @"openttd.zoom_out": @"Zoom Out",
+ @"openttd.build_rail": @"Rail",
+ @"openttd.build_road": @"Road",
+ @"openttd.build_tram": @"Tram",
+ @"openttd.build_docks": @"Docks",
+ @"openttd.build_airport": @"Airport",
+};
+#endif
+
/** Subclass of NSWindow to cater our special needs */
+#ifdef HAVE_OSX_1015_SDK
+@interface OTTD_CocoaWindow : NSWindow <NSTouchBarDelegate>
+@property (strong) NSSet *touchbarItems;
+- (NSImage*)generateImage:(int)spriteId;
+#else
@interface OTTD_CocoaWindow : NSWindow
+#endif
+
- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag driver:(VideoDriver_Cocoa *)drv;
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag;