1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
24 #include <eventmultiplexer.hxx>
25 #include <mouseeventhandler.hxx>
26 #include <screenupdater.hxx>
27 #include <unoview.hxx>
28 #include <vieweventhandler.hxx>
30 #include <basegfx/point/b2dpoint.hxx>
31 #include <cppcanvas/sprite.hxx>
33 #include <com/sun/star/rendering/XBitmap.hpp>
34 #include <com/sun/star/awt/Point.hpp>
40 namespace slideshow::internal
42 class EventMultiplexer
;
43 typedef std::shared_ptr
<class SlideOverlayButton
> SlideOverlayButtonSharedPtr
;
45 class SlideOverlayButton
: public ViewEventHandler
, public MouseEventHandler
48 SlideOverlayButton(const SlideOverlayButton
&) = delete;
49 SlideOverlayButton
& operator=(const SlideOverlayButton
&) = delete;
51 static SlideOverlayButtonSharedPtr
52 create(const css::uno::Reference
<css::rendering::XBitmap
>& xIconBitmap
,
53 const css::awt::Point
& rPosition
,
54 const std::function
<void(basegfx::B2DPoint
)>& clickHandler
,
55 ScreenUpdater
& rScreenUpdater
, EventMultiplexer
& rEventMultiplexer
,
56 const UnoViewContainer
& rViewContainer
);
58 /** Shows button icon.
60 void show() { setVisible(true); }
62 /** Hides button icon.
64 void hide() { setVisible(false); }
66 css::geometry::IntegerSize2D
getSize() const;
67 basegfx::B2DPoint
calcSpritePos(UnoViewSharedPtr
const& rView
) const;
70 SlideOverlayButton(css::uno::Reference
<css::rendering::XBitmap
> xIconBitmap
,
71 css::awt::Point pPosition
,
72 std::function
<void(basegfx::B2DPoint
)> clickHandler
,
73 ScreenUpdater
& rScreenUpdater
, EventMultiplexer
& rEventMultiplexer
,
74 const UnoViewContainer
& rViewContainer
);
77 virtual void viewAdded(const UnoViewSharedPtr
& rView
) override
;
78 virtual void viewRemoved(const UnoViewSharedPtr
& rView
) override
;
79 virtual void viewChanged(const UnoViewSharedPtr
& rView
) override
;
80 virtual void viewsChanged() override
;
83 virtual bool handleMousePressed(const css::awt::MouseEvent
& e
) override
;
84 virtual bool handleMouseReleased(const css::awt::MouseEvent
& e
) override
;
85 virtual bool handleMouseDragged(const css::awt::MouseEvent
& e
) override
;
86 virtual bool handleMouseMoved(const css::awt::MouseEvent
& e
) override
;
88 void setVisible(const bool bVisible
);
90 typedef std::vector
<std::pair
<UnoViewSharedPtr
, cppcanvas::CustomSpriteSharedPtr
>> ViewsVecT
;
92 css::uno::Reference
<css::rendering::XBitmap
> mxIconBitmap
;
93 EventMultiplexer
& mrEventMultiplexer
;
94 css::awt::Point mpPosition
;
95 std::function
<void(basegfx::B2DPoint
)> mClickHandler
;
98 ScreenUpdater
& mrScreenUpdater
;
99 bool mbVisible
= false;
100 sal_Int32 mnIgnoreClicksCnt
= 0;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */