Blender  V2.93
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GHOST_SystemCocoa Class Reference

#include <GHOST_SystemCocoa.h>

Inherits GHOST_System.

Public Member Functions

 GHOST_SystemCocoa ()
 
 ~GHOST_SystemCocoa ()
 
GHOST_TUns64 getMilliSeconds () const
 
GHOST_TUns8 getNumDisplays () const
 
void getMainDisplayDimensions (GHOST_TUns32 &width, GHOST_TUns32 &height) const
 
void getAllDisplayDimensions (GHOST_TUns32 &width, GHOST_TUns32 &height) const
 
GHOST_IWindowcreateWindow (const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=NULL)
 
GHOST_IContextcreateOffscreenContext (GHOST_GLSettings glSettings)
 
GHOST_TSuccess disposeContext (GHOST_IContext *context)
 
bool processEvents (bool waitForEvent)
 
void handleQuitRequest ()
 
bool handleOpenDocumentRequest (void *filepathStr)
 
GHOST_TSuccess handleDraggingEvent (GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data)
 
GHOST_TSuccess getCursorPosition (GHOST_TInt32 &x, GHOST_TInt32 &y) const
 
GHOST_TSuccess setCursorPosition (GHOST_TInt32 x, GHOST_TInt32 y)
 
GHOST_TSuccess getModifierKeys (GHOST_ModifierKeys &keys) const
 
GHOST_TSuccess getButtons (GHOST_Buttons &buttons) const
 
GHOST_TUns8getClipboard (bool selection) const
 
void putClipboard (GHOST_TInt8 *buffer, bool selection) const
 
GHOST_TSuccess handleWindowEvent (GHOST_TEventType eventType, GHOST_WindowCocoa *window)
 
GHOST_TSuccess handleApplicationBecomeActiveEvent ()
 
bool hasDialogWindow ()
 
void notifyExternalEventProcessed ()
 
int toggleConsole (int action)
 
GHOST_TSuccess handleTabletEvent (void *eventPtr, short eventType)
 
bool handleTabletEvent (void *eventPtr)
 
GHOST_TSuccess handleMouseEvent (void *eventPtr)
 
GHOST_TSuccess handleKeyEvent (void *eventPtr)
 
- Public Member Functions inherited from GHOST_System
GHOST_ITimerTaskinstallTimer (GHOST_TUns64 delay, GHOST_TUns64 interval, GHOST_TimerProcPtr timerProc, GHOST_TUserDataPtr userData=NULL)
 
GHOST_TSuccess removeTimer (GHOST_ITimerTask *timerTask)
 
GHOST_TSuccess disposeWindow (GHOST_IWindow *window)
 
bool validWindow (GHOST_IWindow *window)
 
GHOST_TSuccess beginFullScreen (const GHOST_DisplaySetting &setting, GHOST_IWindow **window, const bool stereoVisual, const bool alphaBackground)
 
GHOST_TSuccess updateFullScreen (const GHOST_DisplaySetting &setting, GHOST_IWindow **window)
 
GHOST_TSuccess endFullScreen (void)
 
bool getFullScreen (void)
 
bool useNativePixel (void)
 
void useWindowFocus (const bool use_focus)
 
void dispatchEvents ()
 
GHOST_TSuccess addEventConsumer (GHOST_IEventConsumer *consumer)
 
GHOST_TSuccess removeEventConsumer (GHOST_IEventConsumer *consumer)
 
GHOST_TSuccess getModifierKeyState (GHOST_TModifierKeyMask mask, bool &isDown) const
 
GHOST_TSuccess getButtonState (GHOST_TButtonMask mask, bool &isDown) const
 
void setTabletAPI (GHOST_TTabletAPI api)
 
GHOST_TTabletAPI getTabletAPI (void)
 
GHOST_TSuccess pushEvent (GHOST_IEvent *event)
 
GHOST_TimerManagergetTimerManager () const
 
GHOST_EventManagergetEventManager () const
 
GHOST_WindowManagergetWindowManager () const
 
virtual GHOST_TSuccess showMessageBox (const char *, const char *, const char *, const char *, const char *, GHOST_DialogOptions) const
 
virtual void initDebug (bool is_debug_enabled)
 
virtual bool isDebugEnabled ()
 

Protected Member Functions

GHOST_TSuccess init ()
 
GHOST_TSuccess setMouseCursorPosition (GHOST_TInt32 x, GHOST_TInt32 y)
 
- Protected Member Functions inherited from GHOST_System
 GHOST_System ()
 
virtual ~GHOST_System ()
 
virtual GHOST_TSuccess exit ()
 
