Lumiera  0.pre.03
»edityourfreedom«
TimeCode Class Reference

#include "gui/widget/timecode-widget.hpp"

Description

Widget for timecode input and display.

Adapted implementation from the Ardour DAW

Definition at line 64 of file timecode-widget.hpp.

Public Types

enum  Mode {
  SMPTE,
  MinSec,
  Frames,
  Off
}
 

Public Member Functions

 TimeCode (string clock_name, string widget_name, bool editable)
 
Time current_duration (Time position=Time::ZERO) const
 
Time current_time (Time position=Time::ZERO) const
 
void focus ()
 
Mode mode () const
 
string name () const
 
void set (Time when, bool force=false)
 
void set_mode (Mode)
 
void set_widget_name (string)
 

Static Public Member Functions

static bool has_focus ()
 

Static Public Attributes

static sigc::signal< void > ModeChanged
 

Public Attributes

sigc::signal< void > ChangeAborted
 
sigc::signal< void > ValueChanged
 

Private Types

enum  Field {
  SMPTE_Hours,
  SMPTE_Minutes,
  SMPTE_Seconds,
  SMPTE_Frames,
  MS_Hours,
  MS_Minutes,
  MS_Seconds,
  VFrames
}
 

Private Member Functions

Time audio_time_from_display () const
 
void build_ops_menu ()
 
bool drop_focus_handler (GdkEventFocus *ev)
 
bool field_button_press_event (GdkEventButton *ev, Field)
 
bool field_button_release_event (GdkEventButton *ev, Field)
 
bool field_button_scroll_event (GdkEventScroll *ev, Field)
 
bool field_focus_gain_event (GdkEventFocus *, Field)
 
bool field_focus_loss_event (GdkEventFocus *, Field)
 
bool field_key_press_event (GdkEventKey *ev, Field)
 
bool field_key_release_event (GdkEventKey *ev, Field)
 
bool field_motion_notify_event (GdkEventMotion *ev, Field)
 
int get_frames (Field, Time pos=Time::ZERO, int dir=1)
 
void get_ink_pixel_size (Glib::RefPtr< Pango::Layout > layout, int &width, int &height)
 
Time minsec_time_from_display () const
 
void on_realize ()
 
void set_frames (Time, bool)
 
void set_minsec (Time, bool)
 
void set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *text, gint hpadding, gint vpadding)
 
void set_size_requests ()
 
void set_smpte (Time, bool)
 
void setup_events ()
 
void smpte_offset_changed ()
 
void smpte_sanitize_display ()
 
Time smpte_time_from_display () const
 

Private Attributes

Mode _mode
 
string _name
 
Gtk::EventBox audio_frames_ebox
 
Gtk::Label audio_frames_label
 
Gtk::EventBox clock_base
 
Gtk::Frame clock_frame
 
Gtk::Label colon1
 
Gtk::Label colon2
 
Gtk::Label colon3
 
Gtk::Label colon4
 
Gtk::Label colon5
 
double drag_accum
 
double drag_start_y
 
double drag_y
 
bool dragging
 
bool editable
 
Gtk::EventBox frames_ebox
 
Gtk::Label frames_label
 
Gtk::HBox frames_packer
 
Gtk::HBox frames_packer_hbox
 
Gtk::EventBox hours_ebox
 
Gtk::Label hours_label
 
uint key_entry_state
 
int last_frames
 
int last_hrs
 
int last_mins
 
bool last_negative
 
bool last_pdelta
 
bool last_sdelta
 
int last_secs
 
TimeVar last_when
 
Gtk::HBox minsec_packer
 
Gtk::HBox minsec_packer_hbox
 
Gtk::EventBox minutes_ebox
 
Gtk::Label minutes_label
 
Gtk::EventBox ms_hours_ebox
 
Gtk::Label ms_hours_label
 
int ms_last_hrs
 
int ms_last_mins
 
float ms_last_secs
 
Gtk::EventBox ms_minutes_ebox
 
Gtk::Label ms_minutes_label
 
Gtk::EventBox ms_seconds_ebox
 
Gtk::Label ms_seconds_label
 
Gtk::HBox off_hbox
 
Gtk::Menu * ops_menu
 
Gtk::EventBox seconds_ebox
 
Gtk::Label seconds_label
 
Gtk::HBox smpte_packer
 
