From 27a455c61dcaabab56f1ad1ab78fb8fb7f8b4d4e Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 8 Feb 2017 23:22:12 -1000 Subject: [PATCH] Touch Bar support --- include/boo/IWindow.hpp | 2 ++ lib/mac/WindowCocoa.mm | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/boo/IWindow.hpp b/include/boo/IWindow.hpp index a83a109..3eb6ad8 100644 --- a/include/boo/IWindow.hpp +++ b/include/boo/IWindow.hpp @@ -304,6 +304,8 @@ public: virtual void setStyle(EWindowStyle style)=0; virtual EWindowStyle getStyle() const=0; + virtual void setTouchBarProvider(void*) {} + virtual IGraphicsCommandQueue* getCommandQueue()=0; virtual IGraphicsDataFactory* getDataFactory()=0; diff --git a/lib/mac/WindowCocoa.mm b/lib/mac/WindowCocoa.mm index b33041c..63ea9ab 100644 --- a/lib/mac/WindowCocoa.mm +++ b/lib/mac/WindowCocoa.mm @@ -18,10 +18,12 @@ namespace boo {class WindowCocoa; class GraphicsContextCocoa;} @interface WindowCocoaInternal : NSWindow { boo::WindowCocoa* booWindow; + id touchBarProvider; } - (id)initWithBooWindow:(boo::WindowCocoa*)bw title:(const std::string&)title; - (void)setFrameDefault; - (NSRect)genFrameDefault; +- (void)setTouchBarProvider:(id)provider; @end /* AppKit applies OpenGL much differently than other platforms @@ -1490,6 +1492,14 @@ public: return retval; } + void setTouchBarProvider(void* provider) + { + dispatch_sync(dispatch_get_main_queue(), + ^{ + [m_nsWindow setTouchBarProvider:(__bridge_transfer id)provider]; + }); + } + void waitForRetrace() { static_cast(m_gfxCtx)->waitForRetrace(); @@ -1560,6 +1570,15 @@ IWindow* _WindowCocoaNew(const SystemString& title, NSOpenGLContext* lastGLCtx, (scrFrame.size.height - height) / 2.0, width, height); } +- (void)setTouchBarProvider:(id)provider +{ + touchBarProvider = provider; + self.touchBar = nil; +} +- (NSTouchBar*)makeTouchBar +{ + return [touchBarProvider makeTouchBar]; +} - (void)close { booWindow->_clearWindow();