xtd 0.2.0
animation.h
Go to the documentation of this file.
1 #pragma once
6 #include "control.h"
7 #include "timer.h"
8 #include <xtd/diagnostics/stopwatch>
9 
11 namespace xtd {
13  namespace forms {
25  class animation : public xtd::forms::control {
26  struct data;
27 
28  public:
30 
33  animation();
35 
37 
41  virtual time_span elapsed() const noexcept;
42 
45  virtual int64 elapsed_milliseconds() const noexcept;
46 
49  virtual int64 elapsed_nanoseconds() const noexcept;
50 
53  virtual int64 elapsed_ticks() const noexcept;
54 
57  virtual uint32 frame_counter() const noexcept;
58 
61  virtual uint32 frames_per_second() const noexcept;
64  virtual animation& frames_per_second(uint32 value);
65 
68  virtual bool running() const noexcept;
69 
72  virtual animation& running(bool value);
74 
76 
78  using control::create;
85  static animation create(uint32 frames_per_second, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
93  static animation create(const control& parent, uint32 frames_per_second, const drawing::point& location = {-1, -1}, const drawing::size& size = {-1, -1}, const xtd::ustring& name = xtd::ustring::empty_string);
94 
96  void start();
97 
99  void stop();
101 
103 
110 
111  protected:
113 
115  drawing::size default_size() const noexcept override;
117 
119 
123  virtual void on_updated(const xtd::forms::animation_updated_event_args& e);
125 
126  private:
127  void on_frames_timer_tick(object& timer, const xtd::event_args& e);
128 
129  std::shared_ptr<data> data_;
130  };
131  }
132 }
xtd::event< animation, animation_updated_event_handler > updated
Occurs when the specified interval specified by xtd::forms::animation::frames_per_second has elapsed ...
Definition: animation.h:108
animation()
Initialize a new instance of animation class.
Contains xtd::forms::timer component.
void stop()
Stops animation of the animation control.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
virtual uint32 frames_per_second() const noexcept
Gets the number of frame per second.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
virtual const xtd::ustring & name() const noexcept
Gets the name of the control.
Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in...
Definition: timer.h:36
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
static control create(const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create a specified control with specified location, size, and name.
virtual uint32 frame_counter() const noexcept
Gets the current frame counter value.
drawing::size default_size() const noexcept override
Gets the default size of the control.
Represents an event.
Definition: event.h:21
virtual drawing::point location() const noexcept
Gets the coordinates of the upper-left corner of the control relative to the upper-left corner of its...
Represents an animation control.
Definition: animation.h:25
virtual void on_updated(const xtd::forms::animation_updated_event_args &e)
Raises the updated event.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:78
Provides data for the animation update event.
Definition: animation_update_event_args.h:20
virtual std::optional< control_ref > parent() const noexcept
Gets the parent container of the control.
Represents a time interval.
Definition: time_span.h:26
virtual time_span elapsed() const noexcept
Gets the elapsed time for the current frame, in nanoseconds.
virtual bool running() const noexcept
Gets a valiue that indicates if the animation is running.
Contains xtd::forms::control control.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition: about_box.h:13
virtual int64 elapsed_ticks() const noexcept
Gets the elapsed time for the current frame, in ticks.
static const ustring empty_string
Represents the empty string.
Definition: ustring.h:53
void start()
Starts animation of the animation control.
Contains xtd::forms::key_event_handler event handler.
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:140
virtual int64 elapsed_nanoseconds() const noexcept
Gets the elapsed time for the current frame, in nanoseconds.
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239
static animation create(uint32 frames_per_second, const drawing::point &location={-1, -1}, const drawing::size &size={-1, -1}, const xtd::ustring &name=xtd::ustring::empty_string)
A factory to create an xtd::forms::animation with specified text, location, size, and name...
size_t size
Represents a size of any object in bytes.
Definition: types.h:195
virtual int64 elapsed_milliseconds() const noexcept
Gets the elapsed time for the current frame, in milliseconds.