Blender V5.0
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
51
53{
54 delete context_;
55}
56
58{
59 return nullptr;
60}
61
66
71
77
79{
80 if (type != drawing_context_type_) {
81 delete context_;
82 context_ = nullptr;
83
85 context_ = newDrawingContext(type);
86 }
87 if (context_ != nullptr) {
89 }
90 else {
93 }
94
96 }
97 return GHOST_kSuccess;
98}
99
101{
102 return context_;
103}
104
106{
107 return context_->swapBufferAcquire();
108}
110{
111 return context_->swapBufferRelease();
112}
113
115{
116 return context_->setSwapInterval(interval);
117}
118
120{
121 return context_->getSwapInterval(interval_out);
122}
123
125{
126 return context_;
127}
128
130{
131 return (context_) ? context_->getDefaultFramebuffer() : 0;
132}
133
134#ifdef WITH_VULKAN_BACKEND
135GHOST_TSuccess GHOST_Window::getVulkanSwapChainFormat(GHOST_VulkanSwapChainData *r_swap_chain_data)
136{
137 return context_->getVulkanSwapChainFormat(r_swap_chain_data);
138}
139#endif
140
142{
143 return context_->activateDrawingContext();
144}
145
147{
148 return context_->updateDrawingContext();
149}
150
152{
153 return context_->releaseNativeHandles();
154}
155
157{
158 if (setWindowCursorVisibility(visible)) {
159 cursor_visible_ = visible;
160 return GHOST_kSuccess;
161 }
162 return GHOST_kFailure;
163}
164
166 GHOST_TAxisFlag wrap_axis,
168 int32_t mouse_ungrab_xy[2])
169{
170 if (cursor_grab_ == mode) {
171 return GHOST_kSuccess;
172 }
173 /* Override with new location. */
174 if (mouse_ungrab_xy) {
175 assert(mode == GHOST_kGrabDisable);
176 cursor_grab_init_pos_[0] = mouse_ungrab_xy[0];
177 cursor_grab_init_pos_[1] = mouse_ungrab_xy[1];
178 }
179
180 if (setWindowCursorGrab(mode)) {
181
182 if (mode == GHOST_kGrabDisable) {
184 }
185 else if (bounds) {
187 }
188 else { /* if bounds not defined, use window */
190 }
191 cursor_grab_ = mode;
192 cursor_grab_axis_ = wrap_axis;
193 return GHOST_kSuccess;
194 }
195 return GHOST_kFailure;
196}
197
206
208 GHOST_TAxisFlag &wrap_axis,
210 bool &use_software_cursor)
211{
212 mode = cursor_grab_;
215 wrap_axis = cursor_grab_axis_;
216 }
217 else {
218 bounds.l_ = -1;
219 bounds.r_ = -1;
220 bounds.t_ = -1;
221 bounds.b_ = -1;
222 wrap_axis = GHOST_kAxisNone;
223 }
225 false;
226}
227
229{
230 /* Sub-classes may override, by default don't use software cursor. */
231 return false;
232}
233
235{
236 if (setWindowCursorShape(cursor_shape)) {
237 cursor_shape_ = cursor_shape;
238 return GHOST_kSuccess;
239 }
240 return GHOST_kFailure;
241}
242
244 const uint8_t *mask,
245 const int size[2],
246 const int hot_spot[2],
247 bool can_invert_color)
248{
249 if (setWindowCustomCursorShape(bitmap, mask, size, hot_spot, can_invert_color)) {
251 return GHOST_kSuccess;
252 }
253 return GHOST_kFailure;
254}
255
264
266{
267 /* Sub-classes may override. */
268 return GHOST_kFailure;
269}
270
272{
273 can_accept_drag_operation_ = can_accept;
274}
275
280
282{
283 is_unsaved_changes_ = is_unsaved_changes;
284
285 return GHOST_kSuccess;
286}
287
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:57
@ GHOST_kFailure
Definition GHOST_Types.h:57
@ GHOST_kSuccess
Definition GHOST_Types.h:57
GHOST_TGrabCursorMode
@ GHOST_kGrabWrap
@ GHOST_kGrabDisable
@ GHOST_kGrabHide
#define GHOST_CONTEXT_PARAMS_NONE
GHOST_TWindowDecorationStyleFlags
@ GHOST_kDecorationNone
return true
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
virtual void getClientBounds(GHOST_Rect &bounds) const =0
~GHOST_Window() override
GHOST_ContextParams want_context_params_
int32_t cursor_grab_accum_pos_[2]
GHOST_TSuccess swapBufferRelease() override
bool getCursorGrabUseSoftwareDisplay() override
float native_pixel_size_
virtual void setWindowDecorationStyleFlags(GHOST_TWindowDecorationStyleFlags style_flags) override
GHOST_TStandardCursor cursor_shape_
GHOST_TAxisFlag cursor_grab_axis_
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) const override
bool can_accept_drag_operation_
GHOST_TSuccess setModifiedState(bool is_unsaved_changes) override
void * getOSWindow() const override
GHOST_WindowDecorationStyleSettings window_decoration_style_settings_
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type) override
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor cursor_shape) override
uint32_t full_screen_width_
GHOST_Context * getContext()
int32_t cursor_grab_init_pos_[2]
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)
GHOST_TUserDataPtr user_data_
GHOST_TDrawingContextType drawing_context_type_
virtual GHOST_TWindowDecorationStyleFlags getWindowDecorationStyleFlags() override
GHOST_TSuccess releaseNativeHandles()
virtual GHOST_TSuccess setWindowCustomCursorGenerator(GHOST_CursorGenerator *cursor_generator)
virtual void setWindowDecorationStyleSettings(GHOST_WindowDecorationStyleSettings decoration_settings) override
GHOST_TWindowDecorationStyleFlags window_decoration_style_flags_
uint32_t full_screen_height_
bool getModifiedState() override
GHOST_TSuccess setCursorVisibility(bool visible) override
GHOST_TSuccess setCustomCursorShape(const uint8_t *bitmap, const uint8_t *mask, const int size[2], const int hot_spot[2], bool can_invert_color) override
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap) override
virtual GHOST_TSuccess setWindowCursorVisibility(bool visible)=0
void setAcceptDragOperation(bool can_accept) override
GHOST_TSuccess activateDrawingContext() override
GHOST_IContext * getDrawingContext() override
void getCursorGrabState(GHOST_TGrabCursorMode &mode, GHOST_TAxisFlag &wrap_axis, GHOST_Rect &bounds, bool &use_software_cursor) override
GHOST_TSuccess updateDrawingContext()
bool is_unsaved_changes_
GHOST_Window(uint32_t width, uint32_t height, GHOST_TWindowState state, const GHOST_ContextParams &context_params, const bool exclusive=false)
GHOST_TSuccess getSwapInterval(int &interval_out) override
virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape)=0
virtual GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)=0
GHOST_Rect cursor_grab_bounds_
bool progress_bar_visible_
GHOST_TSuccess swapBufferAcquire() override
GHOST_TGrabCursorMode cursor_grab_
GHOST_TSuccess setCustomCursorGenerator(GHOST_CursorGenerator *cursor_generator) override
virtual GHOST_TSuccess setWindowCustomCursorShape(const uint8_t *bitmap, const uint8_t *mask, const int size[2], const int hot_size[2], bool can_invert_color)=0
#define assert(assertion)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]