Gtk::HBox smpte_packer_hbox
 

Static Private Attributes

static bool _has_focus
 
static const uint field_length [(int) VFrames+1]
 

Member Enumeration Documentation

◆ Mode

enum Mode
Enumerator
SMPTE 
MinSec 
Frames 
Off 

Definition at line 68 of file timecode-widget.hpp.

◆ Field

enum Field
private
Enumerator
SMPTE_Hours 
SMPTE_Minutes 
SMPTE_Seconds 
SMPTE_Frames 
MS_Hours 
MS_Minutes 
MS_Seconds 
VFrames 

Definition at line 124 of file timecode-widget.hpp.

Constructor & Destructor Documentation

◆ TimeCode()

Member Function Documentation

◆ mode()

Mode mode ( ) const
inline

Definition at line 83 of file timecode-widget.hpp.

References TimeCode::_mode, TimeCode::focus(), TimeCode::set_mode(), and TimeCode::set_widget_name().

+ Here is the call graph for this function:

◆ focus()

void focus ( )

Definition at line 553 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::Frames, TimeCode::frames_ebox, TimeCode::hours_ebox, TimeCode::MinSec, TimeCode::ms_hours_ebox, TimeCode::Off, and TimeCode::SMPTE.

Referenced by TimeCode::mode().

+ Here is the caller graph for this function:

◆ set()

void set ( Time  when,
bool  force = false 
)

Definition at line 408 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::Frames, TimeCode::last_when, TimeCode::MinSec, TimeCode::Off, TimeCode::set_frames(), TimeCode::set_minsec(), TimeCode::set_smpte(), and TimeCode::SMPTE.

+ Here is the call graph for this function:

◆ set_mode()

void set_mode ( Mode  m)

Definition at line 1305 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::clock_base, TimeCode::Frames, TimeCode::frames_packer_hbox, TimeCode::key_entry_state, TimeCode::last_when, TimeCode::MinSec, TimeCode::minsec_packer_hbox, TimeCode::ModeChanged, TimeCode::Off, TimeCode::off_hbox, TimeCode::set_size_requests(), TimeCode::SMPTE, and TimeCode::smpte_packer_hbox.

Referenced by TimeCode::build_ops_menu(), TimeCode::mode(), and TimeCode::TimeCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_widget_name()

◆ name()

string name ( ) const
inline

Definition at line 92 of file timecode-widget.hpp.

References TimeCode::_name, TimeCode::current_duration(), TimeCode::current_time(), and Time::ZERO.

+ Here is the call graph for this function:

◆ current_time()

Time current_time ( Time  position = Time::ZERO) const

Definition at line 1152 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::audio_time_from_display(), TimeCode::Frames, TimeCode::MinSec, TimeCode::minsec_time_from_display(), TimeCode::Off, TimeCode::SMPTE, and TimeCode::smpte_time_from_display().

Referenced by TimeCode::field_motion_notify_event(), and TimeCode::name().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current_duration()

Time current_duration ( Time  position = Time::ZERO) const

Definition at line 1180 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::audio_time_from_display(), TimeCode::Frames, TimeCode::MinSec, TimeCode::minsec_time_from_display(), TimeCode::Off, TimeCode::SMPTE, and TimeCode::smpte_time_from_display().

Referenced by TimeCode::name().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_focus()

static bool has_focus ( )
inlinestatic

Definition at line 103 of file timecode-widget.hpp.

References TimeCode::_has_focus.

◆ on_realize()

void on_realize ( )
private

Definition at line 397 of file timecode-widget.cpp.

References TimeCode::set_size_requests().

+ Here is the call graph for this function:

◆ field_motion_notify_event()

bool field_motion_notify_event ( GdkEventMotion *  ev,
Field  field 
)
private

Definition at line 1060 of file timecode-widget.cpp.

References TimeCode::current_time(), TimeCode::drag_accum, TimeCode::drag_y, TimeCode::dragging, TimeCode::get_frames(), TimeCode::ValueChanged, and Time::ZERO.

Referenced by TimeCode::setup_events().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ field_button_press_event()

bool field_button_press_event ( GdkEventButton *  ev,
Field  field 
)
private

Definition at line 966 of file timecode-widget.cpp.

References TimeCode::drag_accum, TimeCode::drag_start_y, TimeCode::drag_y, TimeCode::dragging, and NULL.

Referenced by TimeCode::setup_events().

+ Here is the caller graph for this function:

◆ field_button_release_event()

bool field_button_release_event ( GdkEventButton *  ev,
Field  field 
)
private

Definition at line 893 of file timecode-widget.cpp.

References TimeCode::audio_frames_ebox, TimeCode::build_ops_menu(), TimeCode::drag_start_y, TimeCode::dragging, TimeCode::editable, TimeCode::frames_ebox, TimeCode::hours_ebox, TimeCode::minutes_ebox, TimeCode::MS_Hours, TimeCode::ms_hours_ebox, TimeCode::MS_Minutes, TimeCode::ms_minutes_ebox, TimeCode::MS_Seconds, TimeCode::ms_seconds_ebox, TimeCode::ops_menu, TimeCode::seconds_ebox, TimeCode::SMPTE_Frames, TimeCode::SMPTE_Hours, TimeCode::SMPTE_Minutes, TimeCode::SMPTE_Seconds, and TimeCode::VFrames.

Referenced by TimeCode::setup_events(), and TimeCode::TimeCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ field_button_scroll_event()

bool field_button_scroll_event ( GdkEventScroll *  ev,
Field  field 
)
private

Definition at line 1010 of file timecode-widget.cpp.

Referenced by TimeCode::setup_events().

+ Here is the caller graph for this function:

◆ field_key_press_event()

bool field_key_press_event ( GdkEventKey *  ev,
Field  field 
)
private

Definition at line 576 of file timecode-widget.cpp.

Referenced by TimeCode::setup_events().

+ Here is the caller graph for this function:

◆ field_key_release_event()

bool field_key_release_event ( GdkEventKey *  ev,
Field  field 
)
private

◆ field_focus_gain_event()

bool field_focus_gain_event ( GdkEventFocus *  ,
Field  field 
)
private

audio_frames_ebox.set_flags(Gtk::HAS_FOCUS);

Definition at line 798 of file timecode-widget.cpp.

References TimeCode::audio_frames_ebox, TimeCode::frames_ebox, TimeCode::hours_ebox, TimeCode::key_entry_state, TimeCode::minutes_ebox, TimeCode::MS_Hours, TimeCode::ms_hours_ebox, TimeCode::MS_Minutes, TimeCode::ms_minutes_ebox, TimeCode::MS_Seconds, TimeCode::ms_seconds_ebox, TimeCode::seconds_ebox, TimeCode::SMPTE_Frames, TimeCode::SMPTE_Hours, TimeCode::SMPTE_Minutes, TimeCode::SMPTE_Seconds, and TimeCode::VFrames.

Referenced by TimeCode::setup_events().

+ Here is the caller graph for this function:

◆ field_focus_loss_event()

bool field_focus_loss_event ( GdkEventFocus *  ,
Field  field 
)
private

◆ drop_focus_handler()

bool drop_focus_handler ( GdkEventFocus *  ev)
private

Definition at line 389 of file timecode-widget.cpp.

Referenced by TimeCode::setup_events().

+ Here is the caller graph for this function:

◆ set_smpte()

void set_smpte ( Time  when,
bool  force 
)
private

Definition at line 498 of file timecode-widget.cpp.

References TimeCode::frames_label, lib::time::getHours(), lib::time::getMins(), lib::time::getSecs(), TimeCode::hours_label, TimeCode::last_frames, TimeCode::last_hrs, TimeCode::last_mins, TimeCode::last_negative, TimeCode::last_secs, TimeCode::minutes_label, and TimeCode::seconds_label.

Referenced by TimeCode::set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_minsec()

void set_minsec ( Time  when,
bool  force 
)
private

Definition at line 466 of file timecode-widget.cpp.

References lib::time::getHours(), lib::time::getMins(), lib::time::getSecs(), TimeCode::ms_hours_label, TimeCode::ms_last_hrs, TimeCode::ms_last_mins, TimeCode::ms_last_secs, TimeCode::ms_minutes_label, and TimeCode::ms_seconds_label.

Referenced by TimeCode::set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_frames()

void set_frames ( Time  when,
bool  force 
)
private

Definition at line 455 of file timecode-widget.cpp.

References TimeCode::audio_frames_label.

Referenced by TimeCode::set().

+ Here is the caller graph for this function:

◆ get_frames()

int get_frames ( Field  field,
Time  pos = Time::ZERO,
int  dir = 1 
)
private

Definition at line 1113 of file timecode-widget.cpp.

Referenced by TimeCode::field_motion_notify_event().

+ Here is the caller graph for this function:

◆ smpte_sanitize_display()

void smpte_sanitize_display ( )
private

Definition at line 1208 of file timecode-widget.cpp.

References TimeCode::frames_label, TimeCode::minutes_label, and TimeCode::seconds_label.

Referenced by TimeCode::field_key_release_event().

+ Here is the caller graph for this function:

◆ smpte_time_from_display()

Time smpte_time_from_display ( ) const
private

Definition at line 1242 of file timecode-widget.cpp.

References Time::ZERO.

Referenced by TimeCode::current_duration(), and TimeCode::current_time().

+ Here is the caller graph for this function:

◆ minsec_time_from_display()

Time minsec_time_from_display ( ) const
private

Definition at line 1263 of file timecode-widget.cpp.

References Time::ZERO.

Referenced by TimeCode::current_duration(), and TimeCode::current_time().

+ Here is the caller graph for this function:

◆ audio_time_from_display()

Time audio_time_from_display ( ) const
private

Definition at line 1280 of file timecode-widget.cpp.

References TimeCode::audio_frames_label.

Referenced by TimeCode::current_duration(), and TimeCode::current_time().

+ Here is the caller graph for this function:

◆ build_ops_menu()

void build_ops_menu ( )
private

Definition at line 1288 of file timecode-widget.cpp.

References TimeCode::Frames, TimeCode::MinSec, TimeCode::Off, TimeCode::ops_menu, TimeCode::set_mode(), and TimeCode::SMPTE.

Referenced by TimeCode::field_button_release_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setup_events()

◆ smpte_offset_changed()

void smpte_offset_changed ( )
private

◆ set_size_requests()

void set_size_requests ( )
private

Definition at line 1353 of file timecode-widget.cpp.

References TimeCode::_mode, TimeCode::audio_frames_label, TimeCode::Frames, TimeCode::frames_label, TimeCode::hours_label, TimeCode::MinSec, TimeCode::minutes_label, TimeCode::ms_hours_label, TimeCode::ms_minutes_label, TimeCode::ms_seconds_label, TimeCode::Off, TimeCode::off_hbox, TimeCode::seconds_label, TimeCode::set_size_request_to_display_given_text(), and TimeCode::SMPTE.

Referenced by TimeCode::on_realize(), and TimeCode::set_mode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_size_request_to_display_given_text()

void set_size_request_to_display_given_text ( Gtk::Widget &  w,
const gchar *  text,
gint  hpadding,
gint  vpadding 
)
private

Definition at line 1384 of file timecode-widget.cpp.

References TimeCode::get_ink_pixel_size().

Referenced by TimeCode::set_size_requests().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_ink_pixel_size()

void get_ink_pixel_size ( Glib::RefPtr< Pango::Layout >  layout,
int &  width,
int &  height 
)
private

Definition at line 1396 of file timecode-widget.cpp.

Referenced by TimeCode::set_size_request_to_display_given_text().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ValueChanged

sigc::signal<void> ValueChanged

◆ ChangeAborted

sigc::signal<void> ChangeAborted

Definition at line 98 of file timecode-widget.hpp.

Referenced by TimeCode::field_key_release_event().

◆ ModeChanged

sigc::signal< void > ModeChanged
static

Definition at line 100 of file timecode-widget.hpp.

Referenced by TimeCode::set_mode().

◆ key_entry_state

◆ _mode

◆ _name

string _name
private

Definition at line 109 of file timecode-widget.hpp.

Referenced by TimeCode::name().

◆ editable

bool editable
private

◆ ops_menu

Gtk::Menu* ops_menu
private

◆ smpte_packer_hbox

Gtk::HBox smpte_packer_hbox
private

Definition at line 115 of file timecode-widget.hpp.

Referenced by TimeCode::set_mode(), and TimeCode::TimeCode().

◆ smpte_packer

Gtk::HBox smpte_packer
private

Definition at line 116 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ minsec_packer_hbox

Gtk::HBox minsec_packer_hbox
private

Definition at line 118 of file timecode-widget.hpp.

Referenced by TimeCode::set_mode(), and TimeCode::TimeCode().

◆ minsec_packer

Gtk::HBox minsec_packer
private

Definition at line 119 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ frames_packer_hbox

Gtk::HBox frames_packer_hbox
private

Definition at line 121 of file timecode-widget.hpp.

Referenced by TimeCode::set_mode(), and TimeCode::TimeCode().

◆ frames_packer

Gtk::HBox frames_packer
private

Definition at line 122 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ audio_frames_ebox

◆ audio_frames_label

◆ off_hbox

Gtk::HBox off_hbox
private

Definition at line 138 of file timecode-widget.hpp.

Referenced by TimeCode::set_mode(), and TimeCode::set_size_requests().

◆ hours_ebox

◆ minutes_ebox

◆ seconds_ebox

◆ frames_ebox

◆ ms_hours_ebox

◆ ms_minutes_ebox

◆ ms_seconds_ebox

◆ hours_label

◆ minutes_label

◆ seconds_label

◆ frames_label

◆ colon1

Gtk::Label colon1
private

Definition at line 153 of file timecode-widget.hpp.

Referenced by TimeCode::set_widget_name(), and TimeCode::TimeCode().

◆ colon2

Gtk::Label colon2
private

Definition at line 153 of file timecode-widget.hpp.

Referenced by TimeCode::set_widget_name(), and TimeCode::TimeCode().

◆ colon3

Gtk::Label colon3
private

Definition at line 153 of file timecode-widget.hpp.

Referenced by TimeCode::set_widget_name(), and TimeCode::TimeCode().

◆ ms_hours_label

◆ ms_minutes_label

◆ ms_seconds_label

◆ colon4

Gtk::Label colon4
private

Definition at line 158 of file timecode-widget.hpp.

Referenced by TimeCode::set_widget_name(), and TimeCode::TimeCode().

◆ colon5

Gtk::Label colon5
private

Definition at line 158 of file timecode-widget.hpp.

Referenced by TimeCode::set_widget_name(), and TimeCode::TimeCode().

◆ clock_base

◆ clock_frame

Gtk::Frame clock_frame
private

Definition at line 161 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ last_when

TimeVar last_when
private

Definition at line 163 of file timecode-widget.hpp.

Referenced by TimeCode::set(), TimeCode::set_mode(), and TimeCode::TimeCode().

◆ last_pdelta

bool last_pdelta
private

Definition at line 164 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ last_sdelta

bool last_sdelta
private

Definition at line 165 of file timecode-widget.hpp.

Referenced by TimeCode::TimeCode().

◆ last_hrs

int last_hrs
private

Definition at line 167 of file timecode-widget.hpp.

Referenced by TimeCode::set_smpte().

◆ last_mins

int last_mins
private

Definition at line 168 of file timecode-widget.hpp.

Referenced by TimeCode::set_smpte().

◆ last_secs

int last_secs
private

Definition at line 169 of file timecode-widget.hpp.

Referenced by TimeCode::set_smpte().

◆ last_frames

int last_frames
private

Definition at line 170 of file timecode-widget.hpp.

Referenced by TimeCode::set_smpte().

◆ last_negative

bool last_negative
private

Definition at line 171 of file timecode-widget.hpp.

Referenced by TimeCode::set_smpte().

◆ ms_last_hrs

int ms_last_hrs
private

Definition at line 173 of file timecode-widget.hpp.

Referenced by TimeCode::set_minsec().

◆ ms_last_mins

int ms_last_mins
private

Definition at line 174 of file timecode-widget.hpp.

Referenced by TimeCode::set_minsec().

◆ ms_last_secs

float ms_last_secs
private

Definition at line 175 of file timecode-widget.hpp.

Referenced by TimeCode::set_minsec().

◆ dragging

◆ drag_start_y

double drag_start_y
private

◆ drag_y

double drag_y
private

◆ drag_accum

double drag_accum
private

◆ field_length

const unsigned int field_length
staticprivate

Definition at line 211 of file timecode-widget.hpp.

Referenced by TimeCode::field_key_release_event().

◆ _has_focus

bool _has_focus
staticprivate

Definition at line 212 of file timecode-widget.hpp.

Referenced by TimeCode::has_focus().

+ Inheritance diagram for TimeCode:
+ Collaboration diagram for TimeCode:

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