libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UIAnimDrawer.hpp
Go to the documentation of this file.
1 #ifndef UIANIMDRAWER_HPP
2 #define UIANIMDRAWER_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "UIContainer.hpp"
22 
23 namespace AlgAudio{
24 
26 public:
27  static std::shared_ptr<UIAnimDrawer> Create(std::weak_ptr<Window> parent_window, Direction dir);
28  virtual void Insert(std::shared_ptr<UIWidget> child) override;
29  void StartShow(float time_to_show);
30  void StartHide(float time_to_hide);
31  virtual void CustomDraw(DrawContext& c) override;
32  virtual void CustomResize(Size2D s) override;
33  virtual void OnChildRequestedSizeChanged() override;
34  virtual void OnChildVisibilityChanged() override;
35  virtual bool CustomMousePress(bool down, MouseButton b,Point2D) override;
36  virtual void CustomMouseMotion(Point2D,Point2D) override;
37  virtual void CustomMouseEnter(Point2D) override;
38  virtual void CustomMouseLeave(Point2D) override;
39  virtual Point2D GetChildPos() const override {return GetCurrentOffset(); }
40  virtual void RemoveChild() override;
41 
44 private:
45  UIAnimDrawer(std::weak_ptr<Window> parent_window, Direction dir);
46 
47  void Step(float delta);
48  Point2D GetCurrentOffset() const;
49  Size2D GetInnerSize() const;
50  void UpdateRequestedSize();
51 
52  Direction direction;
53  float phase = 0.0;
54  // 0 = stationary, 1 - showing, -1 - hiding
55  int state = 0;
56  float time_to_finish;
57  Subscription anim;
58 };
59 
60 } // namespace AlgAudio
61 
62 #endif // UIANIMDRAWER_HPP
Signal on_hide_complete
Definition: UIAnimDrawer.hpp:43
virtual void RemoveChild() override
Definition: UIContainer.hpp:27
Definition: DrawContext.hpp:65
MouseButton
Definition: Utilities.hpp:190
virtual Point2D GetChildPos() const override
Definition: UIAnimDrawer.hpp:39
virtual void CustomResize(Size2D s) override
virtual void OnChildVisibilityChanged() override
Definition: UIAnimDrawer.hpp:25
std::shared_ptr< UIWidget > child
Definition: UIContainer.hpp:54
virtual void Insert(std::shared_ptr< UIWidget > child) override
virtual void CustomMouseEnter(Point2D) override
virtual void OnChildRequestedSizeChanged() override
virtual void CustomDraw(DrawContext &c) override
Direction
Definition: Utilities.hpp:138
virtual void CustomMouseMotion(Point2D, Point2D) override
Definition: Alertable.hpp:26
virtual void CustomMouseLeave(Point2D) override
void StartShow(float time_to_show)
Definition: Signal.hpp:44
void StartHide(float time_to_hide)
virtual bool CustomMousePress(bool down, MouseButton b, Point2D) override
static std::shared_ptr< UIAnimDrawer > Create(std::weak_ptr< Window > parent_window, Direction dir)
Signal on_show_complete
Definition: UIAnimDrawer.hpp:42
Definition: Signal.hpp:145
Definition: Utilities.hpp:40