[Summary] Implemented functionality for buttons in top bar

[Reviewed] GZharun
This commit is contained in:
nikolay 2014-08-26 17:10:45 +03:00
parent f56ccdb00e
commit d6687d8ff5
6 changed files with 162 additions and 8 deletions

View file

@ -215,7 +215,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, _hd_remained_time_label(0)
, editor (0)
, mixer (0)
//, meterbridge (0)
, _bit_depth_button(0)
, _sample_rate_button(0)
, _frame_rate_button(0)
, splash (0)
{
Gtkmm2ext::init(localedir);
@ -313,6 +315,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
ARDOUR::GUIIdle.connect (forever_connections, MISSING_INVALIDATOR, boost::bind(&ARDOUR_UI::gui_idle_handler, this), gui_context());
EngineStateController::instance()->SampleRateChanged.connect_same_thread (update_connections_to_toolbar_buttons, boost::bind (&ARDOUR_UI::update_sample_rate_button, this) );
EngineStateController::instance()->EngineRunning.connect_same_thread (update_connections_to_toolbar_buttons, boost::bind (&ARDOUR_UI::update_sample_rate_button, this) );
/* lets get this party started */
setup_gtk_ardour_enums ();

View file

@ -227,6 +227,17 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void focus_on_clock ();
AudioClock* big_clock;
WavesButton* _bit_depth_button;
WavesButton* _sample_rate_button;
WavesButton* _frame_rate_button;
void on_bit_depth_button (WavesButton*);
void on_sample_rate_button (WavesButton*);
void on_frame_rate_button (WavesButton*);
void update_bit_depth_button ();
void update_sample_rate_button ();
void update_frame_rate_button ();
PBD::ScopedConnectionList update_connections_to_toolbar_buttons;
TimeInfoBox* time_info_box;
VideoTimeLine *video_timeline;

View file

@ -231,6 +231,10 @@ ARDOUR_UI::set_session (Session *s)
editor_meter_peak_display.show();
}
}
update_bit_depth_button ();
update_sample_rate_button ();
update_frame_rate_button ();
}
int

View file

@ -67,6 +67,7 @@
#include "control_protocol/control_protocol.h"
#include "i18n.h"
#include "utils.h"
using namespace std;
using namespace ARDOUR;
@ -86,18 +87,105 @@ ARDOUR_UI::create_editor ()
_dsp_load_label = &editor->get_label("dsp_load_label");
_hd_load_label = &editor->get_label("hd_load_label");
_hd_remained_time_label = &editor->get_label("hd_remained_time");
_bit_depth_button = &editor->get_waves_button("bit_depth_button");
_sample_rate_button = &editor->get_waves_button("sample_rate_button");
_frame_rate_button = &editor->get_waves_button("frame_rate_button");
}
catch (failed_constructor& err) {
return -1;
}
_bit_depth_button->signal_clicked.connect(sigc::mem_fun (*this, &ARDOUR_UI::on_bit_depth_button));
_sample_rate_button->signal_clicked.connect(sigc::mem_fun (*this, &ARDOUR_UI::on_sample_rate_button));
_frame_rate_button->signal_clicked.connect(sigc::mem_fun (*this, &ARDOUR_UI::on_frame_rate_button));
editor->Realized.connect (sigc::mem_fun (*this, &ARDOUR_UI::editor_realized));
editor->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), true));
return 0;
}
void
ARDOUR_UI::on_bit_depth_button (WavesButton*)
{
tracks_control_panel->show ();
}
void
ARDOUR_UI::on_sample_rate_button (WavesButton*)
{
tracks_control_panel->show ();
}
void
ARDOUR_UI::on_frame_rate_button (WavesButton*)
{
tracks_control_panel->show ();
}
void
ARDOUR_UI::update_bit_depth_button ()
{
if( _session && _bit_depth_button )
{
string file_data_format;
switch (_session->config.get_native_file_data_format ()) {
case FormatFloat:
file_data_format = "32 bit";
break;
case FormatInt24:
file_data_format = "24 bit";
break;
case FormatInt16:
file_data_format = "16 bit";
break;
}
_bit_depth_button->set_text (file_data_format);
}
}
void
ARDOUR_UI::update_sample_rate_button ()
{
if( !_sample_rate_button )
return;
std::string active_sr = rate_as_string(EngineStateController::instance()->get_current_sample_rate());
_sample_rate_button->set_text (active_sr);
}
void
ARDOUR_UI::update_frame_rate_button ()
{
if( !_frame_rate_button )
return;
string timecode_format_string;
switch( _timecode_format ) {
case Timecode::timecode_24:
timecode_format_string = "24 fps";
break;
case Timecode::timecode_25:
timecode_format_string = "25 fps";
break;
case Timecode::timecode_30:
timecode_format_string = "30 fps";
break;
case Timecode::timecode_23976:
timecode_format_string = "23.976 fps";
break;
case Timecode::timecode_2997:
timecode_format_string = "29.97 fps";
break;
default:
break;
}
_frame_rate_button->set_text (timecode_format_string);
}
void
ARDOUR_UI::install_actions ()
{

View file

@ -418,10 +418,20 @@ ARDOUR_UI::parameter_changed (std::string p)
void
ARDOUR_UI::session_parameter_changed (const std::string& param)
{
if (param == "native-file-data-format" || param == "native-file-header-format")
if ( param == "native-file-data-format" )
{
update_format();
if ( param == "timecode-format")
update_bit_depth_button ();
}
else if (param == "native-file-header-format")
{
update_format();
}
else if ( param == "timecode-format" )
{
update_timecode_format();
update_frame_rate_button ();
}
}
void

View file

@ -32,15 +32,51 @@
normalicon="tracks"
activeicon="tracks_active"
prelighticon="tracks_prelight"/>
<Layout width="407" height="51">
<icon source="top_bar_background.png"
tooltip="--------------------&#xA;This is a mockup&#xA;--------------------" />
<icon source="top_bar_background.png"/>
<HBox id="time_info_box_home"
x="60"
y="4"/>
<HBox id="primary_clock_home"
x="132"
y="6"/>
<Button id="bit_depth_button"
text="bit depth"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="270"
y="5"
width="63"
height="18"
normalicon="top_bar_button"
activeicon="top_bar_button"
prelighticon="top_bar_button"/>
<Button id="sample_rate_button"
text="sample rate"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="270"
y="28"
width="63"
height="18"
normalicon="top_bar_button"
activeicon="top_bar_button"
prelighticon="top_bar_button"/>
<Button id="frame_rate_button"
text="frame rate"
winfont ="Arial 8"
macfont ="Helvetica 8"
x="335"
y="28"
width="63"
height="18"
normalicon="top_bar_button"
activeicon="top_bar_button"
prelighticon="top_bar_button"/>
</Layout>
<Layout box.pack="end" width="114" height="51">
<icon source="metrics_display.png"/>
@ -98,8 +134,8 @@
<Label id="hd_remained_time"
style="generic_control"
fgnormal="#ffffff"
winfont ="Arial 8"
macfont ="Helvetica 8"
winfont ="Arial 9"
macfont ="Helvetica 9"
x="58"
y="33"/>
</Layout>