Files
test/intern/ghost/intern/GHOST_C-api.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

972 lines
29 KiB
C++
Raw Normal View History

/*
2002-10-12 11:37:38 +00:00
* 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.
2002-10-12 11:37:38 +00:00
*
* 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,
2010-02-12 13:34:04 +00:00
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2002-10-12 11:37:38 +00:00
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
/** \file
* \ingroup GHOST
2002-10-12 11:37:38 +00:00
*
* C Api for GHOST
*/
#include <stdlib.h>
#include <string.h>
2002-10-12 11:37:38 +00:00
#include "GHOST_C-api.h"
#include "GHOST_IEvent.h"
#include "GHOST_IEventConsumer.h"
#include "GHOST_ISystem.h"
#include "intern/GHOST_Debug.h"
#ifdef WITH_XR_OPENXR
# include "GHOST_IXrContext.h"
#endif
2002-10-12 11:37:38 +00:00
#include "intern/GHOST_CallbackEventConsumer.h"
#include "intern/GHOST_XrException.h"
2002-10-12 11:37:38 +00:00
GHOST_SystemHandle GHOST_CreateSystem(void)
{
GHOST_ISystem::createSystem();
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = GHOST_ISystem::getSystem();
2002-10-12 11:37:38 +00:00
return (GHOST_SystemHandle)system;
}
void GHOST_SystemInitDebug(GHOST_SystemHandle systemhandle, int is_debug_enabled)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
system->initDebug(is_debug_enabled);
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return system->disposeSystem();
}
void GHOST_ShowMessageBox(GHOST_SystemHandle systemhandle,
const char *title,
const char *message,
const char *help_label,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
system->showMessageBox(title, message, help_label, continue_label, link, dialog_options);
}
2011-12-24 02:32:08 +00:00
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback,
GHOST_TUserDataPtr userdata)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer(eventCallback, userdata);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle)
{
2012-05-19 09:57:55 +00:00
delete ((GHOST_CallbackEventConsumer *)consumerhandle);
2002-10-12 11:37:38 +00:00
return GHOST_kSuccess;
}
GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return system->getMilliSeconds();
}
GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TUns64 delay,
GHOST_TUns64 interval,
GHOST_TimerProcPtr timerproc,
GHOST_TUserDataPtr userdata)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return (GHOST_TimerTaskHandle)system->installTimer(delay, interval, timerproc, userdata);
}
GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TimerTaskHandle timertaskhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *)timertaskhandle;
2002-10-12 11:37:38 +00:00
return system->removeTimer(timertask);
}
GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return system->getNumDisplays();
}
void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TUns32 *width,
GHOST_TUns32 *height)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
system->getMainDisplayDimensions(*width, *height);
}
void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *width,
GHOST_TUns32 *height)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
system->getAllDisplayDimensions(*width, *height);
}
2002-10-12 11:37:38 +00:00
GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle,
GHOST_GLSettings glSettings)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
return (GHOST_ContextHandle)system->createOffscreenContext(glSettings);
}
GHOST_TSuccess GHOST_DisposeOpenGLContext(GHOST_SystemHandle systemhandle,
GHOST_ContextHandle contexthandle)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
return system->disposeContext(context);
}
2002-10-12 11:37:38 +00:00
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
const char *title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
GHOST_GLSettings glSettings)
2012-05-19 09:57:55 +00:00
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return (GHOST_WindowHandle)system->createWindow(
UI: Register File Browser as Child/Dialog-Window for the OS For many users, this will make the File Browser window behave more like what they would expect. It addresses the issue of the File Browser becoming hidden behind the main window by clicking anywhere in the latter. It communicates the interruptive, but temporary nature of the operation a bit better. Further, on tiling window managers the File Browser now opens as floating by default, like in other applications. Note that this also makes sure the File Browser is always opened as separate window, so it doesn't re-use the Preferences, or any other temporary window anymore. This seems to have been a common annoyance. More concretely, this makes the File Browser window behave as follows: * Stays on top of its parent Blender window, but not on top of non-Blender windows. * Minimizes with its parent window * Can be moved independently * Doesn't add an own item in task bars * Doesn't block other Blender windows (we may want to have this though) * Opens as floating window for tiling window managers (e.g. i3wm/Sway) Further notes: * When opening a file browser from the Preference window (or any temporary window), the main window, as the file browsers parent is moved on top of the Preferences, which makes it seem like the Preferences were closed. This is the general issue of bad secondary window handling as window activation changes. I made it so that the window is moved back once the file browser is closed. This behavior is confusing and would be nice to avoid. It's a separate issue though. * On most window managers on Linux the temporary window can not be minimized and maximized, they disable that for dialog windows. * On Windows and macOS, only minimizing is disabled, as there is no decent way yet to restore a window if it's not shown in the taskbar. Reviewed By: Brecht van Lommel, Campbell Barton, William Reynish Edits and macOS implementation by Brecht. Differential Revision: https://developer.blender.org/D5810 Part of T69652.
2019-10-03 16:59:49 +02:00
title, left, top, width, height, state, type, glSettings, false, false);
}
GHOST_WindowHandle GHOST_CreateDialogWindow(GHOST_SystemHandle systemhandle,
GHOST_WindowHandle parent_windowhandle,
const char *title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
GHOST_GLSettings glSettings)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
return (GHOST_WindowHandle)system->createWindow(title,
left,
top,
width,
height,
state,
type,
glSettings,
false,
true,
(GHOST_IWindow *)parent_windowhandle);
2002-10-12 11:37:38 +00:00
}
GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->getUserData();
}
void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr userdata)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
window->setUserData(userdata);
}
UI: Register File Browser as Child/Dialog-Window for the OS For many users, this will make the File Browser window behave more like what they would expect. It addresses the issue of the File Browser becoming hidden behind the main window by clicking anywhere in the latter. It communicates the interruptive, but temporary nature of the operation a bit better. Further, on tiling window managers the File Browser now opens as floating by default, like in other applications. Note that this also makes sure the File Browser is always opened as separate window, so it doesn't re-use the Preferences, or any other temporary window anymore. This seems to have been a common annoyance. More concretely, this makes the File Browser window behave as follows: * Stays on top of its parent Blender window, but not on top of non-Blender windows. * Minimizes with its parent window * Can be moved independently * Doesn't add an own item in task bars * Doesn't block other Blender windows (we may want to have this though) * Opens as floating window for tiling window managers (e.g. i3wm/Sway) Further notes: * When opening a file browser from the Preference window (or any temporary window), the main window, as the file browsers parent is moved on top of the Preferences, which makes it seem like the Preferences were closed. This is the general issue of bad secondary window handling as window activation changes. I made it so that the window is moved back once the file browser is closed. This behavior is confusing and would be nice to avoid. It's a separate issue though. * On most window managers on Linux the temporary window can not be minimized and maximized, they disable that for dialog windows. * On Windows and macOS, only minimizing is disabled, as there is no decent way yet to restore a window if it's not shown in the taskbar. Reviewed By: Brecht van Lommel, Campbell Barton, William Reynish Edits and macOS implementation by Brecht. Differential Revision: https://developer.blender.org/D5810 Part of T69652.
2019-10-03 16:59:49 +02:00
int GHOST_IsDialogWindow(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return (int)window->isDialog();
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_WindowHandle windowhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return system->disposeWindow(window);
}
int GHOST_ValidWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return (int)system->validWindow(window);
}
GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_DisplaySetting *setting,
const int stereoVisual)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_IWindow *window = NULL;
2002-10-12 11:37:38 +00:00
bool bstereoVisual;
if (stereoVisual)
2002-10-12 11:37:38 +00:00
bstereoVisual = true;
else
2002-10-12 11:37:38 +00:00
bstereoVisual = false;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
system->beginFullScreen(*setting, &window, bstereoVisual);
return (GHOST_WindowHandle)window;
}
GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return system->endFullScreen();
}
int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
return (int)system->getFullScreen();
}
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
2012-05-19 09:57:55 +00:00
return (int)system->processEvents(waitForEvent ? true : false);
2002-10-12 11:37:38 +00:00
}
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
system->dispatchEvents();
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle,
GHOST_EventConsumerHandle consumerhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
2012-05-19 09:57:55 +00:00
return system->addEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle,
GHOST_EventConsumerHandle consumerhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2012-05-19 09:57:55 +00:00
return system->removeEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
}
2012-05-19 09:57:55 +00:00
GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->setProgressBar(progress);
}
GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->endProgressBar();
}
2002-10-12 11:37:38 +00:00
GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->getCursorShape();
}
GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TStandardCursor cursorshape)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setCursorShape(cursorshape);
}
GHOST_TSuccess GHOST_HasCursorShape(GHOST_WindowHandle windowhandle,
GHOST_TStandardCursor cursorshape)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->hasCursorShape(cursorshape);
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex,
int sizey,
2012-05-19 09:57:55 +00:00
int hotX,
int hotY,
GHOST_TUns8 canInvertColor)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setCustomCursorShape(bitmap, mask, sizex, sizey, hotX, hotY, canInvertColor);
}
2002-10-12 11:37:38 +00:00
int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return (int)window->getCursorVisibility();
}
GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle, int visible)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
2012-05-19 09:57:55 +00:00
return window->setCursorVisibility(visible ? true : false);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 *x,
GHOST_TInt32 *y)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return system->getCursorPosition(*x, *y);
}
GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 x,
GHOST_TInt32 y)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return system->setCursorPosition(x, y);
}
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TGrabCursorMode mode,
GHOST_TAxisFlag wrap_axis,
int bounds[4],
const int mouse_ungrab_xy[2])
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
GHOST_Rect bounds_rect;
GHOST_TInt32 mouse_xy[2];
2012-05-19 09:57:55 +00:00
if (bounds) {
bounds_rect = GHOST_Rect(bounds[0], bounds[1], bounds[2], bounds[3]);
}
if (mouse_ungrab_xy) {
mouse_xy[0] = mouse_ungrab_xy[0];
mouse_xy[1] = mouse_ungrab_xy[1];
}
return window->setCursorGrab(
mode, wrap_axis, bounds ? &bounds_rect : NULL, mouse_ungrab_xy ? mouse_xy : NULL);
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TModifierKeyMask mask,
int *isDown)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
GHOST_TSuccess result;
2012-05-19 09:57:55 +00:00
bool isdown = false;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
result = system->getModifierKeyState(mask, isdown);
*isDown = (int)isdown;
return result;
}
GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
2012-05-19 09:57:55 +00:00
GHOST_TButtonMask mask,
int *isDown)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
2002-10-12 11:37:38 +00:00
GHOST_TSuccess result;
2012-05-19 09:57:55 +00:00
bool isdown = false;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
result = system->getButtonState(mask, isdown);
*isDown = (int)isdown;
return result;
}
#ifdef WITH_INPUT_NDOF
void GHOST_setNDOFDeadZone(float deadzone)
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
system->setNDOFDeadZone(deadzone);
}
#endif
void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
window->setAcceptDragOperation(canAccept);
}
2002-10-12 11:37:38 +00:00
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IEvent *event = (GHOST_IEvent *)eventhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return event->getType();
}
GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IEvent *event = (GHOST_IEvent *)eventhandle;
2002-10-12 11:37:38 +00:00
return event->getTime();
}
GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IEvent *event = (GHOST_IEvent *)eventhandle;
2002-10-12 11:37:38 +00:00
return (GHOST_WindowHandle)event->getWindow();
}
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IEvent *event = (GHOST_IEvent *)eventhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return event->getData();
}
GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *)timertaskhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return timertask->getTimerProc();
}
void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle, GHOST_TimerProcPtr timerproc)
{
2012-05-19 09:57:55 +00:00
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *)timertaskhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
timertask->setTimerProc(timerproc);
}
GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *)timertaskhandle;
2002-10-12 11:37:38 +00:00
return timertask->getUserData();
}
void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle, GHOST_TUserDataPtr userdata)
{
2012-05-19 09:57:55 +00:00
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *)timertaskhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
timertask->setUserData(userdata);
}
2018-06-04 18:47:57 +02:00
int GHOST_GetValid(GHOST_WindowHandle windowhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return (int)window->getValid();
}
GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->getDrawingContextType();
}
GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TDrawingContextType type)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setDrawingContextType(type);
}
void GHOST_SetTitle(GHOST_WindowHandle windowhandle, const char *title)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
window->setTitle(title);
}
2012-05-19 09:57:55 +00:00
char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
std::string title = window->getTitle();
2002-10-12 11:37:38 +00:00
char *ctitle = (char *)malloc(title.size() + 1);
2012-09-08 08:59:47 +00:00
if (ctitle == NULL) {
return NULL;
}
strcpy(ctitle, title.c_str());
2012-05-19 09:57:55 +00:00
2002-10-12 11:37:38 +00:00
return ctitle;
}
2018-06-04 18:47:57 +02:00
GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
GHOST_Rect *rectangle = NULL;
2002-10-12 11:37:38 +00:00
rectangle = new GHOST_Rect();
window->getWindowBounds(*rectangle);
return (GHOST_RectangleHandle)rectangle;
}
2018-06-04 18:47:57 +02:00
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
GHOST_Rect *rectangle = NULL;
2002-10-12 11:37:38 +00:00
rectangle = new GHOST_Rect();
window->getClientBounds(*rectangle);
return (GHOST_RectangleHandle)rectangle;
}
void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
{
2012-05-19 09:57:55 +00:00
delete (GHOST_Rect *)rectanglehandle;
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle, GHOST_TUns32 width)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setClientWidth(width);
}
GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle, GHOST_TUns32 height)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setClientHeight(height);
}
GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TUns32 width,
GHOST_TUns32 height)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setClientSize(width, height);
}
void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 inX,
GHOST_TInt32 inY,
GHOST_TInt32 *outX,
GHOST_TInt32 *outY)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
window->screenToClient(inX, inY, *outX, *outY);
}
void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 inX,
GHOST_TInt32 inY,
GHOST_TInt32 *outX,
GHOST_TInt32 *outY)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
window->clientToScreen(inX, inY, *outX, *outY);
}
GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->getState();
}
GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle, GHOST_TWindowState state)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->setState(state);
}
GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle,
GHOST_TUns8 isUnsavedChanges)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
return window->setModifiedState(isUnsavedChanges);
2018-06-04 18:47:57 +02:00
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle, GHOST_TWindowOrder order)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return window->setOrder(order);
}
GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->swapBuffers();
}
GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interval)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->setSwapInterval(interval);
}
GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int *intervalOut)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->getSwapInterval(*intervalOut);
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2018-06-04 18:47:57 +02:00
2002-10-12 11:37:38 +00:00
return window->activateDrawingContext();
}
GHOST_TSuccess GHOST_ActivateOpenGLContext(GHOST_ContextHandle contexthandle)
{
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
if (context) {
return context->activateDrawingContext();
}
else {
GHOST_PRINTF("%s: Context not valid\n", __func__);
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ReleaseOpenGLContext(GHOST_ContextHandle contexthandle)
{
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
2002-10-12 11:37:38 +00:00
return context->releaseDrawingContext();
}
2002-10-12 11:37:38 +00:00
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection NOTE: While most of the milestone 1 goals are there, a few smaller features and improvements are still to be done. Big picture of this milestone: Initial, OpenXR-based virtual reality support for users and foundation for advanced use cases. Maniphest Task: https://developer.blender.org/T71347 The tasks contains more information about this milestone. To be clear: This is not a feature rich VR implementation, it's focused on the initial scene inspection use case. We intentionally focused on that, further features like controller support are part of the next milestone. - How to use? Instructions on how to use this are here: https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test These will be updated and moved to a more official place (likely the manual) soon. Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC headsets don't support the OpenXR standard yet and hence, do not work with this implementation. --------------- This is the C-side implementation of the features added for initial VR support as per milestone 1. A "VR Scene Inspection" Add-on will be committed separately, to expose the VR functionality in the UI. It also adds some further features for milestone 1, namely a landmarking system (stored view locations in the VR space) Main additions/features: * Support for rendering viewports to an HMD, with good performance. * Option to sync the VR view perspective with a fully interactive, regular 3D View (VR-Mirror). * Option to disable positional tracking. Keeps the current position (calculated based on the VR eye center pose) when enabled while a VR session is running. * Some regular viewport settings for the VR view * RNA/Python-API to query and set VR session state information. * WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data * wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU context) * DNA/RNA for management of VR session settings * `--debug-xr` and `--debug-xr-time` commandline options * Utility batch & config file for using the Oculus runtime on Windows. * Most VR data is runtime only. The exception is user settings which are saved to files (`XrSessionSettings`). * VR support can be disabled through the `WITH_XR_OPENXR` compiler flag. For architecture and code documentation, see https://wiki.blender.org/wiki/Source/Interface/XR. --------------- A few thank you's: * A huge shoutout to Ray Molenkamp for his help during the project - it would have not been that successful without him! * Sebastian Koenig and Simeon Conzendorf for testing and feedback! * The reviewers, especially Brecht Van Lommel! * Dalai Felinto for pushing and managing me to get this done ;) * The OpenXR working group for providing an open standard. I think we're the first bigger application to adopt OpenXR. Congratulations to them and ourselves :) This project started as a Google Summer of Code 2019 project - "Core Support of Virtual Reality Headsets through OpenXR" (see https://wiki.blender.org/wiki/User:Severin/GSoC-2019/). Some further information, including ideas for further improvements can be found in the final GSoC report: https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report Differential Revisions: D6193, D7098 Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 20:20:55 +01:00
unsigned int GHOST_GetContextDefaultOpenGLFramebuffer(GHOST_ContextHandle contexthandle)
{
GHOST_IContext *context = (GHOST_IContext *)contexthandle;
return context->getDefaultFramebuffer();
}
unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->getDefaultFramebuffer();
}
2002-10-12 11:37:38 +00:00
GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
{
2012-05-19 09:57:55 +00:00
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
2002-10-12 11:37:38 +00:00
return window->invalidate();
}
void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
system->setTabletAPI(api);
}
2002-10-12 11:37:38 +00:00
GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
{
2012-05-19 09:57:55 +00:00
return ((GHOST_Rect *)rectanglehandle)->getWidth();
2002-10-12 11:37:38 +00:00
}
GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
{
2012-05-19 09:57:55 +00:00
return ((GHOST_Rect *)rectanglehandle)->getHeight();
2002-10-12 11:37:38 +00:00
}
void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 *l,
GHOST_TInt32 *t,
GHOST_TInt32 *r,
GHOST_TInt32 *b)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
GHOST_Rect *rect = (GHOST_Rect *)rectanglehandle;
*l = rect->m_l;
*t = rect->m_t;
*r = rect->m_r;
*b = rect->m_b;
2002-10-12 11:37:38 +00:00
}
void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 l,
GHOST_TInt32 t,
GHOST_TInt32 r,
GHOST_TInt32 b)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->set(l, t, r, b);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
{
GHOST_TSuccess result = GHOST_kFailure;
if (((GHOST_Rect *)rectanglehandle)->isEmpty())
2002-10-12 11:37:38 +00:00
result = GHOST_kSuccess;
return result;
}
GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
{
GHOST_TSuccess result = GHOST_kFailure;
if (((GHOST_Rect *)rectanglehandle)->isValid())
2002-10-12 11:37:38 +00:00
result = GHOST_kSuccess;
return result;
}
void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle, GHOST_TInt32 i)
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->inset(i);
2002-10-12 11:37:38 +00:00
}
void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_RectangleHandle anotherrectanglehandle)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->unionRect(*(GHOST_Rect *)anotherrectanglehandle);
2002-10-12 11:37:38 +00:00
}
void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 x,
GHOST_TInt32 y)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->unionPoint(x, y);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 x,
GHOST_TInt32 y)
2002-10-12 11:37:38 +00:00
{
GHOST_TSuccess result = GHOST_kFailure;
if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
2002-10-12 11:37:38 +00:00
result = GHOST_kSuccess;
return result;
}
GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_RectangleHandle anotherrectanglehandle)
2002-10-12 11:37:38 +00:00
{
GHOST_TVisibility visible = GHOST_kNotVisible;
2012-05-19 09:57:55 +00:00
visible = ((GHOST_Rect *)rectanglehandle)->getVisibility(*(GHOST_Rect *)anotherrectanglehandle);
2002-10-12 11:37:38 +00:00
return visible;
}
void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 cx,
GHOST_TInt32 cy)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy);
2002-10-12 11:37:38 +00:00
}
void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_TInt32 cx,
GHOST_TInt32 cy,
GHOST_TInt32 w,
GHOST_TInt32 h)
2002-10-12 11:37:38 +00:00
{
2012-05-19 09:57:55 +00:00
((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy, w, h);
2002-10-12 11:37:38 +00:00
}
GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
2012-05-19 09:57:55 +00:00
GHOST_RectangleHandle anotherrectanglehandle)
2002-10-12 11:37:38 +00:00
{
GHOST_TSuccess result = GHOST_kFailure;
if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle))
2002-10-12 11:37:38 +00:00
result = GHOST_kSuccess;
return result;
}
2012-05-19 09:57:55 +00:00
GHOST_TUns8 *GHOST_getClipboard(int selection)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = GHOST_ISystem::getSystem();
2.5: Text Editor back. There was very little structure in this code, using many globals and duplicated code. Now it should be better structured. Most things should work, the main parts that are not back yet are the python plugins and markers. Notes: * Blenfont is used for drawing the text, nicely anti-aliased. * A monospace truetype font was added, since that is needed for the text editor. It's Bitstream Vera Sans Mono. This is the default gnome terminal font, but it doesn't fit entirely well with the other font I think, can be changed easily of course. * Clipboard copy/cut/paste now always uses the system clipboard, the code for the own cut buffer was removed. * The interface buttons should support copy/cut/paste again now as well. * WM_clipboard_text_get/WM_clipboard_text_set were added to the windowmanager code. * Find panel is now a kind of second header, instead of a panel. This needs especially a way to start editing the text field immediately on open still. * Operators are independent of the actual space when possible, was a bit of puzzling but got it solved nice with notifiers, and some lazy init for syntax highlight in the drawing code. * RNA was created for the text editor space and used for buttons. * Operators: * New, Open, Reload, Save, Save As, Make Internal * Run Script, Refresh Pyconstraints * Copy, Cut, Paste * Convert Whitespace, Uncomment, Comment, Indent, Unindent * Line Break, Insert * Next Marker, Previous Marker, Clear All Markers, Mark All * Select Line, Select All * Jump, Move, Move Select, Delete, Toggle Overwrite * Scroll, Scroll Bar, Set Cursor, Line Number * Find and Replace, Find, Replace, Find Set Selected, Replace Set Selected * To 3D Object * Resolve Conflict
2009-02-28 23:33:35 +00:00
return system->getClipboard(selection);
}
2.5: Text Editor back. There was very little structure in this code, using many globals and duplicated code. Now it should be better structured. Most things should work, the main parts that are not back yet are the python plugins and markers. Notes: * Blenfont is used for drawing the text, nicely anti-aliased. * A monospace truetype font was added, since that is needed for the text editor. It's Bitstream Vera Sans Mono. This is the default gnome terminal font, but it doesn't fit entirely well with the other font I think, can be changed easily of course. * Clipboard copy/cut/paste now always uses the system clipboard, the code for the own cut buffer was removed. * The interface buttons should support copy/cut/paste again now as well. * WM_clipboard_text_get/WM_clipboard_text_set were added to the windowmanager code. * Find panel is now a kind of second header, instead of a panel. This needs especially a way to start editing the text field immediately on open still. * Operators are independent of the actual space when possible, was a bit of puzzling but got it solved nice with notifiers, and some lazy init for syntax highlight in the drawing code. * RNA was created for the text editor space and used for buttons. * Operators: * New, Open, Reload, Save, Save As, Make Internal * Run Script, Refresh Pyconstraints * Copy, Cut, Paste * Convert Whitespace, Uncomment, Comment, Indent, Unindent * Line Break, Insert * Next Marker, Previous Marker, Clear All Markers, Mark All * Select Line, Select All * Jump, Move, Move Select, Delete, Toggle Overwrite * Scroll, Scroll Bar, Set Cursor, Line Number * Find and Replace, Find, Replace, Find Set Selected, Replace Set Selected * To 3D Object * Resolve Conflict
2009-02-28 23:33:35 +00:00
void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = GHOST_ISystem::getSystem();
2.5: Text Editor back. There was very little structure in this code, using many globals and duplicated code. Now it should be better structured. Most things should work, the main parts that are not back yet are the python plugins and markers. Notes: * Blenfont is used for drawing the text, nicely anti-aliased. * A monospace truetype font was added, since that is needed for the text editor. It's Bitstream Vera Sans Mono. This is the default gnome terminal font, but it doesn't fit entirely well with the other font I think, can be changed easily of course. * Clipboard copy/cut/paste now always uses the system clipboard, the code for the own cut buffer was removed. * The interface buttons should support copy/cut/paste again now as well. * WM_clipboard_text_get/WM_clipboard_text_set were added to the windowmanager code. * Find panel is now a kind of second header, instead of a panel. This needs especially a way to start editing the text field immediately on open still. * Operators are independent of the actual space when possible, was a bit of puzzling but got it solved nice with notifiers, and some lazy init for syntax highlight in the drawing code. * RNA was created for the text editor space and used for buttons. * Operators: * New, Open, Reload, Save, Save As, Make Internal * Run Script, Refresh Pyconstraints * Copy, Cut, Paste * Convert Whitespace, Uncomment, Comment, Indent, Unindent * Line Break, Insert * Next Marker, Previous Marker, Clear All Markers, Mark All * Select Line, Select All * Jump, Move, Move Select, Delete, Toggle Overwrite * Scroll, Scroll Bar, Set Cursor, Line Number * Find and Replace, Find, Replace, Find Set Selected, Replace Set Selected * To 3D Object * Resolve Conflict
2009-02-28 23:33:35 +00:00
system->putClipboard(buffer, selection);
}
int GHOST_toggleConsole(int action)
{
2012-05-19 09:57:55 +00:00
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->toggleConsole(action);
}
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
int GHOST_UseNativePixels(void)
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->useNativePixel();
}
void GHOST_UseWindowFocus(int use_focus)
{
GHOST_ISystem *system = GHOST_ISystem::getSystem();
return system->useWindowFocus(use_focus);
}
float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
if (window)
return window->getNativePixelSize();
return 1.0f;
Holiday coding log :) Nice formatted version (pictures soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability Short list of main changes: - Transparent region option (over main region), added code to blend in/out such panels. - Min size window now 640 x 480 - Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake. - Macbook retina support, use command line --no-native-pixels to disable it - Timeline Marker label was drawing wrong - Trackpad and magic mouse: supports zoom (hold ctrl) - Fix for splash position: removed ghost function and made window size update after creation immediate - Fast undo buffer save now adds UI as well. Could be checked for regular file save even... Quit.blend and temp file saving use this now. - Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)" - New Userpref option "Keep Session" - this always saves quit.blend, and loads on start. This allows keeping UI and data without actual saves, until you actually save. When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header) - Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards. - User preferences (themes, keymaps, user settings) now can be saved as a separate file. Old option is called "Save Startup File" the new one "Save User Settings". To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still. - OSX: fixed bug that stopped giving mouse events outside window. This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
}
GHOST_TUns16 GHOST_GetDPIHint(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
return window->getDPIHint();
}
#ifdef WITH_INPUT_IME
void GHOST_BeginIME(GHOST_WindowHandle windowhandle,
GHOST_TInt32 x,
GHOST_TInt32 y,
GHOST_TInt32 w,
GHOST_TInt32 h,
int complete)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
window->beginIME(x, y, w, h, complete);
}
void GHOST_EndIME(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
window->endIME();
}
#endif /* WITH_INPUT_IME */
#ifdef WITH_XR_OPENXR
# define GHOST_XR_CAPI_CALL(call, ctx) \
try { \
call; \
} \
catch (GHOST_XrException & e) { \
(ctx)->dispatchErrorMessage(&e); \
}
# define GHOST_XR_CAPI_CALL_RET(call, ctx) \
try { \
return call; \
} \
catch (GHOST_XrException & e) { \
(ctx)->dispatchErrorMessage(&e); \
}
void GHOST_XrSessionStart(GHOST_XrContextHandle xr_contexthandle,
const GHOST_XrSessionBeginInfo *begin_info)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL(xr_context->startSession(begin_info), xr_context);
}
void GHOST_XrSessionEnd(GHOST_XrContextHandle xr_contexthandle)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL(xr_context->endSession(), xr_context);
}
void GHOST_XrSessionDrawViews(GHOST_XrContextHandle xr_contexthandle, void *draw_customdata)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL(xr_context->drawSessionViews(draw_customdata), xr_context);
}
int GHOST_XrSessionIsRunning(const GHOST_XrContextHandle xr_contexthandle)
{
const GHOST_IXrContext *xr_context = (const GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL_RET(xr_context->isSessionRunning(), xr_context);
return 0; /* Only reached if exception is thrown. */
}
void GHOST_XrGraphicsContextBindFuncs(GHOST_XrContextHandle xr_contexthandle,
GHOST_XrGraphicsContextBindFn bind_fn,
GHOST_XrGraphicsContextUnbindFn unbind_fn)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL(xr_context->setGraphicsContextBindFuncs(bind_fn, unbind_fn), xr_context);
}
void GHOST_XrDrawViewFunc(GHOST_XrContextHandle xr_contexthandle, GHOST_XrDrawViewFn draw_view_fn)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL(xr_context->setDrawViewFunc(draw_view_fn), xr_context);
}
int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_contexthandle)
{
GHOST_IXrContext *xr_context = (GHOST_IXrContext *)xr_contexthandle;
GHOST_XR_CAPI_CALL_RET(xr_context->needsUpsideDownDrawing(), xr_context);
return 0; /* Only reached if exception is thrown. */
}
#endif