TGUI  1.4.0
No Matches
tgui::Duration Class Reference

Wrapper for durations. More...

#include <TGUI/Duration.hpp>

Public Member Functions

constexpr Duration ()
 Creates an zero-length duration.
template<typename Rep , typename Period >
constexpr Duration (std::chrono::duration< Rep, Period > duration)
 Creates the duration from any kind of std::chrono::duration.
constexpr Duration (int milliseconds)
 Creates the duration from a given amount of milliseconds.
 Duration (sf::Time duration)
 Creates the duration from an sf::Time instance.
TGUI_NODISCARD constexpr float asSeconds () const
 Returns the duration in seconds.
constexpr operator std::chrono::nanoseconds () const
 Convert the duration to std::chrono::nanoseconds.
template<typename Rep , typename Period >
constexpr operator std::chrono::duration< Rep, Period > () const
 Convert the duration to std::chrono::duration.
 operator sf::Time () const
 Convert the duration to sf::Time.

Detailed Description

Wrapper for durations.

You do not have to use class directly in your code unless you want to store the duration. Functions taking tgui::Duration as parameter can be directly passed arguments like:

  • sf::microseconds(500)
  • std::chrono::nanoseconds(20000)
  • std::chrono::milliseconds(10) / 2.0f
  • 200 // unit is milliseconds

Constructor & Destructor Documentation

◆ Duration()

tgui::Duration::Duration ( int milliseconds)

Creates the duration from a given amount of milliseconds.

millisecondsAmount of milliseconds to store in the duration

The documentation for this class was generated from the following file: