Files
test/intern/ghost/intern/GHOST_WindowSDL.hh
Campbell Barton ebfa7edeb1 Cleanup: use snake case, replace "m_" prefix with "_" suffix
Follow our own C++ conventions for GHOST.
2025-08-16 16:14:18 +10:00

120 lines
3.1 KiB
C++

/* SPDX-FileCopyrightText: 2011-2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup GHOST
* Declaration of GHOST_WindowSDL class.
*/
#pragma once
#include "GHOST_SystemSDL.hh"
#include "GHOST_Window.hh"
#include <map>
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(2, 0, 0)
# error "SDL 2.0 or newer is needed to build with Ghost"
#endif
class GHOST_SystemSDL;
class GHOST_WindowSDL : public GHOST_Window {
private:
GHOST_SystemSDL *system_;
bool valid_setup_;
bool invalid_window_;
SDL_Window *sdl_win_;
SDL_Cursor *sdl_custom_cursor_;
public:
GHOST_WindowSDL(GHOST_SystemSDL *system,
const char *title,
int32_t left,
int32_t top,
uint32_t width,
uint32_t height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const GHOST_ContextParams &context_params,
const bool exclusive = false,
const GHOST_IWindow *parent_window = nullptr);
~GHOST_WindowSDL();
/* SDL specific */
SDL_Window *getSDLWindow()
{
return sdl_win_;
}
GHOST_TSuccess invalidate() override;
/**
* called by the X11 system implementation when expose events
* for the window have been pushed onto the GHOST queue
*/
void validate()
{
invalid_window_ = false;
}
bool getValid() const override;
void getWindowBounds(GHOST_Rect &bounds) const override;
void getClientBounds(GHOST_Rect &bounds) const override;
protected:
/**
* \param type: The type of rendering context create.
* \return Indication of success.
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type) override;
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override;
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override;
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape) 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;
GHOST_TSuccess setWindowCursorVisibility(bool visible) override;
void setTitle(const char *title) override;
std::string getTitle() const override;
GHOST_TSuccess setClientWidth(uint32_t width) override;
GHOST_TSuccess setClientHeight(uint32_t height) override;
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override;
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override;
GHOST_TSuccess setState(GHOST_TWindowState state) override;
GHOST_TWindowState getState() const override;
GHOST_TSuccess setOrder(GHOST_TWindowOrder /*order*/) override
{
// TODO
return GHOST_kSuccess;
}
uint16_t getDPIHint() override;
};