Added fix for invisible size widget on OSX.

It's still behind a define because it does not work with
blender (player and gears work fine).
Maarten
This commit is contained in:
Maarten Gribnau 2003-01-01 22:32:35 +00:00
parent e3376a4338
commit fac23acffe
2 changed files with 50 additions and 2 deletions

@ -46,6 +46,9 @@
#include "GHOST_Debug.h" #include "GHOST_Debug.h"
AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL; AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL;
#ifdef GHOST_DRAW_CARBON_GUTTER
const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16;
#endif //GHOST_DRAW_CARBON_GUTTER
static const GLint sPreferredFormatWindow[7] = { static const GLint sPreferredFormatWindow[7] = {
AGL_RGBA, GL_TRUE, AGL_RGBA, GL_TRUE,
@ -190,6 +193,18 @@ void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const
bounds.m_l = rect.left; bounds.m_l = rect.left;
bounds.m_r = rect.right; bounds.m_r = rect.right;
bounds.m_t = rect.top; bounds.m_t = rect.top;
// Subtract gutter height from bottom
#ifdef GHOST_DRAW_CARBON_GUTTER
if ((bounds.m_b - bounds.m_t) > s_sizeRectSize)
{
bounds.m_b -= s_sizeRectSize;
}
else
{
bounds.m_t = bounds.m_b;
}
#endif //GHOST_DRAW_CARBON_GUTTER
} }
@ -210,9 +225,15 @@ GHOST_TSuccess GHOST_WindowCarbon::setClientHeight(GHOST_TUns32 height)
GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientHeight(): window invalid") GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientHeight(): window invalid")
GHOST_Rect cBnds, wBnds; GHOST_Rect cBnds, wBnds;
getClientBounds(cBnds); getClientBounds(cBnds);
#ifdef GHOST_DRAW_CARBON_GUTTER
if (((GHOST_TUns32)cBnds.getHeight()) != height+s_sizeRectSize) {
::SizeWindow(m_windowRef, cBnds.getWidth(), height+s_sizeRectSize, true);
}
#else //GHOST_DRAW_CARBON_GUTTER
if (((GHOST_TUns32)cBnds.getHeight()) != height) { if (((GHOST_TUns32)cBnds.getHeight()) != height) {
::SizeWindow(m_windowRef, cBnds.getWidth(), height, true); ::SizeWindow(m_windowRef, cBnds.getWidth(), height, true);
} }
#endif //GHOST_DRAW_CARBON_GUTTER
return GHOST_kSuccess; return GHOST_kSuccess;
} }
@ -222,10 +243,17 @@ GHOST_TSuccess GHOST_WindowCarbon::setClientSize(GHOST_TUns32 width, GHOST_TUns3
GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientSize(): window invalid") GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientSize(): window invalid")
GHOST_Rect cBnds, wBnds; GHOST_Rect cBnds, wBnds;
getClientBounds(cBnds); getClientBounds(cBnds);
#ifdef GHOST_DRAW_CARBON_GUTTER
if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
(((GHOST_TUns32)cBnds.getHeight()) != height+s_sizeRectSize)) {
::SizeWindow(m_windowRef, width, height+s_sizeRectSize, true);
}
#else //GHOST_DRAW_CARBON_GUTTER
if ((((GHOST_TUns32)cBnds.getWidth()) != width) || if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
(((GHOST_TUns32)cBnds.getHeight()) != height)) { (((GHOST_TUns32)cBnds.getHeight()) != height)) {
::SizeWindow(m_windowRef, width, height, true); ::SizeWindow(m_windowRef, width, height, true);
} }
#endif //GHOST_DRAW_CARBON_GUTTER
return GHOST_kSuccess; return GHOST_kSuccess;
} }
@ -343,6 +371,20 @@ GHOST_TSuccess GHOST_WindowCarbon::activateDrawingContext()
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_aglCtx) { if (m_aglCtx) {
::aglSetCurrentContext(m_aglCtx); ::aglSetCurrentContext(m_aglCtx);
#ifdef GHOST_DRAW_CARBON_GUTTER
// Restrict drawing to non-gutter area
::aglEnable(m_aglCtx, AGL_BUFFER_RECT);
GHOST_Rect bnds;
getClientBounds(bnds);
GLint b[4] =
{
bnds.m_l,
bnds.m_t+s_sizeRectSize,
bnds.m_r-bnds.m_l,
bnds.m_b-bnds.m_t
};
GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b);
#endif //GHOST_DRAW_CARBON_GUTTER
} }
else { else {
succeeded = GHOST_kFailure; succeeded = GHOST_kFailure;

@ -49,12 +49,10 @@
/** /**
* Window on Mac OSX/Carbon. * Window on Mac OSX/Carbon.
* WILL BE ADDED:
* Carbon windows have a size widget in the lower right corner of the window. * Carbon windows have a size widget in the lower right corner of the window.
* To force it to be visible, the height of the client rectangle is reduced so * To force it to be visible, the height of the client rectangle is reduced so
* that applications do not draw in that area. GHOST will manage that area * that applications do not draw in that area. GHOST will manage that area
* which is called the gutter. * which is called the gutter.
* END WILL BE ADDED
* When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent * When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent
* OpenGL drawing outside the reduced client rectangle. * OpenGL drawing outside the reduced client rectangle.
* @author Maarten Gribnau * @author Maarten Gribnau
@ -271,6 +269,14 @@ protected:
/** When running in full-screen this tells whether to refresh the window. */ /** When running in full-screen this tells whether to refresh the window. */
bool m_fullScreenDirty; bool m_fullScreenDirty;
/**
* The width/height of the size rectangle in the lower right corner of a
* Mac/Carbon window. This is also the height of the gutter area.
*/
#ifdef GHOST_DRAW_CARBON_GUTTER
static const GHOST_TInt32 s_sizeRectSize;
#endif // GHOST_DRAW_CARBON_GUTTER
}; };
#endif // _GHOST_WINDOW_CARBON_H_ #endif // _GHOST_WINDOW_CARBON_H_