2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 1999 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __audio_clock_h__
|
|
|
|
#define __audio_clock_h__
|
|
|
|
|
2011-05-21 21:18:22 -04:00
|
|
|
#include <map>
|
2011-11-17 17:49:13 -05:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <pangomm.h>
|
2011-06-02 13:47:58 -04:00
|
|
|
|
|
|
|
#include <gtkmm/alignment.h>
|
2005-09-26 14:24:59 -04:00
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/label.h>
|
2011-06-02 13:47:58 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/ardour.h"
|
2009-12-17 13:24:23 -05:00
|
|
|
#include "ardour/session_handle.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-12-07 08:57:45 -05:00
|
|
|
#include "gtkmm2ext/cairo_widget.h"
|
2011-06-02 13:47:58 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
namespace ARDOUR {
|
|
|
|
class Session;
|
2006-07-19 12:47:04 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Mode {
|
2009-10-26 10:38:58 -04:00
|
|
|
Timecode,
|
2005-09-25 14:42:24 -04:00
|
|
|
BBT,
|
|
|
|
MinSec,
|
2011-06-07 19:07:08 -04:00
|
|
|
Frames
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
AudioClock (const std::string& clock_name, bool is_transient, const std::string& widget_name,
|
2010-03-04 21:09:37 -05:00
|
|
|
bool editable, bool follows_playhead, bool duration = false, bool with_info = false);
|
2011-06-02 13:47:58 -04:00
|
|
|
~AudioClock ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Mode mode() const { return _mode; }
|
2011-06-07 19:07:08 -04:00
|
|
|
void set_off (bool yn);
|
|
|
|
bool off() const { return _off; }
|
2011-11-17 17:49:13 -05:00
|
|
|
void set_widget_name (const std::string& name);
|
|
|
|
void set_active_state (Gtkmm2ext::ActiveState s);
|
2011-11-18 12:06:11 -05:00
|
|
|
void set_editable (bool yn);
|
2011-11-19 09:27:05 -05:00
|
|
|
void set_corner_radius (double);
|
2011-11-20 10:10:53 -05:00
|
|
|
void set_fixed_width (bool);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
void focus ();
|
|
|
|
|
2011-11-18 13:06:16 -05:00
|
|
|
void set (framepos_t, bool force = false, ARDOUR::framecnt_t offset = 0);
|
2009-11-12 15:39:53 -05:00
|
|
|
void set_from_playhead ();
|
|
|
|
void locate ();
|
2005-09-25 14:42:24 -04:00
|
|
|
void set_mode (Mode);
|
2010-09-17 14:20:37 -04:00
|
|
|
void set_bbt_reference (framepos_t);
|
2010-10-18 18:02:12 -04:00
|
|
|
void set_is_duration (bool);
|
2007-01-08 12:12:29 -05:00
|
|
|
|
|
|
|
std::string name() const { return _name; }
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
framepos_t current_time (framepos_t position = 0) const;
|
|
|
|
framepos_t current_duration (framepos_t position = 0) const;
|
2005-09-25 14:42:24 -04:00
|
|
|
void set_session (ARDOUR::Session *s);
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
sigc::signal<void> ValueChanged;
|
2008-09-19 10:38:46 -04:00
|
|
|
sigc::signal<void> mode_changed;
|
2008-09-10 11:03:30 -04:00
|
|
|
sigc::signal<void> ChangeAborted;
|
2007-01-08 12:12:29 -05:00
|
|
|
|
|
|
|
static sigc::signal<void> ModeChanged;
|
|
|
|
static std::vector<AudioClock*> clocks;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
protected:
|
|
|
|
void render (cairo_t*);
|
2011-06-03 18:18:47 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
private:
|
|
|
|
Mode _mode;
|
2007-01-08 12:12:29 -05:00
|
|
|
std::string _name;
|
|
|
|
bool is_transient;
|
2005-09-25 14:42:24 -04:00
|
|
|
bool is_duration;
|
|
|
|
bool editable;
|
2009-11-25 21:15:44 -05:00
|
|
|
/** true if this clock follows the playhead, meaning that certain operations are redundant */
|
|
|
|
bool _follows_playhead;
|
2011-06-07 19:07:08 -04:00
|
|
|
bool _off;
|
2011-11-20 10:10:53 -05:00
|
|
|
bool _fixed_width;
|
2011-11-20 11:38:51 -05:00
|
|
|
int layout_x_offset;
|
2011-11-21 12:39:55 -05:00
|
|
|
int em_width;
|
2011-11-21 14:24:37 -05:00
|
|
|
bool _edit_by_click_field;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Gtk::Menu *ops_menu;
|
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
Glib::RefPtr<Pango::Layout> _layout;
|
|
|
|
Glib::RefPtr<Pango::Layout> _left_layout;
|
|
|
|
Glib::RefPtr<Pango::Layout> _right_layout;
|
|
|
|
|
|
|
|
Pango::AttrColor* editing_attr;
|
|
|
|
Pango::AttrColor* foreground_attr;
|
|
|
|
|
|
|
|
Pango::AttrList normal_attributes;
|
|
|
|
Pango::AttrList editing_attributes;
|
|
|
|
Pango::AttrList info_attributes;
|
|
|
|
|
2011-11-19 09:27:05 -05:00
|
|
|
int first_height;
|
|
|
|
int first_width;
|
2011-11-17 17:49:13 -05:00
|
|
|
int layout_height;
|
|
|
|
int layout_width;
|
|
|
|
int info_height;
|
|
|
|
int upper_height;
|
|
|
|
double mode_based_info_ratio;
|
2011-11-19 09:27:05 -05:00
|
|
|
double corner_radius;
|
2011-11-18 12:06:11 -05:00
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
static const double info_font_scale_factor;
|
|
|
|
static const double separator_height;
|
2011-11-18 10:35:58 -05:00
|
|
|
static const double x_leading_padding;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
enum Field {
|
2011-11-21 14:24:37 -05:00
|
|
|
Timecode_Hours = 1,
|
2009-10-26 10:38:58 -04:00
|
|
|
Timecode_Minutes,
|
|
|
|
Timecode_Seconds,
|
|
|
|
Timecode_Frames,
|
2005-09-25 14:42:24 -04:00
|
|
|
MS_Hours,
|
|
|
|
MS_Minutes,
|
|
|
|
MS_Seconds,
|
2011-05-21 21:18:05 -04:00
|
|
|
MS_Milliseconds,
|
2005-09-25 14:42:24 -04:00
|
|
|
Bars,
|
2009-10-14 12:10:01 -04:00
|
|
|
Beats,
|
2005-09-25 14:42:24 -04:00
|
|
|
Ticks,
|
2011-06-02 13:47:58 -04:00
|
|
|
AudioFrames,
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
Field index_to_field (int index) const;
|
2011-06-03 18:18:47 -04:00
|
|
|
|
2011-11-18 17:17:59 -05:00
|
|
|
/* this maps the number of input characters/digits when editing
|
|
|
|
to a cursor position. insert_map[N] = index of character/digit
|
|
|
|
where the cursor should be after N chars/digits. it is
|
|
|
|
mode specific and so it is filled during set_mode().
|
|
|
|
*/
|
|
|
|
|
|
|
|
std::vector<int> insert_map;
|
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
bool editing;
|
|
|
|
std::string edit_string;
|
|
|
|
std::string pre_edit_string;
|
|
|
|
std::string input_string;
|
2011-11-18 10:35:58 -05:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t bbt_reference_time;
|
2010-12-03 17:26:29 -05:00
|
|
|
framepos_t last_when;
|
2007-05-13 22:48:28 -04:00
|
|
|
bool last_pdelta;
|
|
|
|
bool last_sdelta;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
bool dragging;
|
|
|
|
double drag_start_y;
|
|
|
|
double drag_y;
|
|
|
|
double drag_accum;
|
2011-11-17 17:49:13 -05:00
|
|
|
Field drag_field;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 22:48:59 -04:00
|
|
|
void on_realize ();
|
2011-11-17 17:49:13 -05:00
|
|
|
bool on_key_press_event (GdkEventKey *);
|
|
|
|
bool on_key_release_event (GdkEventKey *);
|
|
|
|
bool on_scroll_event (GdkEventScroll *ev);
|
|
|
|
bool on_button_press_event (GdkEventButton *ev);
|
|
|
|
bool on_button_release_event(GdkEventButton *ev);
|
|
|
|
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
|
|
|
|
void on_size_request (Gtk::Requisition* req);
|
|
|
|
bool on_motion_notify_event (GdkEventMotion *ev);
|
|
|
|
void on_size_allocate (Gtk::Allocation&);
|
2011-11-17 20:22:40 -05:00
|
|
|
bool on_focus_out_event (GdkEventFocus*);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-12-03 17:26:29 -05:00
|
|
|
void set_timecode (framepos_t, bool);
|
|
|
|
void set_bbt (framepos_t, bool);
|
|
|
|
void set_minsec (framepos_t, bool);
|
|
|
|
void set_frames (framepos_t, bool);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
framepos_t get_frame_step (Field, framepos_t pos = 0, int dir = 1);
|
|
|
|
|
|
|
|
bool timecode_validate_edit (const std::string&);
|
|
|
|
bool bbt_validate_edit (const std::string&);
|
2011-11-21 12:51:15 -05:00
|
|
|
bool minsec_validate_edit (const std::string&);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-11-18 00:04:18 -05:00
|
|
|
framepos_t frames_from_timecode_string (const std::string&) const;
|
|
|
|
framepos_t frames_from_bbt_string (framepos_t, const std::string&) const;
|
|
|
|
framepos_t frame_duration_from_bbt_string (framepos_t, const std::string&) const;
|
|
|
|
framepos_t frames_from_minsec_string (const std::string&) const;
|
|
|
|
framepos_t frames_from_audioframes_string (const std::string&) const;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
void build_ops_menu ();
|
|
|
|
|
2010-12-01 15:49:22 -05:00
|
|
|
void session_configuration_changed (std::string);
|
2006-06-14 17:17:32 -04:00
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
Field index_to_field () const;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-11-21 14:24:37 -05:00
|
|
|
void start_edit (Field f = Field (0));
|
2011-11-17 17:49:13 -05:00
|
|
|
void end_edit (bool);
|
2011-11-17 20:22:40 -05:00
|
|
|
void end_edit_relative (bool);
|
2011-06-02 13:47:58 -04:00
|
|
|
void edit_next_field ();
|
2011-11-17 20:22:40 -05:00
|
|
|
ARDOUR::framecnt_t parse_as_distance (const std::string&);
|
2011-06-02 13:47:58 -04:00
|
|
|
|
2011-11-17 20:22:40 -05:00
|
|
|
ARDOUR::framecnt_t parse_as_timecode_distance (const std::string&);
|
|
|
|
ARDOUR::framecnt_t parse_as_minsec_distance (const std::string&);
|
|
|
|
ARDOUR::framecnt_t parse_as_bbt_distance (const std::string&);
|
|
|
|
ARDOUR::framecnt_t parse_as_frames_distance (const std::string&);
|
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
void set_font ();
|
|
|
|
void set_colors ();
|
|
|
|
void show_edit_status (int length);
|
2011-11-21 14:24:37 -05:00
|
|
|
int merge_input_and_edit_string ();
|
|
|
|
std::string get_field (Field);
|
2011-11-17 17:49:13 -05:00
|
|
|
|
2011-11-18 00:04:18 -05:00
|
|
|
void drop_focus ();
|
2011-11-20 10:10:53 -05:00
|
|
|
void dpi_reset ();
|
|
|
|
|
2011-11-17 17:49:13 -05:00
|
|
|
double bg_r, bg_g, bg_b, bg_a;
|
2011-11-20 10:26:43 -05:00
|
|
|
double cursor_r, cursor_g, cursor_b, cursor_a;
|
2005-09-25 14:42:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __audio_clock_h__ */
|