diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_Window.cpp')
-rw-r--r-- | intern/ghost/intern/GHOST_Window.cpp | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp index 834836a7f4d..3f093840d0c 100644 --- a/intern/ghost/intern/GHOST_Window.cpp +++ b/intern/ghost/intern/GHOST_Window.cpp @@ -13,7 +13,7 @@ #include "GHOST_ContextNone.h" -#include <assert.h> +#include <cassert> GHOST_Window::GHOST_Window(uint32_t width, uint32_t height, @@ -51,19 +51,19 @@ GHOST_Window::~GHOST_Window() void *GHOST_Window::getOSWindow() const { - return NULL; + return nullptr; } GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type) { if (type != m_drawingContextType) { delete m_context; - m_context = NULL; + m_context = nullptr; - if (type != GHOST_kDrawingContextTypeNone) + if (type != GHOST_kDrawingContextTypeNone) { m_context = newDrawingContext(type); - - if (m_context != NULL) { + } + if (m_context != nullptr) { m_drawingContextType = type; } else { @@ -73,9 +73,7 @@ GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType typ return (type == m_drawingContextType) ? GHOST_kSuccess : GHOST_kFailure; } - else { - return GHOST_kSuccess; - } + return GHOST_kSuccess; } GHOST_TSuccess GHOST_Window::swapBuffers() @@ -119,9 +117,7 @@ GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible) m_cursorVisible = visible; return GHOST_kSuccess; } - else { - return GHOST_kFailure; - } + return GHOST_kFailure; } GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, @@ -129,10 +125,10 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds, int32_t mouse_ungrab_xy[2]) { - if (m_cursorGrab == mode) + if (m_cursorGrab == mode) { return GHOST_kSuccess; - - /* override with new location */ + } + /* Override with new location. */ if (mouse_ungrab_xy) { assert(mode == GHOST_kGrabDisable); m_cursorGrabInitPos[0] = mouse_ungrab_xy[0]; @@ -154,26 +150,52 @@ GHOST_TSuccess GHOST_Window::setCursorGrab(GHOST_TGrabCursorMode mode, m_cursorGrabAxis = wrap_axis; return GHOST_kSuccess; } - else { - return GHOST_kFailure; - } + return GHOST_kFailure; } GHOST_TSuccess GHOST_Window::getCursorGrabBounds(GHOST_Rect &bounds) { + if (m_cursorGrab != GHOST_kGrabWrap) { + return GHOST_kFailure; + } bounds = m_cursorGrabBounds; return (bounds.m_l == -1 && bounds.m_r == -1) ? GHOST_kFailure : GHOST_kSuccess; } +void GHOST_Window::getCursorGrabState(GHOST_TGrabCursorMode &mode, + GHOST_TAxisFlag &wrap_axis, + GHOST_Rect &bounds, + bool &use_software_cursor) +{ + mode = m_cursorGrab; + if (m_cursorGrab == GHOST_kGrabWrap) { + bounds = m_cursorGrabBounds; + wrap_axis = m_cursorGrabAxis; + } + else { + bounds.m_l = -1; + bounds.m_r = -1; + bounds.m_t = -1; + bounds.m_b = -1; + wrap_axis = GHOST_kGrabAxisNone; + } + use_software_cursor = (m_cursorGrab != GHOST_kGrabDisable) ? getCursorGrabUseSoftwareDisplay() : + false; +} + +bool GHOST_Window::getCursorGrabUseSoftwareDisplay() +{ + /* Sub-classes may override, by default don't use software cursor. */ + return false; +} + GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape) { if (setWindowCursorShape(cursorShape)) { m_cursorShape = cursorShape; return GHOST_kSuccess; } - else { - return GHOST_kFailure; - } + return GHOST_kFailure; } GHOST_TSuccess GHOST_Window::setCustomCursorShape( @@ -183,9 +205,13 @@ GHOST_TSuccess GHOST_Window::setCustomCursorShape( m_cursorShape = GHOST_kStandardCursorCustom; return GHOST_kSuccess; } - else { - return GHOST_kFailure; - } + return GHOST_kFailure; +} + +GHOST_TSuccess GHOST_Window::getCursorBitmap(GHOST_CursorBitmapRef * /*bitmap*/) +{ + /* Sub-classes may override. */ + return GHOST_kFailure; } void GHOST_Window::setAcceptDragOperation(bool canAccept) |