OpenShot Library | libopenshot  0.7.0
Timer.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2026 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_TIMER_EFFECT_H
14 #define OPENSHOT_TIMER_EFFECT_H
15 
16 #include "../Color.h"
17 #include "../EffectBase.h"
18 #include "../Enums.h"
19 #include "../Frame.h"
20 #include "../Json.h"
21 #include "../KeyFrame.h"
22 
23 #include <memory>
24 #include <string>
25 
26 namespace openshot
27 {
28  enum TimerMode {
34  };
35 
39  };
40 
41  enum TimerFormat {
47  };
48 
49  class Timer : public EffectBase
50  {
51  private:
52  void init_effect_details();
53  double ResolveFps() const;
54  int64_t EffectiveFrameNumber(int64_t frame_number) const;
55  double CountdownDuration(int64_t frame_number) const;
56  std::string FormatSeconds(double seconds, double fps, bool duration_style) const;
57  std::string FormatTimecode(double seconds, double fps) const;
58  std::string TimerLayoutText(int64_t frame_number) const;
59 
60  public:
61  int mode;
63  int format;
64  int clamp;
65  int gravity;
67  std::string font_name;
68  std::string prefix;
69  std::string suffix;
83 
84  Timer();
85 
86  std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
87  std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
88 
89  double TimerSeconds(int64_t frame_number) const;
90  std::string TimerText(int64_t frame_number) const;
91 
92  std::string Json() const override;
93  void SetJson(const std::string value) override;
94  Json::Value JsonValue() const override;
95  void SetJsonValue(const Json::Value root) override;
96  std::string PropertiesJSON(int64_t requested_frame) const override;
97  };
98 }
99 
100 #endif
openshot::Timer::background_alpha
Keyframe background_alpha
Definition: Timer.h:80
openshot::Timer::background_padding
Keyframe background_padding
Definition: Timer.h:81
openshot::TIMER_FORMAT_HH_MM_SS_MILLISECONDS
@ TIMER_FORMAT_HH_MM_SS_MILLISECONDS
Definition: Timer.h:44
openshot::Timer::TimerSeconds
double TimerSeconds(int64_t frame_number) const
Definition: Timer.cpp:189
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:56
openshot::Timer::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Timer.cpp:492
openshot::Timer::gravity
int gravity
Definition: Timer.h:65
openshot::Timer::y_offset
Keyframe y_offset
Definition: Timer.h:79
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AnimatedCurve.h:24
openshot::Timer::stroke_width
Keyframe stroke_width
Definition: Timer.h:77
openshot::Timer::stroke
Color stroke
Definition: Timer.h:71
openshot::TimerMode
TimerMode
Definition: Timer.h:28
openshot::Timer::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition: Timer.h:86
openshot::Timer::font_name
std::string font_name
Definition: Timer.h:67
openshot::Timer::color
Color color
Definition: Timer.h:70
openshot::TIMER_TIME_SOURCE
@ TIMER_TIME_SOURCE
Definition: Timer.h:38
openshot::TIMER_MODE_TIMECODE
@ TIMER_MODE_TIMECODE
Definition: Timer.h:32
openshot::Timer::clamp
int clamp
Definition: Timer.h:64
openshot::Timer::background_corner
Keyframe background_corner
Definition: Timer.h:82
openshot::Timer::font_size
Keyframe font_size
Definition: Timer.h:75
openshot::Timer::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Timer.cpp:429
openshot::Timer::TimerText
std::string TimerText(int64_t frame_number) const
Definition: Timer.cpp:201
openshot::Color
This class represents a color (used on the timeline and clips)
Definition: Color.h:27
openshot::TIMER_FORMAT_FRAMES
@ TIMER_FORMAT_FRAMES
Definition: Timer.h:46
openshot::Timer::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Timer.cpp:442
openshot::TIMER_FORMAT_HH_MM_SS
@ TIMER_FORMAT_HH_MM_SS
Definition: Timer.h:43
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
openshot::TimerTimeSource
TimerTimeSource
Definition: Timer.h:36
openshot::Timer::start_time
Keyframe start_time
Definition: Timer.h:73
openshot::TimerFormat
TimerFormat
Definition: Timer.h:41
openshot::Timer::prefix
std::string prefix
Definition: Timer.h:68
openshot::Timer::show_background
int show_background
Definition: Timer.h:66
openshot::TIMER_MODE_FRAME_NUMBER
@ TIMER_MODE_FRAME_NUMBER
Definition: Timer.h:33
openshot::Timer::Json
std::string Json() const override
Generate JSON string of this object.
Definition: Timer.cpp:395
openshot::Timer::Timer
Timer()
Definition: Timer.cpp:47
openshot::Timer::time_source
int time_source
Definition: Timer.h:62
openshot::TIMER_MODE_COUNT_UP
@ TIMER_MODE_COUNT_UP
Definition: Timer.h:29
openshot::Timer::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Timer.cpp:400
openshot::TIMER_TIME_CLIP
@ TIMER_TIME_CLIP
Definition: Timer.h:37
openshot::Timer::background
Color background
Definition: Timer.h:72
openshot::Timer::format
int format
Definition: Timer.h:63
openshot::Timer::end_time
Keyframe end_time
Definition: Timer.h:74
openshot::Timer
Definition: Timer.h:49
openshot::Timer::mode
int mode
Definition: Timer.h:61
openshot::TIMER_FORMAT_MM_SS
@ TIMER_FORMAT_MM_SS
Definition: Timer.h:42
openshot::Timer::suffix
std::string suffix
Definition: Timer.h:69
openshot::TIMER_MODE_CLOCK
@ TIMER_MODE_CLOCK
Definition: Timer.h:31
openshot::TIMER_FORMAT_TIMECODE
@ TIMER_FORMAT_TIMECODE
Definition: Timer.h:45
openshot::Timer::font_alpha
Keyframe font_alpha
Definition: Timer.h:76
openshot::Timer::x_offset
Keyframe x_offset
Definition: Timer.h:78
openshot::TIMER_MODE_COUNT_DOWN
@ TIMER_MODE_COUNT_DOWN
Definition: Timer.h:30