change time.h into a multilingual header
This commit is contained in:
parent
71aacc7698
commit
237d287021
10 changed files with 75 additions and 33 deletions
|
|
@ -29,9 +29,8 @@
|
|||
#include "gui/model/project.hpp"
|
||||
#include "gui/controller/controller.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace sigc;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,8 @@
|
|||
#include "gui/window-manager.hpp"
|
||||
#include "gui/util/cairo-util.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace Cairo;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ liblumiera_la_SOURCES = \
|
|||
$(liblumiera_la_srcdir)/test/suite.cpp \
|
||||
$(liblumiera_la_srcdir)/test/test-helper.cpp \
|
||||
$(liblumiera_la_srcdir)/test/testoption.cpp \
|
||||
$(liblumiera_la_srcdir)/time.c \
|
||||
$(liblumiera_la_srcdir)/time.cpp \
|
||||
$(liblumiera_la_srcdir)/time/lumitime.cpp \
|
||||
$(liblumiera_la_srcdir)/time/quantiser.cpp \
|
||||
$(liblumiera_la_srcdir)/time/timecode.cpp \
|
||||
|
|
|
|||
|
|
@ -45,13 +45,11 @@
|
|||
#define LUMIERA_LUMITIME_FMT_H
|
||||
|
||||
#include "lib/lumitime.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <nobug.h>
|
||||
#include "lib/time.h"
|
||||
#include "lib/error.hpp"
|
||||
extern "C" {
|
||||
#include "lib/tmpbuf.h"
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/* GAVL_TIME_SCALE is the correct factor or dividend when using gavl_time_t for
|
||||
|
|
@ -19,17 +19,66 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/** @file time.h
|
||||
** Common functions for handling of time values.
|
||||
** Working with time values in sexagesimal format, quantising time and converting
|
||||
** to/from common timecode formats can be tricky to get right. Thus the goal is
|
||||
** to concentrate the actual bits of math for these operations into a small number
|
||||
** of library functions, which are easy to test thoroughly in isolation.
|
||||
**
|
||||
** Built on top of that, the actual time handling in the GUI and within the Lumiera
|
||||
** session is mostly confined to use the opaque lib::time::Time wrapper objects.
|
||||
** When time values actually need to be \em quantised (aligned to a frame grid),
|
||||
** this is expressed at the API through using the lib::time::QuTime type, which
|
||||
** then in turn can be materialised into a number of \em timecode formats.
|
||||
** These definitions ensure that whenever an actual quantisation (rounding)
|
||||
** operation is performed, the link to the appropriate time grid is available,
|
||||
** so that multiple output or rendering operations can use differing time origins
|
||||
** and frame rates simultaneously on the same model.
|
||||
**
|
||||
** The Lumiera backend functions mostly operate on raw frame counts, which in this
|
||||
** model are defined to be a special kind of timecode, and thus dependent on a
|
||||
** preceding time quantisation.
|
||||
**
|
||||
**
|
||||
** @see lib::time::Time
|
||||
** @see timequant.hpp
|
||||
** @see TimeValue_test
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LUMIERA_TIME_H
|
||||
#define LUMIERA_TIME_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <gavl/gavl.h>
|
||||
|
||||
#ifdef __cplusplus /*=================== C++ facilities ===================== */
|
||||
#include "lib/time/timevalue.hpp"
|
||||
|
||||
|
||||
/**
|
||||
* Formats a time in a safeclib tmpbuf in HH:MM:SS:mmm format.
|
||||
* @param size maximal length for the string
|
||||
* @param the time value to print
|
||||
* @return safeclib temporary buffer containing the constructed of the string
|
||||
* Converts a fraction of seconds to Lumiera's internal opaque time scale.
|
||||
* @param fractionalSeconds given as rational number
|
||||
*/
|
||||
inline gavl_time_t
|
||||
lumiera_rational_to_time (lib::time::FSecs const& fractionalSeconds)
|
||||
{
|
||||
return boost::rational_cast<gavl_time_t> (GAVL_TIME_SCALE * fractionalSeconds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C" { /* ===================== C interface ======================== */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Formats a time value in H:MM:SS.mmm format into a temporary buffer.
|
||||
* @return safeclib temporary buffer containing formatted time string
|
||||
*/
|
||||
char*
|
||||
lumiera_tmpbuf_print_time (gavl_time_t time);
|
||||
|
|
@ -41,19 +90,19 @@ lumiera_tmpbuf_print_time (gavl_time_t time);
|
|||
* as zero. Each interval includes its lower bound, but excludes its upper bound.
|
||||
* @param grid spacing of the grid intervals, measured in GAVL_TIME_SCALE
|
||||
* @return number of the grid interval containing the given time.
|
||||
* @warning the resulting value is limited such as to fit into a 64bit long
|
||||
* @warning the resulting value is limited to (Time::Min, Time::MAX)
|
||||
*/
|
||||
int64_t
|
||||
lumiera_quantise_frames (gavl_time_t time, double grid, gavl_time_t origin);
|
||||
|
||||
/**
|
||||
* Similar to #lumiera_quantise_frames, but returns a grid aligned \em time value
|
||||
* Similar to #lumiera_quantise_frames, but returns a grid aligned \em time value
|
||||
* @return time of start of the grid interval containing the given time,
|
||||
* but measured relative to the origin
|
||||
* @warning because the resulting value needs to be limited to fit into a 64bit long,
|
||||
* the addressable time range can be considerably reduced. For example, if
|
||||
* origin = LLONG_MIN, then all original time values above zero will be
|
||||
* clipped, because the result, relative to origin, needs to be <= LLONG_MAX
|
||||
* origin = Time::MIN, then all original time values above zero will be
|
||||
* clipped, because the result, relative to origin, needs to be <= Time::MAX
|
||||
*/
|
||||
gavl_time_t
|
||||
lumiera_quantise_time (gavl_time_t time, double grid, gavl_time_t origin);
|
||||
|
|
@ -65,24 +114,28 @@ gavl_time_t
|
|||
lumiera_build_time (long millis, uint secs, uint mins, uint hours);
|
||||
|
||||
/**
|
||||
* Get the hour part of given time.
|
||||
* Extract the hour part of given time.
|
||||
*/
|
||||
int lumiera_time_hours(gavl_time_t time);
|
||||
|
||||
/**
|
||||
* Get the minute part of given time.
|
||||
* Extract the minute part of given time.
|
||||
*/
|
||||
int lumiera_time_minutes(gavl_time_t time);
|
||||
|
||||
/**
|
||||
* Get the seconds part of given time.
|
||||
* Extract the seconds part of given time.
|
||||
*/
|
||||
int lumiera_time_seconds(gavl_time_t time);
|
||||
|
||||
/**
|
||||
* Get the milliseconds part of given time.
|
||||
* Extract the milliseconds part of given time.
|
||||
*/
|
||||
int lumiera_time_millis(gavl_time_t time);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}//extern "C"
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@
|
|||
|
||||
#include "lib/lumitime.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@
|
|||
#include "lib/time/quantiser.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "lib/time/timequant.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
#include <boost/rational.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@
|
|||
#include "lib/time/timevalue.hpp"
|
||||
#include "lib/time/timequant.hpp"
|
||||
#include "lib/time/formats.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "lib/time.h"
|
||||
}
|
||||
|
||||
|
||||
using std::string;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
typedef unsigned int uint;
|
||||
|
||||
#include "lib/time.h"
|
||||
#include "tests/test.h"
|
||||
#include "lib/time.h"
|
||||
|
||||
#include <nobug.h>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue