diff options
author | Richard Linden <none@none> | 2012-02-07 19:29:10 -0800 |
---|---|---|
committer | Richard Linden <none@none> | 2012-02-07 19:29:10 -0800 |
commit | 4e08461f8ad23fb75ca8587c781c2cf65351b1ab (patch) | |
tree | c6f48cdffa3c3436d517b808b3d432f095eee159 | |
parent | d56be1f1751f66bff09f0d223ed4712974e69e09 (diff) |
EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates
changed over to new convert() method
added LLCoordFloater
-rw-r--r-- | indra/llmath/llcoord.h | 69 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 43 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 35 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 8 | ||||
-rw-r--r-- | indra/llwindow/lldragdropwin32.cpp | 10 | ||||
-rw-r--r-- | indra/llwindow/llwindow.h | 2 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 108 | ||||
-rw-r--r-- | indra/newview/llpanelprimmediacontrols.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 9 |
9 files changed, 211 insertions, 75 deletions
diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index c0623e6d1f..0b1d7e04f5 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -26,32 +26,79 @@ #ifndef LL_LLCOORD_H #define LL_LLCOORD_H +struct LL_COORD_TYPE_COMMON +{ + typedef S32 value_t; +}; + // A two-dimensional pixel value -template<typename COORD_FRAME, typename VALUE_TYPE> -class LLCoord +template<typename COORD_FRAME> +class LLCoord : protected COORD_FRAME { public: - typedef LLCoord<COORD_FRAME, VALUE_TYPE> self_t; - VALUE_TYPE mX; - VALUE_TYPE mY; + typedef LLCoord<COORD_FRAME> self_t; + typename COORD_FRAME::value_t mX; + typename COORD_FRAME::value_t mY; LLCoord(): mX(0), mY(0) {} LLCoord(S32 x, S32 y): mX(x), mY(y) {} + LLCoord(const LLCoord<LL_COORD_TYPE_COMMON>& other) + { + COORD_FRAME::convertFromCommon(other); + } + + LLCoord<LL_COORD_TYPE_COMMON> convert() const + { + return COORD_FRAME::convertToCommon(); + } + void set(S32 x, S32 y) { mX = x; mY = y;} bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } bool operator!=(const self_t& other) const { return !(*this == other); } }; -struct LL_COORD_TYPE_GL {}; -struct LL_COORD_TYPE_WINDOW {}; -struct LL_COORD_TYPE_SCREEN {}; +typedef LLCoord<LL_COORD_TYPE_COMMON> LLCoordCommon; + +struct LL_COORD_TYPE_GL +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const + { + const LLCoord<LL_COORD_TYPE_GL>& self = static_cast<const LLCoord<LL_COORD_TYPE_GL>&>(*this); + return LLCoordCommon(self.mX, self.mY); + } + + void convertFromCommon(const LLCoordCommon& from) + { + LLCoord<LL_COORD_TYPE_GL>& self = static_cast<LLCoord<LL_COORD_TYPE_GL>&>(*this); + self.mX = from.mX; + self.mY = from.mY; + } +}; + +struct LL_COORD_TYPE_WINDOW +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const; + void convertFromCommon(const LLCoordCommon& from); +}; + +struct LL_COORD_TYPE_SCREEN +{ + typedef S32 value_t; + + LLCoordCommon convertToCommon() const; + void convertFromCommon(const LLCoordCommon& from); +}; -typedef LLCoord<LL_COORD_TYPE_GL, S32> LLCoordGL; -typedef LLCoord<LL_COORD_TYPE_WINDOW, S32> LLCoordWindow; -typedef LLCoord<LL_COORD_TYPE_SCREEN, S32> LLCoordScreen; +typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL; +typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow; +typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen; #endif diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index cef5ba3fe7..6274caa97f 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -270,6 +270,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mMinimizeSignal(NULL) // mNotificationContext(NULL) { + mPosition.setFloater(*this); // mNotificationContext = new LLFloaterNotificationContext(getHandle()); // Clicks stop here. @@ -3271,3 +3272,45 @@ void LLFloater::stackWith(LLFloater& other) setShape(next_rect); } +LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater) +: coord_t(x, y) +{ + mFloater = floater.getHandle(); +} + + +LLCoordFloater::LLCoordFloater(const LLCoordCommon& other, LLFloater& floater) +{ + mFloater = floater.getHandle(); + convertFromCommon(other); +} + +LLCoordFloater& LLCoordFloater::operator=(const LLCoordFloater& other) +{ + mFloater = other.mFloater; + coord_t::operator =(other); + return *this; +} + +void LLCoordFloater::setFloater(LLFloater& floater) +{ + mFloater = floater.getHandle(); +} + +bool LLCoordFloater::operator==(const LLCoordFloater& other) const +{ + return mX == other.mX && mY == other.mY && mFloater == other.mFloater; +} + +LLCoordCommon LL_COORD_FLOATER::convertToCommon() const +{ + const LLCoordFloater& self = static_cast<const LLCoordFloater&>(*this); + return LLCoordCommon(self.mX, self.mY); +} + +void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from) +{ + LLCoordFloater& self = static_cast<LLCoordFloater&>(*this); + self.mX = from.mX; + self.mY = from.mY; +} diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 1eb8c964f9..a7cc9ae961 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -82,9 +82,37 @@ namespace LLInitParam }; } -struct LL_COORD_FLOATER; +struct LL_COORD_FLOATER +{ + typedef F32 value_t; + + LLCoordCommon convertToCommon() const; + void convertFromCommon(const LLCoordCommon& from); +protected: + LLHandle<LLFloater> mFloater; +}; + +struct LLCoordFloater : LLCoord<LL_COORD_FLOATER> +{ + typedef LLCoord<LL_COORD_FLOATER> coord_t; -typedef LLCoord<LL_COORD_FLOATER, F32> LLCoordFloater; + LLCoordFloater() {} + LLCoordFloater(F32 x, F32 y, LLFloater& floater); + LLCoordFloater(const LLCoordCommon& other, LLFloater& floater); + + LLCoordFloater& operator=(const LLCoordCommon& other) + { + convertFromCommon(other); + return *this; + } + + LLCoordFloater& operator=(const LLCoordFloater& other); + + bool operator==(const LLCoordFloater& other) const; + bool operator!=(const LLCoordFloater& other) const { return !(*this == other); } + + void setFloater(LLFloater& floater); +}; class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater> { @@ -187,7 +215,7 @@ public: bool initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node = NULL); /*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false); - /*virtual*/ BOOL canSnapTo(const LLView* other_view); + /*virtual*/ BOOL canSnapTo(const LLView* other_view); /*virtual*/ void setSnappedTo(const LLView* snap_view); /*virtual*/ void setFocus( BOOL b ); /*virtual*/ void setIsChrome(BOOL is_chrome); @@ -428,6 +456,7 @@ private: LLFloaterEnums::EOpenPositioning mOpenPositioning; S32 mSpecifiedLeft; S32 mSpecifiedBottom; + LLCoordFloater mPosition; S32 mMinWidth; S32 mMinHeight; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 931b696c90..137716743f 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1736,10 +1736,7 @@ void LLUI::setMousePositionScreen(S32 x, S32 y) screen_x = llround((F32)x * sGLScaleFactor.mV[VX]); screen_y = llround((F32)y * sGLScaleFactor.mV[VY]); - LLCoordWindow window_point; - LLView::getWindow()->convertCoords(LLCoordGL(screen_x, screen_y), &window_point); - - LLView::getWindow()->setCursorPosition(window_point); + LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert()); } //static @@ -1747,8 +1744,7 @@ void LLUI::getMousePositionScreen(S32 *x, S32 *y) { LLCoordWindow cursor_pos_window; getWindow()->getCursorPosition(&cursor_pos_window); - LLCoordGL cursor_pos_gl; - getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl); + LLCoordGL cursor_pos_gl(cursor_pos_window.convert()); *x = llround((F32)cursor_pos_gl.mX / sGLScaleFactor.mV[VX]); *y = llround((F32)cursor_pos_gl.mY / sGLScaleFactor.mV[VX]); } diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index d4d444eb28..15acddd987 100644 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -124,10 +124,9 @@ class LLDragDropWin32Target: ScreenToClient( mAppWindowHandle, &pt2 ); LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( cursor_coord_window.convert(), mask, LLWindowCallbacks::DNDA_START_TRACKING, mDropUrl ); switch (result) @@ -180,10 +179,9 @@ class LLDragDropWin32Target: ScreenToClient( mAppWindowHandle, &pt2 ); LLCoordWindow cursor_coord_window( pt2.x, pt2.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( gl_coord, mask, + LLWindowCallbacks::DragNDropResult result = window_imp->completeDragNDropRequest( cursor_coord_window.convert(), mask, LLWindowCallbacks::DNDA_TRACK, mDropUrl ); switch (result) @@ -237,15 +235,13 @@ class LLDragDropWin32Target: LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong( mAppWindowHandle, GWL_USERDATA ); if ( NULL != window_imp ) { - LLCoordGL gl_coord( 0, 0 ); - POINT pt_client; pt_client.x = pt.x; pt_client.y = pt.y; ScreenToClient( mAppWindowHandle, &pt_client ); LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + LLCoordGL gl_coord(cursor_coord_window.convert()); llinfos << "### (Drop) URL is: " << mDropUrl << llendl; llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index cab2d0a8fb..d2971581d2 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -39,7 +39,7 @@ class LLWindowCallbacks; // Refer to llwindow_test in test/common/llwindow for usage example -class LLWindow +class LLWindow : public LLInstanceTracker<LLWindow> { public: struct LLWindowResolution diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index a245986433..a8d2836f48 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -1545,24 +1545,16 @@ void LLWindowWin32::moveWindow( const LLCoordScreen& position, const LLCoordScre BOOL LLWindowWin32::setCursorPosition(const LLCoordWindow position) { - LLCoordScreen screen_pos; - mMousePositionModified = TRUE; if (!mWindowHandle) { return FALSE; } - if (!convertCoords(position, &screen_pos)) - { - return FALSE; - } // Inform the application of the new mouse position (needed for per-frame // hover/picking to function). - LLCoordGL gl_pos; - convertCoords(position, &gl_pos); - mCallbacks->handleMouseMove(this, gl_pos, (MASK)0); + mCallbacks->handleMouseMove(this, position.convert(), (MASK)0); // DEV-18951 VWR-8524 Camera moves wildly when alt-clicking. // Because we have preemptively notified the application of the new @@ -1572,24 +1564,23 @@ BOOL LLWindowWin32::setCursorPosition(const LLCoordWindow position) while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) { } - return SetCursorPos(screen_pos.mX, screen_pos.mY); + LLCoordScreen screen_pos(position.convert()); + return ::SetCursorPos(screen_pos.mX, screen_pos.mY); } BOOL LLWindowWin32::getCursorPosition(LLCoordWindow *position) { POINT cursor_point; - LLCoordScreen screen_pos; - if (!mWindowHandle || - !GetCursorPos(&cursor_point)) + if (!mWindowHandle + || !GetCursorPos(&cursor_point) + || !position) { return FALSE; } - screen_pos.mX = cursor_point.x; - screen_pos.mY = cursor_point.y; - - return convertCoords(screen_pos, position); + *position = LLCoordScreen(cursor_point.x, cursor_point.y).convert(); + return TRUE; } void LLWindowWin32::hideCursor() @@ -2167,15 +2158,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2197,15 +2188,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2230,15 +2221,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2265,15 +2256,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2294,15 +2285,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2329,15 +2320,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2358,15 +2349,15 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // If we don't do this, many clicks could get buffered up, and if the // first click changes the cursor position, all subsequent clicks // will occur at the wrong location. JC - LLCoordWindow cursor_coord_window; if (window_imp->mMousePositionModified) { + LLCoordWindow cursor_coord_window; window_imp->getCursorPosition(&cursor_coord_window); - window_imp->convertCoords(cursor_coord_window, &gl_coord); + gl_coord = cursor_coord_window.convert(); } else { - window_imp->convertCoords(window_coord, &gl_coord); + gl_coord = window_coord.convert(); } MASK mask = gKeyboard->currentMask(TRUE); // generate move event to update mouse coordinates @@ -2438,9 +2429,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_MOUSEMOVE: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MOUSEMOVE"); - window_imp->convertCoords(window_coord, &gl_coord); MASK mask = gKeyboard->currentMask(TRUE); - window_imp->mCallbacks->handleMouseMove(window_imp, gl_coord, mask); + window_imp->mCallbacks->handleMouseMove(window_imp, window_coord.convert(), mask); return 0; } @@ -2570,6 +2560,44 @@ BOOL LLWindowWin32::convertCoords(LLCoordGL from, LLCoordWindow *to) return TRUE; } +LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const +{ + const LLCoordWindow& self = static_cast<const LLCoordWindow&>(*this); + + LLWindow* windowp = &(*LLWindow::beginInstances()); + LLCoordGL out; + windowp->convertCoords(self, &out); + return out.convert(); +} + +void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from) +{ + LLCoordWindow& self = static_cast<LLCoordWindow&>(*this); + + LLWindow* windowp = &(*LLWindow::beginInstances()); + LLCoordGL from_gl(from); + windowp->convertCoords(from_gl, &self); +} + +LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const +{ + const LLCoordScreen& self = static_cast<const LLCoordScreen&>(*this); + + LLWindow* windowp = &(*LLWindow::beginInstances()); + LLCoordGL out; + windowp->convertCoords(self, &out); + return out.convert(); +} + +void LL_COORD_TYPE_SCREEN::convertFromCommon(const LLCoordCommon& from) +{ + LLCoordScreen& self = static_cast<LLCoordScreen&>(*this); + + LLWindow* windowp = &(*LLWindow::beginInstances()); + LLCoordGL from_gl(from); + windowp->convertCoords(from_gl, &self); +} + BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordGL* to) { S32 client_height; diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 39c0628cbe..76d38f067d 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -818,7 +818,7 @@ bool LLPanelPrimMediaControls::isMouseOver() LLCoordGL cursor_pos_gl; S32 x, y; getWindow()->getCursorPosition(&cursor_pos_window); - getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl); + cursor_pos_gl = cursor_pos_window.convert(); if(mMediaControlsStack->getVisible()) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 0de2545596..236c828c16 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4083,14 +4083,11 @@ void LLViewerWindow::resetSnapshotLoc() void LLViewerWindow::movieSize(S32 new_width, S32 new_height) { LLCoordWindow size; + LLCoordWindow new_size(new_width, new_height); gViewerWindow->getWindow()->getSize(&size); - if ( size.mX != new_width - || size.mY != new_height) + if ( size != new_size ) { - LLCoordWindow new_size(new_width, new_height); - LLCoordScreen screen_size; - gViewerWindow->getWindow()->convertCoords(new_size, &screen_size); - gViewerWindow->getWindow()->setSize(screen_size); + gViewerWindow->getWindow()->setSize(new_size.convert()); } } |