Blender V4.5
GHOST_WindowCocoa.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#ifndef __APPLE__
13# error Apple OSX only!
14#endif // __APPLE__
15
16#include "GHOST_Window.hh"
17#ifdef WITH_INPUT_IME
18# include "GHOST_Event.hh"
19#endif
20
21@class CAMetalLayer;
22@class CocoaMetalView;
23@class CocoaOpenGLView;
24@class BlenderWindow;
25@class NSCursor;
26@class NSScreen;
27
29
31 public:
48 const char *title,
50 int32_t bottom,
51 uint32_t width,
52 uint32_t height,
55 const bool stereoVisual,
56 bool is_debug,
57 bool dialog,
58 GHOST_WindowCocoa *parentWindow,
59 const GHOST_GPUDevice &preferred_device);
60
65 ~GHOST_WindowCocoa() override;
66
71 bool getValid() const override;
72
77 void *getOSWindow() const override;
78
83 void setTitle(const char *title) override;
88 std::string getTitle() const override;
89
94 GHOST_TSuccess setPath(const char *filepath) override;
95
100
107 void getWindowBounds(GHOST_Rect &bounds) const override;
108
114 void getClientBounds(GHOST_Rect &bounds) const override;
115
120 GHOST_TSuccess setClientWidth(uint32_t width) override;
121
126 GHOST_TSuccess setClientHeight(uint32_t height) override;
127
133 GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override;
134
139 GHOST_TWindowState getState() const override;
140
146 GHOST_TSuccess setModifiedState(bool isUnsavedChanges) override;
147
155 void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
156
164 void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
165
174 void clientToScreenIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
175
184 void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
185
190 NSScreen *getScreen() const;
191
198 static NSScreen *getPrimaryScreen();
199
206
213
214 NSCursor *getStandardCursor(GHOST_TStandardCursor cursor) const;
215 void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
216
217 bool isDialog() const override;
218
220 {
221 return m_tablet;
222 }
223
228 GHOST_TSuccess setProgressBar(float progress) override;
229
234
235 void setNativePixelSize();
236
239 {
240 return m_window;
241 };
242
243 /* Internal value to ensure proper redraws during animations */
244 void setImmediateDraw(bool value)
245 {
246 m_immediateDraw = value;
247 }
248 bool getImmediateDraw() const
249 {
250 return m_immediateDraw;
251 }
252
253#ifdef WITH_INPUT_IME
254 void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed) override;
255 void endIME() override;
256#endif /* WITH_INPUT_IME */
257
258 protected:
264
269 GHOST_TSuccess invalidate() override;
270
275 GHOST_TSuccess setWindowCursorVisibility(bool visible) override;
276
282
289
295 uint8_t *mask,
296 int sizex,
297 int sizey,
298 int hotX,
299 int hotY,
300 bool canInvertColor) override;
301
304
306 CocoaOpenGLView *m_openGLView;
307 CocoaMetalView *m_metalView;
308 CAMetalLayer *m_metalLayer;
309
312
313 NSCursor *m_customCursor;
314
316
318 bool m_debug_context; // for debug messages during context setup
321};
322
323#ifdef WITH_INPUT_IME
324class GHOST_EventIME : public GHOST_Event {
325 public:
332 GHOST_EventIME(uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window, void *customdata)
333 : GHOST_Event(msec, type, window)
334 {
335 this->m_data = customdata;
336 }
337};
338
339typedef int GHOST_ImeStateFlagCocoa;
340enum {
341 GHOST_IME_INPUT_FOCUSED = (1 << 0),
342 GHOST_IME_ENABLED = (1 << 1),
343 GHOST_IME_COMPOSING = (1 << 2),
344 GHOST_IME_KEY_CONTROL_CHAR = (1 << 3),
345 GHOST_IME_COMPOSITION_EVENT = (1 << 4), // For Korean input
346 GHOST_IME_RESULT_EVENT = (1 << 5) // For Korean input
347};
348#endif /* WITH_INPUT_IME */
GHOST_TWindowState
GHOST_TStandardCursor
GHOST_TEventType
GHOST_TDrawingContextType
GHOST_TWindowOrder
GHOST_TSuccess
Definition GHOST_Types.h:80
GHOST_TGrabCursorMode
float progress
Definition WM_types.hh:1019
unsigned long long int uint64_t
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
btAlignedObjectArray< btScalar > m_data
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
GHOST_Event(uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window)
bool isDialog() const override
GHOST_TSuccess setProgressBar(float progress) override
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override
GHOST_SystemCocoa * m_systemCocoa
bool getImmediateDraw() const
GHOST_TSuccess setState(GHOST_TWindowState state) override
std::string getTitle() const override
BlenderWindow * m_window
void setImmediateDraw(bool value)
GHOST_TSuccess setClientHeight(uint32_t height) override
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
NSScreen * getScreen() const
void setTitle(const char *title) override
GHOST_TSuccess setModifiedState(bool isUnsavedChanges) override
GHOST_TSuccess invalidate() override
CocoaOpenGLView * m_openGLView
CAMetalLayer * m_metalLayer
GHOST_TSuccess endProgressBar() override
NSCursor * getStandardCursor(GHOST_TStandardCursor cursor) const
GHOST_TWindowState getState() const override
GHOST_TSuccess setClientWidth(uint32_t width) override
GHOST_GPUDevice m_preferred_device
GHOST_TabletData m_tablet
GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa, const char *title, int32_t left, int32_t bottom, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_TDrawingContextType type, const bool stereoVisual, bool is_debug, bool dialog, GHOST_WindowCocoa *parentWindow, const GHOST_GPUDevice &preferred_device)
GHOST_TSuccess applyWindowDecorationStyle() override
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape) override
void clientToScreenIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
void * getOSWindow() const override
GHOST_TabletData & GetCocoaTabletData()
void getClientBounds(GHOST_Rect &bounds) const override
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
void getWindowBounds(GHOST_Rect &bounds) const override
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type) override
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override
GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor) override
static NSScreen * getPrimaryScreen()
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override
void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
CocoaMetalView * m_metalView
GHOST_TSuccess setPath(const char *filepath) override
bool getValid() const override
GHOST_TSuccess setWindowCursorVisibility(bool visible) override
BlenderWindow * getViewWindow() const
void loadCursor(bool visible, GHOST_TStandardCursor cursor) const
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override
GHOST_Window(uint32_t width, uint32_t height, GHOST_TWindowState state, const bool wantStereoVisual=false, const bool exclusive=false)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]
static int left