GHOST_TSuccess createFullScreenWindow (GHOST_Window **window, const GHOST_DisplaySetting &settings, const bool stereoVisual, const bool alphaBackground=0)
 
- Protected Member Functions inherited from GHOST_ISystem
 GHOST_ISystem ()
 
virtual ~GHOST_ISystem ()
 

Protected Attributes

GHOST_TUns64 m_start_time
 
bool m_outsideLoopEventProcessed
 
bool m_needDelayedApplicationBecomeActiveEventProcessing
 
GHOST_TUns32 m_modifierMask
 
bool m_ignoreWindowSizedMessages
 
bool m_ignoreMomentumScroll
 
bool m_multiTouchScroll
 
double m_last_warp_timestamp
 
- Protected Attributes inherited from GHOST_System
GHOST_DisplayManagerm_displayManager
 
GHOST_TimerManagerm_timerManager
 
GHOST_WindowManagerm_windowManager
 
GHOST_EventManagerm_eventManager
 
GHOST_DisplaySetting m_preFullScreenSetting
 
GHOST_TTabletAPI m_tabletAPI
 
bool m_is_debug_enabled
 

Additional Inherited Members

- Static Public Member Functions inherited from GHOST_ISystem
static GHOST_TSuccess createSystem ()
 
static GHOST_TSuccess disposeSystem ()
 
static GHOST_ISystemgetSystem ()
 
- Public Attributes inherited from GHOST_System
bool m_nativePixel
 
bool m_windowFocus
 
- Static Protected Attributes inherited from GHOST_ISystem
static GHOST_ISystemm_system = NULL
 

Detailed Description

Definition at line 40 of file GHOST_SystemCocoa.h.

Constructor & Destructor Documentation

◆ GHOST_SystemCocoa()

GHOST_SystemCocoa::GHOST_SystemCocoa ( )

◆ ~GHOST_SystemCocoa()

GHOST_SystemCocoa::~GHOST_SystemCocoa ( )

Destructor.

Definition at line 541 of file GHOST_SystemCocoa.mm.

Member Function Documentation

◆ createOffscreenContext()

GHOST_IContext * GHOST_SystemCocoa::createOffscreenContext ( GHOST_GLSettings  glSettings)
virtual

Create a new offscreen context. Never explicitly delete the context, use disposeContext() instead.

Returns
The new context (or 0 if creation failed).

Create a new offscreen context. Never explicitly delete the context, use disposeContext() instead.

Returns
The new context (or 0 if creation failed).

Implements GHOST_System.

Definition at line 768 of file GHOST_SystemCocoa.mm.

References context, and NULL.

◆ createWindow()

GHOST_IWindow * GHOST_SystemCocoa::createWindow ( const char *  title,
GHOST_TInt32  left,
GHOST_TInt32  top,
GHOST_TUns32  width,
GHOST_TUns32  height,
GHOST_TWindowState  state,
GHOST_TDrawingContextType  type,
GHOST_GLSettings  glSettings,
const bool  exclusive = false,
const bool  is_dialog = false,
const GHOST_IWindow parentWindow = NULL 
)
virtual

Create a new window. The new window is added to the list of windows managed. Never explicitly delete the window, use disposeWindow() instead.

Parameters
titleThe name of the window. (displayed in the title bar of the window if the OS supports it).
leftThe coordinate of the left edge of the window.
topThe coordinate of the top edge of the window.
widthThe width the window.
heightThe height the window.
stateThe state of the window when opened.
typeThe type of drawing context installed in this window.
glSettingsMisc OpenGL settings.
exclusiveUse to show the window ontop and ignore others (used fullscreen).
parentWindowParent (embedder) window.
Returns
The new window (or 0 if creation failed).

Implements GHOST_ISystem.

Definition at line 702 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::addWindow(), bottom, GHOST_GLSettings::flags, getMilliSeconds(), GHOST_IWindow::getValid(), GHOST_ASSERT, GHOST_glDebugContext, GHOST_glStereoVisual, GHOST_kEventWindowActivate, GHOST_kEventWindowSize, GHOST_PRINT, height, left, GHOST_System::m_windowManager, NULL, GHOST_System::pushEvent(), GHOST_WindowManager::setActiveWindow(), state, top, type, and width.

◆ disposeContext()

GHOST_TSuccess GHOST_SystemCocoa::disposeContext ( GHOST_IContext context)
virtual

Dispose of a context.

Parameters
contextPointer to the context to be disposed.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 784 of file GHOST_SystemCocoa.mm.

References context, and GHOST_kSuccess.

◆ getAllDisplayDimensions()

void GHOST_SystemCocoa::getAllDisplayDimensions ( GHOST_TUns32 width,
GHOST_TUns32 height 
) const
virtual

Returns the combine dimensions of all monitors.

Returns
The dimension of the workspace.

Implements GHOST_ISystem.

Definition at line 696 of file GHOST_SystemCocoa.mm.

References getMainDisplayDimensions(), height, and width.

◆ getButtons()

GHOST_TSuccess GHOST_SystemCocoa::getButtons ( GHOST_Buttons buttons) const
virtual

Returns the state of the mouse buttons (outside the message queue).

Parameters
buttonsThe state of the buttons.
Returns
Indication of success.

Implements GHOST_System.

Definition at line 871 of file GHOST_SystemCocoa.mm.

References GHOST_Buttons::clear(), GHOST_kButtonMaskButton4, GHOST_kButtonMaskButton5, GHOST_kButtonMaskLeft, GHOST_kButtonMaskMiddle, GHOST_kButtonMaskRight, GHOST_kSuccess, and GHOST_Buttons::set().

◆ getClipboard()

GHOST_TUns8 * GHOST_SystemCocoa::getClipboard ( bool  selection) const
virtual

Returns Clipboard data

Parameters
selectionIndicate which buffer to return.
Returns
Returns the selected buffer

Implements GHOST_System.

Definition at line 1936 of file GHOST_SystemCocoa.mm.

References NULL.

◆ getCursorPosition()

GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition ( GHOST_TInt32 x,
GHOST_TInt32 y 
) const
virtual

Returns the current location of the cursor (location in screen coordinates)

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
Indication of success.
Note
: returns coordinates in Cocoa screen coordinates

Implements GHOST_ISystem.

Definition at line 794 of file GHOST_SystemCocoa.mm.

References GHOST_kSuccess, x, and y.

Referenced by GHOST_WindowCocoa::setWindowCursorGrab().

◆ getMainDisplayDimensions()

void GHOST_SystemCocoa::getMainDisplayDimensions ( GHOST_TUns32 width,
GHOST_TUns32 height 
) const
virtual

Returns the dimensions of the main display on this system.

Returns
The dimension of the main display.

Implements GHOST_ISystem.

Definition at line 679 of file GHOST_SystemCocoa.mm.

References height, and width.

Referenced by getAllDisplayDimensions().

◆ getMilliSeconds()

GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds ( ) const
virtual

Returns the system time. Returns the number of milliseconds since the start of the system process. Based on ANSI clock() routine.

Returns
The number of milliseconds.

Reimplemented from GHOST_System.

Definition at line 658 of file GHOST_SystemCocoa.mm.

References m_start_time, and NULL.

Referenced by createWindow(), DeviceEvent(), handleApplicationBecomeActiveEvent(), handleDraggingEvent(), handleOpenDocumentRequest(), handleQuitRequest(), handleWindowEvent(), processEvents(), and setCursorPosition().

◆ getModifierKeys()

GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys ( GHOST_ModifierKeys keys) const
virtual

Returns the state of all modifier keys.

Parameters
keysThe state of all modifier keys (true == pressed).
Returns
Indication of success.

Implements GHOST_System.

Definition at line 859 of file GHOST_SystemCocoa.mm.

References GHOST_kModifierKeyLeftAlt, GHOST_kModifierKeyLeftControl, GHOST_kModifierKeyLeftShift, GHOST_kModifierKeyOS, GHOST_kSuccess, m_modifierMask, and GHOST_ModifierKeys::set().

◆ getNumDisplays()

GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays ( ) const
virtual

Returns the number of displays on this system.

Returns
The number of displays.

Implements GHOST_ISystem.

Definition at line 670 of file GHOST_SystemCocoa.mm.

◆ handleApplicationBecomeActiveEvent()

GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent ( )

◆ handleDraggingEvent()

GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent ( GHOST_TEventType  eventType,
GHOST_TDragnDropTypes  draggedObjectType,
GHOST_WindowCocoa window,
int  mouseX,
int  mouseY,
void *  data 
)

Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass

Parameters
eventTypeThe type of drag'n'drop event.
draggedObjectTypeThe type object concerned. (currently array of file names, string, TIFF image).
mouseXx mouse coordinate (in cocoa base window coordinates).
mouseYy mouse coordinate.
windowThe window on which the event occurred.
Returns
Indication whether the event was handled.

Definition at line 1116 of file GHOST_SystemCocoa.mm.

