Blender V4.5
GHOST_Window.cc
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
8
12
13#include "GHOST_Window.hh"
14
15#include "GHOST_ContextNone.hh"
16
17#include <cassert>
18
49
51{
52 delete m_context;
53}
54
56{
57 return nullptr;
58}
59
64
69
75
77{
78 if (type != m_drawingContextType) {
79 delete m_context;
80 m_context = nullptr;
81
83 m_context = newDrawingContext(type);
84 }
85 if (m_context != nullptr) {
87 }
88 else {
91 }
92
94 }
95 return GHOST_kSuccess;
96}
97
99{
100 return m_context;
101}
102
104{
105 return m_context->swapBuffers();
106}
107
109{
110 return m_context->setSwapInterval(interval);
111}
112
114{
115 return m_context->getSwapInterval(intervalOut);
116}
117
119{
120 return m_context;
121}
122
124{
125 return (m_context) ? m_context->getDefaultFramebuffer() : 0;
126}
127
128#ifdef WITH_VULKAN_BACKEND
129GHOST_TSuccess GHOST_Window::getVulkanSwapChainFormat(GHOST_VulkanSwapChainData *r_swap_chain_data)
130{
131 return m_context->getVulkanSwapChainFormat(r_swap_chain_data);
132}
133#endif
134
136{
137 return m_context->activateDrawingContext();
138}
139
141{
142 return m_context->updateDrawingContext();
143}
144
146{
147 return m_context->releaseNativeHandles();
148}
149
151{
152 if (setWindowCursorVisibility(visible)) {
153 m_cursorVisible = visible;
154 return GHOST_kSuccess;
155 }
156 return GHOST_kFailure;
157}
158
160 GHOST_TAxisFlag wrap_axis,
162 int32_t mouse_ungrab_xy[2])
163{
164 if (m_cursorGrab == mode) {
165 return GHOST_kSuccess;
166 }
167 /* Override with new location. */
168 if (mouse_ungrab_xy) {
169 assert(mode == GHOST_kGrabDisable);
170 m_cursorGrabInitPos[0] = mouse_ungrab_xy[0];
171 m_cursorGrabInitPos[1] = mouse_ungrab_xy[1];
172 }
173
174 if (setWindowCursorGrab(mode)) {
175
176 if (mode == GHOST_kGrabDisable) {
178 }
179 else if (bounds) {
181 }
182 else { /* if bounds not defined, use window */
184 }
185 m_cursorGrab = mode;
186 m_cursorGrabAxis = wrap_axis;
187 return GHOST_kSuccess;
188 }
189 return GHOST_kFailure;
190}
191
200
202 GHOST_TAxisFlag &wrap_axis,
204 bool &use_software_cursor)
205{
206 mode = m_cursorGrab;
209 wrap_axis = m_cursorGrabAxis;
210 }
211 else {
212 bounds.m_l = -1;
213 bounds.m_r = -1;
214 bounds.m_t = -1;
215 bounds.m_b = -1;
216 wrap_axis = GHOST_kAxisNone;
217 }
219 false;
220}
221
223{
224 /* Sub-classes may override, by default don't use software cursor. */
225 return false;
226}
227
229{
230 if (setWindowCursorShape(cursorShape)) {
231 m_cursorShape = cursorShape;
232 return GHOST_kSuccess;
233 }
234 return GHOST_kFailure;
235}
236
238 uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
239{
240 if (setWindowCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, canInvertColor)) {
242 return GHOST_kSuccess;
243 }
244 return GHOST_kFailure;
245}
246
248{
249 /* Sub-classes may override. */
250 return GHOST_kFailure;
251}
252
254{
255 m_canAcceptDragOperation = canAccept;
256}
257
262
264{
265 m_isUnsavedChanges = isUnsavedChanges;
266
267 return GHOST_kSuccess;
268}
269
KDTree *BLI_kdtree_nd_ new(unsigned int nodes_len_capacity)
Definition kdtree_impl.h:97
unsigned int uint
GHOST_TWindowState
@ GHOST_kWindowStateFullScreen
GHOST_TStandardCursor
@ GHOST_kStandardCursorCustom
@ GHOST_kStandardCursorDefault
GHOST_TAxisFlag
@ GHOST_kAxisNone
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeNone
GHOST_TSuccess
Definition GHOST_Types.h:80
@ GHOST_kFailure
Definition GHOST_Types.h:80
@ GHOST_kSuccess
Definition GHOST_Types.h:80
GHOST_TGrabCursorMode
@ GHOST_kGrabWrap
@ GHOST_kGrabDisable
@ GHOST_kGrabHide
GHOST_TWindowDecorationStyleFlags
@ GHOST_kDecorationNone
return true
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
virtual void getClientBounds(GHOST_Rect &bounds) const =0
GHOST_TWindowDecorationStyleFlags m_windowDecorationStyleFlags
~GHOST_Window() override
GHOST_TSuccess setCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor) override
GHOST_TSuccess getSwapInterval(int &intervalOut) override
GHOST_Rect m_cursorGrabBounds
GHOST_WindowDecorationStyleSettings m_windowDecorationStyleSettings
bool getCursorGrabUseSoftwareDisplay() override
virtual void setWindowDecorationStyleSettings(GHOST_WindowDecorationStyleSettings decorationSettings) override
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) const override
void * getOSWindow() const override
GHOST_TGrabCursorMode m_cursorGrab
int32_t m_cursorGrabAccumPos[2]
bool m_wantStereoVisual
int32_t m_cursorGrabInitPos[2]
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) override
GHOST_TStandardCursor m_cursorShape
GHOST_Context * getContext()
bool canAcceptDragOperation() const override
GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_TAxisFlag wrap_axis, GHOST_Rect *bounds, int32_t mouse_ungrab_xy[2]) override
unsigned int getDefaultFramebuffer() override
GHOST_TSuccess setSwapInterval(int interval) override
virtual GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode)
virtual GHOST_TWindowDecorationStyleFlags getWindowDecorationStyleFlags() override
GHOST_TSuccess releaseNativeHandles()
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursorShape) override
GHOST_TAxisFlag m_cursorGrabAxis
virtual GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int szx, int szy, int hotX, int hotY, bool canInvertColor)=0
bool getModifiedState() override
GHOST_TSuccess setCursorVisibility(bool visible) override
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap) override
virtual GHOST_TSuccess setWindowCursorVisibility(bool visible)=0
GHOST_TDrawingContextType m_drawingContextType
GHOST_TSuccess activateDrawingContext() override
GHOST_TSuccess swapBuffers() override
uint32_t m_fullScreenHeight
GHOST_IContext * getDrawingContext() override
bool m_isUnsavedChanges
GHOST_Window(uint32_t width, uint32_t height, GHOST_TWindowState state, const bool wantStereoVisual=false, const bool exclusive=false)
float m_nativePixelSize
void getCursorGrabState(GHOST_TGrabCursorMode &mode, GHOST_TAxisFlag &wrap_axis, GHOST_Rect &bounds, bool &use_software_cursor) override
GHOST_TSuccess updateDrawingContext()
GHOST_TUserDataPtr m_userData
virtual void setWindowDecorationStyleFlags(GHOST_TWindowDecorationStyleFlags styleFlags) override
void setAcceptDragOperation(bool canAccept) override
GHOST_TSuccess setModifiedState(bool isUnsavedChanges) override
bool m_progressBarVisible
virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape)=0
virtual GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)=0
bool m_canAcceptDragOperation
uint32_t m_fullScreenWidth
#define assert(assertion)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]