[Libreoffice-commits] .: 3 commits - sd/source
Jan Holesovsky
kendy at kemper.freedesktop.org
Fri Feb 17 14:51:19 PST 2012
sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx | 6
sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx | 6
sd/source/ui/slidesorter/view/SlideSorterView.cxx | 14 +
sd/source/ui/slidesorter/view/SlsButtonBar.cxx | 129 +++++++-----------
4 files changed, 71 insertions(+), 84 deletions(-)
New commits:
commit 4866b20ec6205b04cd21077fd00d68c4d4bb2c1b
Author: Jan Holesovsky <kendy at suse.cz>
Date: Fri Feb 17 23:32:52 2012 +0100
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.
diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
index 4229665..d65bb90 100644
--- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
@@ -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);
diff --git a/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx b/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
index 13b49f0..c6faee3 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
@@ -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;
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 4d63677..935f191 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -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);
}
diff --git a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
index 06a2074..fc4d05b 100644
--- a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
+++ b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
@@ -68,19 +68,25 @@ 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);
}
commit ebd3d9c77e5c35258d8b49ddd18d9c52b10c6cc3
Author: Jan Holesovsky <kendy at suse.cz>
Date: Fri Feb 17 21:35:13 2012 +0100
Slidesorter: Kill unused maButtonDownBackground.
diff --git a/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx b/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
index 6d8ce62..13b49f0 100644
--- a/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlsButtonBar.hxx
@@ -143,7 +143,6 @@ private:
::std::vector<SharedButton> maRegularButtons;
::std::vector<SharedButton> maExcludedButtons;
BitmapEx maNormalBackground;
- BitmapEx maButtonDownBackground;
bool mbIsMouseOverBar;
::boost::scoped_ptr<BackgroundTheme> mpBackgroundTheme;
int mnLockCount;
diff --git a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
index 6145b94..06a2074 100644
--- a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
+++ b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
@@ -159,7 +159,6 @@ ButtonBar::ButtonBar (SlideSorter& rSlideSorter)
maRegularButtons(),
maExcludedButtons(),
maNormalBackground(),
- maButtonDownBackground(),
mbIsMouseOverBar(false),
mpBackgroundTheme(),
mnLockCount(0)
@@ -409,27 +408,19 @@ void ButtonBar::PaintButtonBackground (
const model::SharedPageDescriptor& rpDescriptor,
const Point aOffset)
{
- BitmapEx* pBitmap = NULL;
- if (maButtonDownBackground.IsEmpty() || maNormalBackground.IsEmpty())
+ if (maNormalBackground.IsEmpty())
{
if (mpBackgroundTheme)
- {
- maButtonDownBackground = mpBackgroundTheme->CreateBackground();
maNormalBackground = mpBackgroundTheme->CreateBackground();
- }
}
- if (mpButtonUnderMouse && mpButtonUnderMouse->IsDown())
- pBitmap = &maButtonDownBackground;
- else
- pBitmap = &maNormalBackground;
- if (pBitmap != NULL)
+ if (!maNormalBackground.IsEmpty())
{
- AlphaMask aMask (pBitmap->GetSizePixel());
+ AlphaMask aMask (maNormalBackground.GetSizePixel());
AdaptTransparency(
aMask,
- pBitmap->GetAlpha(),
+ maNormalBackground.GetAlpha(),
rpDescriptor->GetVisualState().GetButtonBarAlpha());
- rDevice.DrawBitmapEx(maBackgroundLocation+aOffset, BitmapEx(pBitmap->GetBitmap(), aMask));
+ rDevice.DrawBitmapEx(maBackgroundLocation+aOffset, BitmapEx(maNormalBackground.GetBitmap(), aMask));
}
}
@@ -469,7 +460,6 @@ void ButtonBar::LayoutButtons (const Size aPageObjectSize)
// Release the background bitmaps so that on the next paint
// they are created anew in the right size.
maNormalBackground.SetEmpty();
- maButtonDownBackground.SetEmpty();
}
}
commit c6b151f1f8f11d7600058638c6598c1828429b6e
Author: Jan Holesovsky <kendy at suse.cz>
Date: Fri Feb 17 19:27:43 2012 +0100
Slidesorter: No need for abstraction when there is only one descendant.
diff --git a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
index e70dda8..6145b94 100644
--- a/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
+++ b/sd/source/ui/slidesorter/view/SlsButtonBar.cxx
@@ -78,11 +78,9 @@ public:
void SetPreviewBoundingBox (const Rectangle& rPreviewBoundingBox);
Button::IconSize GetIconSize (void) const;
- virtual BitmapEx CreateBackground (
- const OutputDevice& rTemplateDevice,
- const bool bIsButtonDown) const = 0;
- virtual Point GetBackgroundLocation (void) = 0;
- virtual Rectangle GetButtonArea (void) = 0;
+ virtual BitmapEx CreateBackground () const;
+ virtual Point GetBackgroundLocation (void);
+ virtual Rectangle GetButtonArea (void);
protected:
::boost::shared_ptr<Theme> mpTheme;
@@ -91,8 +89,10 @@ protected:
Size maMinimumMediumButtonAreaSize;
Size maMinimumSmallButtonAreaSize;
Button::IconSize meIconSize;
+ Rectangle maButtonArea;
+ Point maBackgroundLocation;
- virtual void Layout (void) = 0;
+ virtual void Layout (void);
private:
void UpdateMinimumIconSizes(const ::std::vector<SharedButton>& rButtons);
@@ -100,29 +100,6 @@ private:
namespace {
- /** Button bar is composed of three images, the left and right end of
- the bar and the center image. Buttons are only placed over the
- center image. The center image is painted as is, it is not scaled.
- */
- class BitmapBackgroundTheme : public ButtonBar::BackgroundTheme
- {
- public:
- BitmapBackgroundTheme(
- const ::boost::shared_ptr<Theme>& rpTheme,
- const ::std::vector<SharedButton>& rButtons);
- virtual ~BitmapBackgroundTheme() { }
- virtual BitmapEx CreateBackground (
- const OutputDevice& rTemplateDevice,
- const bool bIsButtonDown) const;
- virtual Point GetBackgroundLocation (void);
- virtual Rectangle GetButtonArea (void);
- protected:
- virtual void Layout (void);
- private:
- Rectangle maButtonArea;
- Point maBackgroundLocation;
- };
-
/** The source mask is essentially multiplied with the given alpha value.
The result is writen to the result mask.
*/
@@ -437,8 +414,8 @@ void ButtonBar::PaintButtonBackground (
{
if (mpBackgroundTheme)
{
- maButtonDownBackground = mpBackgroundTheme->CreateBackground(rDevice, true);
- maNormalBackground = mpBackgroundTheme->CreateBackground(rDevice, false);
+ maButtonDownBackground = mpBackgroundTheme->CreateBackground();
+ maNormalBackground = mpBackgroundTheme->CreateBackground();
}
}
if (mpButtonUnderMouse && mpButtonUnderMouse->IsDown())
@@ -640,7 +617,7 @@ void ButtonBar::HandleDataChangeEvent (void)
maRegularButtons.push_back(::boost::shared_ptr<Button>(new DuplicateButton(mrSlideSorter)));
mpBackgroundTheme.reset(
- new BitmapBackgroundTheme(
+ new BackgroundTheme(
mrSlideSorter.GetTheme(),
maRegularButtons));
@@ -741,7 +718,9 @@ void ButtonBar::ReleaseLock (void)
ButtonBar::BackgroundTheme::BackgroundTheme (
const ::boost::shared_ptr<Theme>& rpTheme,
const ::std::vector<SharedButton>& rButtons)
- : mpTheme(rpTheme)
+ : mpTheme(rpTheme),
+ maButtonArea(),
+ maBackgroundLocation()
{
UpdateMinimumIconSizes(rButtons);
}
@@ -806,27 +785,8 @@ Button::IconSize ButtonBar::BackgroundTheme::GetIconSize (void) const
-//===== BitmapBackgroundTheme =================================================
-
-BitmapBackgroundTheme::BitmapBackgroundTheme (
- const ::boost::shared_ptr<Theme>& rpTheme,
- const ::std::vector<SharedButton>& rButtons)
- : BackgroundTheme(rpTheme, rButtons),
- maButtonArea(),
- maBackgroundLocation()
-{
-}
-
-
-
-
-BitmapEx BitmapBackgroundTheme::CreateBackground (
- const OutputDevice& rTemplateDevice,
- const bool bIsButtonDown) const
+BitmapEx ButtonBar::BackgroundTheme::CreateBackground () const
{
- (void)rTemplateDevice;
- (void)bIsButtonDown;
-
OSL_ASSERT(mpTheme);
// Get images.
@@ -847,7 +807,7 @@ BitmapEx BitmapBackgroundTheme::CreateBackground (
-Point BitmapBackgroundTheme::GetBackgroundLocation (void)
+Point ButtonBar::BackgroundTheme::GetBackgroundLocation (void)
{
return maBackgroundLocation;
}
@@ -855,7 +815,7 @@ Point BitmapBackgroundTheme::GetBackgroundLocation (void)
-Rectangle BitmapBackgroundTheme::GetButtonArea (void)
+Rectangle ButtonBar::BackgroundTheme::GetButtonArea (void)
{
return maButtonArea;
}
@@ -863,7 +823,7 @@ Rectangle BitmapBackgroundTheme::GetButtonArea (void)
-void BitmapBackgroundTheme::Layout (void)
+void ButtonBar::BackgroundTheme::Layout (void)
{
Size aImageSize (mpTheme->GetIcon(Theme::Icon_ButtonBarLarge).GetSizePixel());
if (aImageSize.Width() >= maPreviewBoundingBox.GetWidth())
@@ -1034,10 +994,8 @@ void ImageButton::Paint (
OutputDevice& rDevice,
const Point aOffset,
const double nAlpha,
- const ::boost::shared_ptr<Theme>& rpTheme) const
+ const ::boost::shared_ptr<Theme>&) const
{
- (void)rpTheme;
-
if ( ! mbIsActive)
return;
More information about the Libreoffice-commits
mailing list