References GHOST_TStringArray::count, data, free(), getMilliSeconds(), GHOST_kDragnDropTypeBitmap, GHOST_kDragnDropTypeFilenames, GHOST_kDragnDropTypeString, GHOST_kEventDraggingDropDone, GHOST_kEventDraggingEntered, GHOST_kEventDraggingExited, GHOST_kEventDraggingUpdated, GHOST_kFailure, GHOST_kSuccess, IB_rect, IMB_allocImBuf(), m_outsideLoopEventProcessed, NULL, GHOST_System::pushEvent(), ImBuf::rect, GHOST_TStringArray::strings, GHOST_System::validWindow(), x, and y.

◆ handleKeyEvent()

GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent ( void *  eventPtr)

◆ handleMouseEvent()

GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent ( void *  eventPtr)

◆ handleOpenDocumentRequest()

bool GHOST_SystemCocoa::handleOpenDocumentRequest ( void *  filepathStr)

Handle Cocoa openFile event Display confirmation request panel if changes performed since last save

Definition at line 1363 of file GHOST_SystemCocoa.mm.

References count, GHOST_WindowManager::getActiveWindow(), GHOST_Window::getCursorGrabModeIsWarp(), getMilliSeconds(), GHOST_kEventOpenMainFile, GHOST_kFailure, GHOST_System::m_windowManager, NULL, and GHOST_System::pushEvent().

◆ handleQuitRequest()

void GHOST_SystemCocoa::handleQuitRequest ( )

Handle User request to quit, from Menu bar Quit, and Cmd+Q Display alert panel if changes performed since last save

Definition at line 1350 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::getActiveWindow(), GHOST_Window::getCursorGrabModeIsWarp(), getMilliSeconds(), GHOST_kEventQuitRequest, m_outsideLoopEventProcessed, GHOST_System::m_windowManager, and GHOST_System::pushEvent().

◆ handleTabletEvent() [1/2]

bool GHOST_SystemCocoa::handleTabletEvent ( void *  eventPtr)

Definition at line 1459 of file GHOST_SystemCocoa.mm.

References handleTabletEvent().

◆ handleTabletEvent() [2/2]

GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent ( void *  eventPtr,
short  eventType 
)

Handles a tablet event.

Parameters
eventPtrAn #NSEvent pointer (cast to void* to enable compilation in standard C++).
eventTypeThe type of the event. It needs to be passed separately as it can be either directly in the event type, or as a sub-type if combined with a mouse button event.
Returns
Indication whether the event was handled.

Definition at line 1405 of file GHOST_SystemCocoa.mm.

References GHOST_TabletData::Active, FALSE, GHOST_WindowManager::getWindowAssociatedWithOSWindow(), GHOST_ASSERT, GHOST_kFailure, GHOST_kSuccess, GHOST_kTabletModeEraser, GHOST_kTabletModeNone, GHOST_kTabletModeStylus, GHOST_TABLET_DATA_NONE, GHOST_System::m_windowManager, GHOST_TabletData::Pressure, GHOST_TabletData::Xtilt, and GHOST_TabletData::Ytilt.

Referenced by handleMouseEvent(), and handleTabletEvent().

◆ handleWindowEvent()

GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent ( GHOST_TEventType  eventType,
GHOST_WindowCocoa window 
)

◆ hasDialogWindow()

bool GHOST_SystemCocoa::hasDialogWindow ( )
Returns
True if any dialog window is open.

Definition at line 1035 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::getWindows(), GHOST_WindowCocoa::isDialog(), and GHOST_System::m_windowManager.

◆ init()

GHOST_TSuccess GHOST_SystemCocoa::init ( void  )
protectedvirtual

Initializes the system. For now, it just registers the window class (WNDCLASS).

Returns
A success value.

Reimplemented from GHOST_System.

Definition at line 545 of file GHOST_SystemCocoa.mm.

References GHOST_System::init(), and CocoaAppDelegate::setSystemCocoa:.

◆ notifyExternalEventProcessed()

void GHOST_SystemCocoa::notifyExternalEventProcessed ( )

External objects should call this when they send an event outside processEvents.

Definition at line 1046 of file GHOST_SystemCocoa.mm.

References m_outsideLoopEventProcessed.

Referenced by DeviceEvent().

◆ processEvents()

bool GHOST_SystemCocoa::processEvents ( bool  waitForEvent)
virtual

Gets events from the system and stores them in the queue.

Parameters
waitForEventFlag to wait for an event (or return immediately).
Returns
Indication of the presence of events.

The event queue polling function

Implements GHOST_ISystem.

Definition at line 889 of file GHOST_SystemCocoa.mm.

References double(), GHOST_TimerManager::fireTimers(), getMilliSeconds(), GHOST_System::getTimerManager(), GHOST_kFireTimeNever, handleApplicationBecomeActiveEvent(), handleKeyEvent(), m_ignoreWindowSizedMessages, m_needDelayedApplicationBecomeActiveEventProcessing, m_outsideLoopEventProcessed, next, GHOST_TimerManager::nextFireTime(), NULL, and type.

◆ putClipboard()

void GHOST_SystemCocoa::putClipboard ( GHOST_TInt8 buffer,
bool  selection 
) const
virtual

Puts buffer to system clipboard

Parameters
bufferThe buffer to be copied.
selectionIndicates which buffer to copy too, only used on X11.

Implements GHOST_System.

Definition at line 1973 of file GHOST_SystemCocoa.mm.

◆ setCursorPosition()

GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition ( GHOST_TInt32  x,
GHOST_TInt32  y 
)
virtual

Updates the location of the cursor (location in screen coordinates).

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
Indication of success.
Note
: expect Cocoa screen coordinates

Implements GHOST_ISystem.

Definition at line 807 of file GHOST_SystemCocoa.mm.

References GHOST_WindowManager::getActiveWindow(), GHOST_WindowCocoa::GetCocoaTabletData(), getMilliSeconds(), GHOST_kEventCursorMove, GHOST_kFailure, GHOST_kSuccess, m_outsideLoopEventProcessed, GHOST_System::m_windowManager, GHOST_System::pushEvent(), setMouseCursorPosition(), x, and y.

Referenced by GHOST_WindowCocoa::setWindowCursorGrab().

◆ setMouseCursorPosition()

GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition ( GHOST_TInt32  x,
GHOST_TInt32  y 
)
protected

Performs the actual cursor position update (location in screen coordinates).

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
Indication of success.

Definition at line 827 of file GHOST_SystemCocoa.mm.

References float(), GHOST_WindowManager::getActiveWindow(), GHOST_WindowCocoa::getScreen(), GHOST_kFailure, GHOST_kSuccess, GHOST_System::m_windowManager, x, and y.

Referenced by handleMouseEvent(), and setCursorPosition().

◆ toggleConsole()

int GHOST_SystemCocoa::toggleConsole ( int  action)
inlinevirtual
See also
GHOST_ISystem

Implements GHOST_ISystem.

Definition at line 247 of file GHOST_SystemCocoa.h.

Member Data Documentation

◆ m_ignoreMomentumScroll

bool GHOST_SystemCocoa::m_ignoreMomentumScroll
protected

Temporarily ignore momentum scroll events

Definition at line 311 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleKeyEvent(), and handleMouseEvent().

◆ m_ignoreWindowSizedMessages

bool GHOST_SystemCocoa::m_ignoreWindowSizedMessages
protected

Ignores window size messages (when window is dragged).

Definition at line 308 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleWindowEvent(), and processEvents().

◆ m_last_warp_timestamp

double GHOST_SystemCocoa::m_last_warp_timestamp
protected

To prevent multiple warp, we store the time of the last warp event and ignore mouse moved events generated before that.

Definition at line 316 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

◆ m_modifierMask

GHOST_TUns32 GHOST_SystemCocoa::m_modifierMask
protected

State of the modifiers.

Definition at line 305 of file GHOST_SystemCocoa.h.

Referenced by getModifierKeys(), GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), and handleKeyEvent().

◆ m_multiTouchScroll

bool GHOST_SystemCocoa::m_multiTouchScroll
protected

Is the scroll wheel event generated by a multitouch trackpad or mouse?

Definition at line 313 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), and handleMouseEvent().

◆ m_needDelayedApplicationBecomeActiveEventProcessing

bool GHOST_SystemCocoa::m_needDelayedApplicationBecomeActiveEventProcessing
protected

Raised window is not yet known by the window manager, so delay application become active event handling

Definition at line 302 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), and processEvents().

◆ m_outsideLoopEventProcessed

bool GHOST_SystemCocoa::m_outsideLoopEventProcessed
protected

Event has been processed directly by Cocoa (or NDOF manager) and has sent a ghost event to be dispatched

Definition at line 298 of file GHOST_SystemCocoa.h.

Referenced by GHOST_SystemCocoa(), handleApplicationBecomeActiveEvent(), handleDraggingEvent(), handleQuitRequest(), handleWindowEvent(), notifyExternalEventProcessed(), processEvents(), and setCursorPosition().

◆ m_start_time

GHOST_TUns64 GHOST_SystemCocoa::m_start_time
protected

Start time at initialization.

Definition at line 294 of file GHOST_SystemCocoa.h.

Referenced by getMilliSeconds(), and GHOST_SystemCocoa().


The documentation for this class was generated from the following files: