blender/intern/ghost/intern/GHOST_WindowSDL.h
Wouter fe3fb23697 Automatic DPI for all platforms, per monitor DPI for Windows.
For Windows 8.1 and X11 (Linux, BSD) now use the DPI specified by the operating
system, which previously only worked on macOS. For Windows this is handled per
monitor, for X11 this is based on Xft.dpi or xrandr --dpi. This should result
in appropriate font and button sizes by default in most cases.

The UI has been simplified to a single UI Scale factor relative to the automatic
DPI, instead of two DPI and Virtual Pixel Size settings. There is forward and
backwards compatibility for existing user preferences.

Reviewed By: brecht, LazyDodo

Differential Revision: https://developer.blender.org/D2539
2017-03-25 11:22:16 +01:00

177 lines
4.2 KiB
C++

/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_WindowSDL.h
* \ingroup GHOST
* Declaration of GHOST_WindowSDL class.
*/
#ifndef __GHOST_WINDOWSDL_H__
#define __GHOST_WINDOWSDL_H__
#include "GHOST_Window.h"
#include "GHOST_SystemSDL.h"
#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 STR_String;
class GHOST_SystemSDL;
class GHOST_WindowSDL : public GHOST_Window
{
private:
GHOST_SystemSDL *m_system;
bool m_valid_setup;
bool m_invalid_window;
SDL_Window *m_sdl_win;
SDL_Cursor *m_sdl_custom_cursor;
public:
const GHOST_TabletData *GetTabletData() {
return NULL;
}
GHOST_WindowSDL(GHOST_SystemSDL *system,
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top,
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const bool exclusive = false,
const GHOST_TUns16 numOfAASamples = 0
);
~GHOST_WindowSDL();
/* SDL specific */
SDL_Window *
getSDLWindow()
{
return m_sdl_win;
}
GHOST_TSuccess invalidate(void);
/**
* called by the X11 system implementation when expose events
* for the window have been pushed onto the GHOST queue
*/
void validate()
{
m_invalid_window = false;
}
bool getValid() const;
void getWindowBounds(GHOST_Rect& bounds) const;
void getClientBounds(GHOST_Rect& bounds) const;
protected:
/**
* \param type The type of rendering context create.
* \return Indication of success.
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
GHOST_TSuccess
setWindowCursorGrab(GHOST_TGrabCursorMode mode);
GHOST_TSuccess
setWindowCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess
setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX, int hotY);
GHOST_TSuccess
setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex, int sizey,
int hotX, int hotY,
int fg_color, int bg_color);
GHOST_TSuccess
setWindowCursorVisibility(bool visible);
void
setTitle(const STR_String& title);
void
getTitle(STR_String& title) const;
GHOST_TSuccess
setClientWidth(GHOST_TUns32 width);
GHOST_TSuccess
setClientHeight(GHOST_TUns32 height);
GHOST_TSuccess
setClientSize(GHOST_TUns32 width,
GHOST_TUns32 height);
void
screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32& outX, GHOST_TInt32& outY) const;
void
clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32& outX, GHOST_TInt32& outY) const;
GHOST_TSuccess
setState(GHOST_TWindowState state);
GHOST_TWindowState
getState() const;
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
{
// TODO
return GHOST_kSuccess;
}
// TODO
GHOST_TSuccess beginFullScreen() const { return GHOST_kFailure; }
GHOST_TSuccess endFullScreen() const { return GHOST_kFailure; }
GHOST_TUns16 getDPIHint();
};
#endif // __GHOST_WINDOWSDL_H__