Blender V5.3
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,
49 int32_t left,
50 int32_t bottom,
51 uint32_t width,
52 uint32_t height,
55 const GHOST_ContextParams &context_params,
56 bool dialog,
57 GHOST_WindowCocoa *parent_window,
58 const GHOST_GPUDevice &preferred_device);
59
64 ~GHOST_WindowCocoa() override;
65
70 bool getValid() const override;
71
76 void *getOSWindow() const override;
77
82 void setTitle(const char *title) override;
87 std::string getTitle() const override;
88
93 void setPath(const char *filepath) override;
94
99
106 void getWindowBounds(GHOST_Rect &bounds) const override;
107
113 void getClientBounds(GHOST_Rect &bounds) const override;
114
119 GHOST_TSuccess setClientWidth(uint32_t width) override;
120
125 GHOST_TSuccess setClientHeight(uint32_t height) override;
126
132 GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override;
133
138 GHOST_TWindowState getState() const override;
139
145 GHOST_TSuccess setModifiedState(bool is_unsaved_changes) override;
146
154 void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
155
163 void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
164
173 void clientToScreenIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
174
183 void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const;
184
189 NSScreen *getScreen() const;
190
197 static NSScreen *getPrimaryScreen();
198
205
212
213 NSCursor *getStandardCursor(GHOST_TStandardCursor cursor) const;
214 void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
215
216 bool isDialog() const override;
217
219 {
220 return tablet_;
221 }
222
227 GHOST_TSuccess setProgressBar(float progress) override;
228
233
234 void setNativePixelSize();
235
236 void updateDrawingSize();
237
240 {
241 return window_;
242 };
243
244 /* Internal value to ensure proper redraws during animations */
245 void setImmediateDraw(bool value)
246 {
247 immediate_draw_ = value;
248 }
249 bool getImmediateDraw() const
250 {
251 return immediate_draw_;
252 }
253
254#ifdef WITH_INPUT_IME
255 void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed) override;
256 void endIME() override;
257#endif /* WITH_INPUT_IME */
258
259 protected:
265
270 GHOST_TSuccess invalidate() override;
271
276 GHOST_TSuccess setWindowCursorVisibility(bool visible) override;
277
283
290
295 GHOST_TSuccess setWindowCustomCursorShape(const uint8_t *bitmap,
296 const uint8_t *mask,
297 const int size[2],
298 const int hot_spot[2],
299 bool can_invert_color) override;
300
303
305 CocoaOpenGLView *opengl_view_;
306 CocoaMetalView *metal_view_;
307 CAMetalLayer *metal_layer_;
308
311
312 NSCursor *custom_cursor_;
313
315
319};
320
321#ifdef WITH_INPUT_IME
322class GHOST_EventIME : public GHOST_Event {
323 public:
330 GHOST_EventIME(uint64_t msec,
331 GHOST_TEventType type,
332 GHOST_IWindow *window,
333 const void *customdata)
334 : GHOST_Event(msec, type, window)
335 {
336 this->data_ = customdata;
337 }
338};
339
340typedef int GHOST_ImeStateFlagCocoa;
341enum {
342 GHOST_IME_INPUT_FOCUSED = (1 << 0),
343 GHOST_IME_ENABLED = (1 << 1),
344 GHOST_IME_COMPOSING = (1 << 2),
345 GHOST_IME_KEY_CONTROL_CHAR = (1 << 3),
346 GHOST_IME_COMPOSITION_EVENT = (1 << 4), // For Korean input
347 GHOST_IME_RESULT_EVENT = (1 << 5) // For Korean input
348};
349#endif /* WITH_INPUT_IME */
GHOST_TWindowState
GHOST_TStandardCursor
GHOST_TEventType
GHOST_TDrawingContextType
GHOST_TWindowOrder
GHOST_TSuccess
GHOST_TGrabCursorMode
SIMD_FORCE_INLINE void invalidate()
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
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)
BlenderWindow * window_
bool isDialog() const override
GHOST_TSuccess setProgressBar(float progress) override
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override
bool getImmediateDraw() const
GHOST_TSuccess setState(GHOST_TWindowState state) override
std::string getTitle() const override
GHOST_SystemCocoa * system_cocoa_
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
CAMetalLayer * metal_layer_
NSScreen * getScreen() const
void setTitle(const char *title) override
GHOST_TSuccess endProgressBar() override
NSCursor * getStandardCursor(GHOST_TStandardCursor cursor) const
GHOST_TWindowState getState() const override
GHOST_TSuccess setClientWidth(uint32_t width) override
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()
CocoaOpenGLView * opengl_view_
void getClientBounds(GHOST_Rect &bounds) const override
GHOST_TSuccess setModifiedState(bool is_unsaved_changes) 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(const uint8_t *bitmap, const uint8_t *mask, const int size[2], const int hot_spot[2], bool can_invert_color) override
static NSScreen * getPrimaryScreen()
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 GHOST_ContextParams &context_params, bool dialog, GHOST_WindowCocoa *parent_window, const GHOST_GPUDevice &preferred_device)
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override
CocoaMetalView * metal_view_
void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
GHOST_GPUDevice preferred_device_
void setPath(const char *filepath) override
bool getValid() const override
GHOST_TSuccess setWindowCursorVisibility(bool visible) override
BlenderWindow * getViewWindow() const
GHOST_TabletData tablet_
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 GHOST_ContextParams &context_params, const bool exclusive=false)
const int state
ccl_device_inline float2 mask(const MaskType mask, const float2 a)