Slidesorter: Show the buttons on the opposite side...
...compared to where the mouse entered the slide thumbnail. This seems to prevent a user annoyance when you very often used to hide the slide, instead of just selecting it.
This commit is contained in:
parent
ebd3d9c77e
commit
4866b20ec6
4 changed files with 55 additions and 15 deletions
|
@ -226,13 +226,15 @@ public:
|
|||
const bool bAnimate = true);
|
||||
void SetPageUnderMouse (
|
||||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const bool bAnimate = true);
|
||||
const bool bAnimate = true,
|
||||
const Point& rMousePosition = Point());
|
||||
|
||||
bool SetState (
|
||||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const model::PageDescriptor::State eState,
|
||||
const bool bStateValue,
|
||||
const bool bAnimate = true);
|
||||
const bool bAnimate = true,
|
||||
const Point& rMousePosition = Point());
|
||||
|
||||
void UpdateOrientation (void);
|
||||
|
||||
|
|
|
@ -69,6 +69,11 @@ public:
|
|||
const Point aMouseModelLocation,
|
||||
const bool bIsMouseButtonDown);
|
||||
|
||||
/// Decide whether the button should be drawn at the top, or the bottom.
|
||||
void UpdateButtonPosition(
|
||||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const Point& rMousePosition);
|
||||
|
||||
void ResetPage (void);
|
||||
|
||||
bool IsMouseOverBar (void) const;
|
||||
|
|
|
@ -958,7 +958,7 @@ void SlideSorterView::UpdatePageUnderMouse (
|
|||
const bool bAnimate)
|
||||
{
|
||||
// Update the page under the mouse.
|
||||
SetPageUnderMouse(rpDescriptor, bAnimate);
|
||||
SetPageUnderMouse(rpDescriptor, bAnimate, rMousePosition);
|
||||
|
||||
// Tell the button bar about the new mouse position.
|
||||
SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
|
||||
|
@ -986,7 +986,8 @@ void SlideSorterView::UpdatePageUnderMouse (
|
|||
|
||||
void SlideSorterView::SetPageUnderMouse (
|
||||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const bool bAnimate)
|
||||
const bool bAnimate,
|
||||
const Point& rMousePosition)
|
||||
{
|
||||
if (mpPageUnderMouse != rpDescriptor)
|
||||
{
|
||||
|
@ -996,7 +997,7 @@ void SlideSorterView::SetPageUnderMouse (
|
|||
mpPageUnderMouse = rpDescriptor;
|
||||
|
||||
if (mpPageUnderMouse)
|
||||
SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true, bAnimate);
|
||||
SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true, bAnimate, rMousePosition);
|
||||
|
||||
// Change the quick help text to display the name of the page under
|
||||
// the mouse.
|
||||
|
@ -1011,7 +1012,8 @@ bool SlideSorterView::SetState (
|
|||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const PageDescriptor::State eState,
|
||||
const bool bStateValue,
|
||||
const bool bAnimate)
|
||||
const bool bAnimate,
|
||||
const Point& rMousePosition)
|
||||
{
|
||||
model::SharedPageDescriptor pDescriptor (rpDescriptor);
|
||||
if ( ! pDescriptor)
|
||||
|
@ -1039,7 +1041,11 @@ bool SlideSorterView::SetState (
|
|||
if (eState == PageDescriptor::ST_MouseOver)
|
||||
{
|
||||
if (bStateValue)
|
||||
{
|
||||
if (bAnimate)
|
||||
GetButtonBar().UpdateButtonPosition(rpDescriptor, rMousePosition);
|
||||
GetButtonBar().RequestFadeIn(rpDescriptor, bAnimate);
|
||||
}
|
||||
else
|
||||
GetButtonBar().RequestFadeOut(rpDescriptor, bAnimate);
|
||||
}
|
||||
|
|
|
@ -67,20 +67,26 @@ namespace sd { namespace slidesorter { namespace view {
|
|||
*/
|
||||
class ButtonBar::BackgroundTheme
|
||||
{
|
||||
public:
|
||||
enum ButtonPosition { TOP, BOTTOM };
|
||||
public:
|
||||
BackgroundTheme(
|
||||
const ::boost::shared_ptr<Theme>& rpTheme,
|
||||
const ::std::vector<SharedButton>& rButtons);
|
||||
virtual ~BackgroundTheme() { }
|
||||
~BackgroundTheme() { }
|
||||
/** Set the preview bounding box, the maximal area in which to display
|
||||
buttons. A call to this method triggers a call to Layout().
|
||||
*/
|
||||
void SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox);
|
||||
Button::IconSize GetIconSize (void) const;
|
||||
|
||||
virtual BitmapEx CreateBackground () const;
|
||||
virtual Point GetBackgroundLocation (void);
|
||||
virtual Rectangle GetButtonArea (void);
|
||||
BitmapEx CreateBackground () const;
|
||||
Point GetBackgroundLocation (void);
|
||||
Rectangle GetButtonArea (void);
|
||||
void SetButtonPosition( ButtonPosition ePosition ) { mePosition = ePosition; }
|
||||
|
||||
/// Compute the positions & sizes.
|
||||
void Layout (void);
|
||||
|
||||
protected:
|
||||
::boost::shared_ptr<Theme> mpTheme;
|
||||
|
@ -92,7 +98,8 @@ protected:
|
|||
Rectangle maButtonArea;
|
||||
Point maBackgroundLocation;
|
||||
|
||||
virtual void Layout (void);
|
||||
/// This comes into effect only during Layout(), before it only caches the value.
|
||||
ButtonPosition mePosition;
|
||||
|
||||
private:
|
||||
void UpdateMinimumIconSizes(const ::std::vector<SharedButton>& rButtons);
|
||||
|
@ -275,6 +282,24 @@ void ButtonBar::ProcessMouseMotionEvent (
|
|||
}
|
||||
|
||||
|
||||
void ButtonBar::UpdateButtonPosition(
|
||||
const model::SharedPageDescriptor& rpDescriptor,
|
||||
const Point& rMousePosition)
|
||||
{
|
||||
if (rpDescriptor && mpBackgroundTheme)
|
||||
{
|
||||
Rectangle aRectangle( rpDescriptor->GetBoundingBox() );
|
||||
aRectangle.Bottom() -= aRectangle.GetHeight() / 2;
|
||||
|
||||
if (aRectangle.IsInside(rMousePosition))
|
||||
mpBackgroundTheme->SetButtonPosition(ButtonBar::BackgroundTheme::BOTTOM);
|
||||
else
|
||||
mpBackgroundTheme->SetButtonPosition(ButtonBar::BackgroundTheme::TOP);
|
||||
|
||||
// Relayout, to propagate the newest location of the buttons
|
||||
LayoutButtons();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ButtonBar::ResetPage (void)
|
||||
|
@ -503,6 +528,7 @@ bool ButtonBar::LayoutButtons (void)
|
|||
nMaximumHeight += 2*nBorder;
|
||||
|
||||
// Set up the bounding box of the button bar.
|
||||
mpBackgroundTheme->Layout();
|
||||
maButtonBoundingBox = mpBackgroundTheme->GetButtonArea();
|
||||
maBackgroundLocation = mpBackgroundTheme->GetBackgroundLocation();
|
||||
if (mrSlideSorter.GetTheme()->GetIntegerValue(Theme::Integer_ButtonPaintType) == 1)
|
||||
|
@ -710,7 +736,8 @@ ButtonBar::BackgroundTheme::BackgroundTheme (
|
|||
const ::std::vector<SharedButton>& rButtons)
|
||||
: mpTheme(rpTheme),
|
||||
maButtonArea(),
|
||||
maBackgroundLocation()
|
||||
maBackgroundLocation(),
|
||||
mePosition( BOTTOM )
|
||||
{
|
||||
UpdateMinimumIconSizes(rButtons);
|
||||
}
|
||||
|
@ -833,9 +860,9 @@ void ButtonBar::BackgroundTheme::Layout (void)
|
|||
}
|
||||
|
||||
maBackgroundLocation = Point(
|
||||
maPreviewBoundingBox.Left()
|
||||
+ (maPreviewBoundingBox.GetWidth()-aImageSize.Width())/2,
|
||||
maPreviewBoundingBox.Bottom() - aImageSize.Height());
|
||||
maPreviewBoundingBox.Left() + (maPreviewBoundingBox.GetWidth()-aImageSize.Width())/2,
|
||||
mePosition == TOP? maPreviewBoundingBox.Top():
|
||||
maPreviewBoundingBox.Bottom() - aImageSize.Height());
|
||||
maButtonArea = Rectangle(maBackgroundLocation, aImageSize);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue