diff options
author | Christian Lippka <cl@openoffice.org> | 2010-12-02 13:34:17 +0100 |
---|---|---|
committer | Christian Lippka <cl@openoffice.org> | 2010-12-02 13:34:17 +0100 |
commit | c5ef5762391ce310884567b3eaa3b474e1aaab9b (patch) | |
tree | d7131a4e0673e42a6b6700059359a6315e2f9163 /slideshow/source/engine | |
parent | 1c51606b68c35a4b64a5cec854dc768afbc26759 (diff) |
impressdefaults1: #i113019# fixes to make changing of user paint settings during slideshow work
Diffstat (limited to 'slideshow/source/engine')
-rw-r--r-- | slideshow/source/engine/slide/slideimpl.cxx | 43 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.cxx | 89 | ||||
-rw-r--r-- | slideshow/source/engine/slide/userpaintoverlay.hxx | 9 | ||||
-rw-r--r-- | slideshow/source/engine/slideshowimpl.cxx | 50 |
4 files changed, 126 insertions, 65 deletions
diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index d976ad4d9697..2534b495ca90 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -139,6 +139,10 @@ public: virtual PolyPolygonVector getPolygons(); virtual void drawPolygons() const; virtual bool isPaintOverlayActive() const; + virtual void enablePaintOverlay(); + virtual void disablePaintOverlay(); + virtual void update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth ); + // TODO(F2): Rework SlideBitmap to no longer be based on XBitmap, // but on canvas-independent basegfx bitmaps @@ -156,6 +160,9 @@ private: virtual bool requestCursor( sal_Int16 nCursorShape ); virtual void resetCursor(); + void activatePaintOverlay(); + void deactivatePaintOverlay(); + /** Query whether the slide has animations at all If the slide doesn't have animations, show() displays @@ -174,9 +181,6 @@ private: */ bool isShowing() const; - void enablePaintOverlay(); - void disablePaintOverlay(); - /// Set all Shapes to their initial attributes for slideshow bool applyInitialShapeAttributes( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xRootAnimationNode ); @@ -419,6 +423,13 @@ SlideImpl::SlideImpl( const uno::Reference< drawing::XDrawPage >& xDra maContext.mrScreenUpdater.addViewUpdate(mpShapeManager); } +void SlideImpl::update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth ) +{ + maUserPaintColor = aUserPaintColor; + mdUserPaintStrokeWidth = dUserPaintStrokeWidth; + mbUserPaintOverlayEnabled = bUserPaintEnabled; +} + SlideImpl::~SlideImpl() { if( mpShapeManager ) @@ -540,7 +551,7 @@ bool SlideImpl::show( bool bSlideBackgoundPainted ) // --------------------------------------------------------------- // enable paint overlay, if maUserPaintColor is valid - enablePaintOverlay(); + activatePaintOverlay(); // --------------------------------------------------------------- @@ -564,7 +575,7 @@ void SlideImpl::hide() // disable user paint overlay under all circumstances, // this slide now ceases to be active. - disablePaintOverlay(); + deactivatePaintOverlay(); // --------------------------------------------------------------- @@ -886,19 +897,33 @@ bool SlideImpl::implPrefetchShow() void SlideImpl::enablePaintOverlay() { - if( mbUserPaintOverlayEnabled ) + if( !mbUserPaintOverlayEnabled || !mbPaintOverlayActive ) + { + mbUserPaintOverlayEnabled = true; + activatePaintOverlay(); + } +} + +void SlideImpl::disablePaintOverlay() +{ +} + +void SlideImpl::activatePaintOverlay() +{ + if( mbUserPaintOverlayEnabled || !maPolygons.empty() ) { mpPaintOverlay = UserPaintOverlay::create( maUserPaintColor, mdUserPaintStrokeWidth, maContext, - maPolygons ); + maPolygons, + mbUserPaintOverlayEnabled ); mbPaintOverlayActive = true; } } void SlideImpl::drawPolygons() const { - if( mbUserPaintOverlayEnabled ) + if( mpPaintOverlay ) mpPaintOverlay->drawPolygons(); } @@ -921,7 +946,7 @@ bool SlideImpl::isPaintOverlayActive() const return mbPaintOverlayActive; } -void SlideImpl::disablePaintOverlay() +void SlideImpl::deactivatePaintOverlay() { if(mbPaintOverlayActive) maPolygons = mpPaintOverlay->getPolygons(); diff --git a/slideshow/source/engine/slide/userpaintoverlay.cxx b/slideshow/source/engine/slide/userpaintoverlay.cxx index 98166c1ee5cf..d0ab4e33a1e3 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.cxx +++ b/slideshow/source/engine/slide/userpaintoverlay.cxx @@ -70,8 +70,9 @@ namespace slideshow ActivitiesQueue& rActivitiesQueue, ScreenUpdater& rScreenUpdater, const UnoViewContainer& rViews, - Slide& rSlide, - const PolyPolygonVector& rPolygons ) : + Slide& rSlide, + const PolyPolygonVector& rPolygons, + bool bActive ) : mrActivitiesQueue( rActivitiesQueue ), mrScreenUpdater( rScreenUpdater ), maViews(), @@ -87,7 +88,8 @@ namespace slideshow //handle the "remove stroke by stroke" mode of erasing mbIsEraseModeActivated( false ), mrSlide(rSlide), - mnSize(100) + mnSize(100), + mbActive( bActive ) { std::for_each( rViews.begin(), rViews.end(), @@ -129,6 +131,8 @@ namespace slideshow bool colorChanged( RGBColor const& rUserColor ) { + mbIsLastPointValid = false; + mbActive = true; this->maStrokeColor = rUserColor; this->mbIsEraseModeActivated = false; return true; @@ -141,15 +145,8 @@ namespace slideshow return true; } - bool eraseAllInkChanged( bool const& rEraseAllInk ) + void repaintWithoutPolygons() { - this->mbIsEraseAllModeActivated= rEraseAllInk; - // if the erase all mode is activated it will remove all ink from slide, - // therefor destroy all the polygons stored - if(mbIsEraseAllModeActivated) - { - // The Erase Mode should be desactivated - mbIsEraseModeActivated = false; // must get access to the instance to erase all polygon for( UnoViewVector::iterator aIter=maViews.begin(), aEnd=maViews.end(); aIter!=aEnd; @@ -181,7 +178,19 @@ namespace slideshow mrScreenUpdater.notifyUpdate(*aIter,true); } - maPolygons.clear(); + } + + bool eraseAllInkChanged( bool const& rEraseAllInk ) + { + this->mbIsEraseAllModeActivated= rEraseAllInk; + // if the erase all mode is activated it will remove all ink from slide, + // therefor destroy all the polygons stored + if(mbIsEraseAllModeActivated) + { + // The Erase Mode should be desactivated + mbIsEraseModeActivated = false; + repaintWithoutPolygons(); + maPolygons.clear(); } mbIsEraseAllModeActivated=false; return true; @@ -198,18 +207,25 @@ namespace slideshow bool switchPenMode() { + mbIsLastPointValid = false; + mbActive = true; this->mbIsEraseModeActivated = false; return true; } bool switchEraserMode() { + mbIsLastPointValid = false; + mbActive = true; this->mbIsEraseModeActivated = true; return true; } bool disable() { + mbIsLastPointValid = false; + mbIsLastMouseDownPosValid = false; + mbActive = false; return true; } @@ -235,6 +251,9 @@ namespace slideshow // MouseEventHandler methods virtual bool handleMousePressed( const awt::MouseEvent& e ) { + if( !mbActive ) + return false; + if (e.Buttons == awt::MouseButton::RIGHT) { mbIsLastPointValid = false; @@ -255,6 +274,9 @@ namespace slideshow virtual bool handleMouseReleased( const awt::MouseEvent& e ) { + if( !mbActive ) + return false; + if (e.Buttons == awt::MouseButton::RIGHT) { mbIsLastPointValid = false; @@ -289,6 +311,9 @@ namespace slideshow virtual bool handleMouseEntered( const awt::MouseEvent& e ) { + if( !mbActive ) + return false; + mbIsLastPointValid = true; maLastPoint.setX( e.X ); maLastPoint.setY( e.Y ); @@ -298,6 +323,9 @@ namespace slideshow virtual bool handleMouseExited( const awt::MouseEvent& ) { + if( !mbActive ) + return false; + mbIsLastPointValid = false; mbIsLastMouseDownPosValid = false; @@ -306,7 +334,16 @@ namespace slideshow virtual bool handleMouseDragged( const awt::MouseEvent& e ) { - if(mbIsEraseModeActivated) + if( !mbActive ) + return false; + + if (e.Buttons == awt::MouseButton::RIGHT) + { + mbIsLastPointValid = false; + return false; + } + + if(mbIsEraseModeActivated) { //define the last point as an object //we suppose that there's no way this point could be valid @@ -421,6 +458,14 @@ namespace slideshow } + void update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth ) + { + maStrokeColor = aUserPaintColor; + mnStrokeWidth = dUserPaintStrokeWidth; + mbActive = bUserPaintEnabled; + if( !mbActive ) + disable(); + } private: ActivitiesQueue& mrActivitiesQueue; @@ -438,17 +483,20 @@ namespace slideshow bool mbIsEraseModeActivated; Slide& mrSlide; sal_Int32 mnSize; + bool mbActive; }; UserPaintOverlaySharedPtr UserPaintOverlay::create( const RGBColor& rStrokeColor, double nStrokeWidth, const SlideShowContext& rContext, - const PolyPolygonVector& rPolygons ) + const PolyPolygonVector& rPolygons, + bool bActive ) { UserPaintOverlaySharedPtr pRet( new UserPaintOverlay( rStrokeColor, nStrokeWidth, rContext, - rPolygons )); + rPolygons, + bActive)); return pRet; } @@ -456,7 +504,8 @@ namespace slideshow UserPaintOverlay::UserPaintOverlay( const RGBColor& rStrokeColor, double nStrokeWidth, const SlideShowContext& rContext, - const PolyPolygonVector& rPolygons ) : + const PolyPolygonVector& rPolygons, + bool bActive ) : mpHandler( new PaintOverlayHandler( rStrokeColor, nStrokeWidth, rContext.mrActivitiesQueue, @@ -464,7 +513,7 @@ namespace slideshow rContext.mrViewContainer, //adding a link to Slide dynamic_cast<Slide&>(rContext.mrCursorManager), - rPolygons )), + rPolygons, bActive )), mrMultiplexer( rContext.mrEventMultiplexer ) { mrMultiplexer.addClickHandler( mpHandler, 3.0 ); @@ -483,6 +532,12 @@ namespace slideshow mpHandler->drawPolygons(); } + void UserPaintOverlay::update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth ) + { + mpHandler->update_settings( bUserPaintEnabled, aUserPaintColor, dUserPaintStrokeWidth ); + } + + UserPaintOverlay::~UserPaintOverlay() { try diff --git a/slideshow/source/engine/slide/userpaintoverlay.hxx b/slideshow/source/engine/slide/userpaintoverlay.hxx index b92f5f2539b0..3a8e14c600c5 100644 --- a/slideshow/source/engine/slide/userpaintoverlay.hxx +++ b/slideshow/source/engine/slide/userpaintoverlay.hxx @@ -69,16 +69,21 @@ namespace slideshow static UserPaintOverlaySharedPtr create( const RGBColor& rStrokeColor, double nStrokeWidth, const SlideShowContext& rContext, - const PolyPolygonVector& rPolygons ); + const PolyPolygonVector& rPolygons, + bool bActive); ~UserPaintOverlay(); PolyPolygonVector getPolygons(); void drawPolygons(); + void update_settings( bool bUserPaintEnabled, RGBColor const& aUserPaintColor, double dUserPaintStrokeWidth ); + + private: UserPaintOverlay( const RGBColor& rStrokeColor, double nStrokeWidth, const SlideShowContext& rContext, - const PolyPolygonVector& rPolygons ); + const PolyPolygonVector& rPolygons, + bool bActive ); ::boost::shared_ptr<PaintOverlayHandler> mpHandler; EventMultiplexer& mrMultiplexer; diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index 83ce94a4a184..a909ade61ee2 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -458,7 +458,7 @@ private: boost::optional<RGBColor> maUserPaintColor; - boost::optional<double> maUserPaintStrokeWidth; + double maUserPaintStrokeWidth; //changed for the eraser project boost::optional<bool> maEraseAllInk; @@ -950,7 +950,7 @@ SlideSharedPtr SlideShowImpl::makeSlide( maShapeCursors, (aIter != maPolygons.end()) ? aIter->second : PolyPolygonVector(), maUserPaintColor ? *maUserPaintColor : RGBColor(), - *maUserPaintStrokeWidth, + maUserPaintStrokeWidth, !!maUserPaintColor, mbImageAnimationsAllowed, mbDisableAnimationZOrder) ); @@ -1616,6 +1616,9 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) // enable user paint maUserPaintColor.reset( unoColor2RGBColor( nColor ) ); + if( mpCurrentSlide && !mpCurrentSlide->isPaintOverlayActive() ) + mpCurrentSlide->enablePaintOverlay(); + maEventMultiplexer.notifyUserPaintColor( *maUserPaintColor ); } else @@ -1623,10 +1626,11 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) // disable user paint maUserPaintColor.reset(); maEventMultiplexer.notifyUserPaintDisabled(); + if( mpCurrentSlide ) + mpCurrentSlide->disablePaintOverlay(); } - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); + resetCursor(); return true; } @@ -1645,15 +1649,6 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) maEraseAllInk.reset( nEraseAllInk ); maEventMultiplexer.notifyEraseAllInk( *maEraseAllInk ); } - else - { - // disable user paint - maEraseAllInk.reset(); - maEventMultiplexer.notifyUserPaintDisabled(); - } - - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); return true; } @@ -1673,9 +1668,6 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) maEventMultiplexer.notifySwitchPenMode(); } } - - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); return true; } @@ -1695,8 +1687,6 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) } } - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); return true; } @@ -1715,15 +1705,6 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) maEraseInk.reset( nEraseInk ); maEventMultiplexer.notifyEraseInkWidth( *maEraseInk ); } - else - { - // disable user paint - maEraseInk.reset(); - maEventMultiplexer.notifyUserPaintDisabled(); - } - - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); return true; } @@ -1737,17 +1718,10 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty ) { OSL_ENSURE( mbMouseVisible,"setProperty(): User paint overrides invisible mouse" ); // enable user paint stroke width - maUserPaintStrokeWidth.reset( nWidth ); - maEventMultiplexer.notifyUserPaintStrokeWidth( *maUserPaintStrokeWidth ); - } - else - { - // disable user paint stroke width - maUserPaintStrokeWidth.reset(); - maEventMultiplexer.notifyUserPaintDisabled(); + maUserPaintStrokeWidth = nWidth; + maEventMultiplexer.notifyUserPaintStrokeWidth( maUserPaintStrokeWidth ); } - if( mnCurrentCursor == awt::SystemPointer::ARROW ) - resetCursor(); + return true; } @@ -2210,6 +2184,8 @@ void SlideShowImpl::notifySlideTransitionEnded( bool bPaintSlide ) "notifySlideTransitionEnded(): Invalid current slide" ); if (mpCurrentSlide) { + mpCurrentSlide->update_settings( !!maUserPaintColor, maUserPaintColor ? *maUserPaintColor : RGBColor(), maUserPaintStrokeWidth ); + // first init show, to give the animations // the chance to register SlideStartEvents const bool bBackgroundLayerRendered( !bPaintSlide ); |