}
-
-
-
-
TimeBarPopupItem::TimeBarPopupItem(MWindow *mwindow,
TimeBarPopup *menu,
const char *text,
TimeBarPopup::TimeBarPopup(MWindow *mwindow)
- : BC_PopupMenu(0,
- 0,
- 0,
- "",
- 0)
+ : BC_PopupMenu(0, 0, 0, "", 0)
{
this->mwindow = mwindow;
}
void TimeBarPopup::create_objects()
{
add_item(items[0] = new TimeBarPopupItem(mwindow,
- this,
- TIME_HMS_TEXT,
- TIME_HMS));
+ this, TIME_HMS_TEXT, TIME_HMS));
add_item(items[1] = new TimeBarPopupItem(mwindow,
- this,
- TIME_HMSF_TEXT,
- TIME_HMSF));
+ this, TIME_HMSF_TEXT, TIME_HMSF));
add_item(items[2] = new TimeBarPopupItem(mwindow,
- this,
- TIME_FRAMES_TEXT,
- TIME_FRAMES));
+ this, TIME_FRAMES_TEXT, TIME_FRAMES));
add_item(items[3] = new TimeBarPopupItem(mwindow,
- this,
- TIME_SAMPLES_TEXT,
- TIME_SAMPLES));
+ this, TIME_SAMPLES_TEXT, TIME_SAMPLES));
add_item(items[4] = new TimeBarPopupItem(mwindow,
- this,
- TIME_SAMPLES_HEX_TEXT,
- TIME_SAMPLES_HEX));
+ this, TIME_SAMPLES_HEX_TEXT, TIME_SAMPLES_HEX));
add_item(items[5] = new TimeBarPopupItem(mwindow,
- this,
- TIME_SECONDS_TEXT,
- TIME_SECONDS));
+ this, TIME_SECONDS_TEXT, TIME_SECONDS));
add_item(items[6] = new TimeBarPopupItem(mwindow,
- this,
- TIME_FEET_FRAMES_TEXT,
- TIME_FEET_FRAMES));
+ this, TIME_FEET_FRAMES_TEXT, TIME_FEET_FRAMES));
}
void TimeBarPopup::update()
{
- for(int i = 0; i < TOTAL_TIMEFORMATS; i++)
- {
- if(items[i]->value == mwindow->edl->session->time_format)
- {
- items[i]->set_checked(1);
- }
- else
- {
- items[i]->set_checked(0);
- }
+ int time_format = mwindow->edl->session->time_format;
+ for( int i=0; i<TOTAL_TIMEFORMATS; ++i ) {
+ items[i]->set_checked(items[i]->value == time_format);
}
}
close_window();
}
-void TransitionLengthThread::start(Transition *transition,
- double length)
+void TransitionLengthThread::start(Transition *transition, double length)
{
this->transition = transition;
- this->length = this->orig_length = length;
+ this->orig_length = length;
+ this->new_length = length;
BC_DialogThread::start();
}
BC_DisplayInfo display_info;
int x = display_info.get_abs_cursor_x() - 150;
int y = display_info.get_abs_cursor_y() - 50;
- TransitionLengthDialog *gui = new TransitionLengthDialog(mwindow,
- this,
- x,
- y);
+ TransitionLengthDialog *gui = new TransitionLengthDialog(mwindow, this, x, y);
gui->create_objects();
return gui;
}
void TransitionLengthThread::handle_close_event(int result)
{
- if(!result)
- {
- if(transition)
- {
- mwindow->set_transition_length(transition, length);
- }
+ if( !result ) {
+ if( transition )
+ mwindow->set_transition_length(transition, new_length);
else
- {
- mwindow->set_transition_length(length);
+ mwindow->set_transition_length(new_length);
+ }
+ else
+ update(orig_length);
+}
+
+int TransitionLengthThread::update(double length)
+{
+ if( !EQUIV(this->new_length, length) ) {
+ this->new_length = length;
+ if( transition ) {
+ transition->length = transition->track->to_units(length, 1);
+ mwindow->sync_parameters(CHANGE_EDL);
+ mwindow->gui->lock_window();
+ mwindow->gui->draw_overlays(1);
+ mwindow->gui->unlock_window();
}
}
+ return 1;
}
+TransitionUnitsItem::TransitionUnitsItem(TransitionUnitsPopup *popup,
+ const char *text, int id)
+ : BC_MenuItem(text)
+{
+ this->popup = popup;
+ this->id = id;
+}
+TransitionUnitsItem::~TransitionUnitsItem()
+{
+}
+int TransitionUnitsItem::handle_event()
+{
+ TransitionUnitsPopup *units_popup = (TransitionUnitsPopup *)get_popup_menu();
+ TransitionLengthDialog *gui = units_popup->gui;
+ TransitionLengthText *length_text = gui->text;
+ EDLSession *session = gui->mwindow->edl->session;
+ double length = gui->thread->new_length;
+ char text[BCSTRLEN];
+ units_popup->units = id;
+ Units::totext(text, length, units_popup->units, session->sample_rate,
+ session->frame_rate, session->frames_per_foot);
+ length_text->update(text);
+ units_popup->set_text(get_text());
+ return 1;
+}
+TransitionUnitsPopup::TransitionUnitsPopup(TransitionLengthDialog *gui, int x, int y)
+ : BC_PopupMenu(x, y, 100, "", 1)
+{
+ this->gui = gui;
+ units = TIME_SECONDS;
+}
+TransitionUnitsPopup::~TransitionUnitsPopup()
+{
+}
+void TransitionUnitsPopup::create_objects()
+{
+ TransitionUnitsItem *units_item;
+ add_item(units_item = new TransitionUnitsItem(this, _("Seconds"), TIME_SECONDS));
+ add_item(new TransitionUnitsItem(this, _("Frames"), TIME_FRAMES));
+ add_item(new TransitionUnitsItem(this, _("Samples"), TIME_SAMPLES));
+ add_item(new TransitionUnitsItem(this, _("H:M:S.xxx"), TIME_HMS));
+ add_item(new TransitionUnitsItem(this, _("H:M:S:frm"), TIME_HMSF));
+ set_text(units_item->get_text());
+}
TransitionLengthDialog::TransitionLengthDialog(MWindow *mwindow,
- TransitionLengthThread *thread,
- int x,
- int y)
- : BC_Window(_(PROGRAM_NAME ": Transition length"),
- x,
- y,
- 300,
- 100,
- -1,
- -1,
- 0,
- 0,
- 1)
+ TransitionLengthThread *thread, int x, int y)
+ : BC_Window(_(PROGRAM_NAME ": Transition length"), x, y,
+ 300, 100, -1, -1, 0, 0, 1)
{
this->mwindow = mwindow;
this->thread = thread;
void TransitionLengthDialog::create_objects()
{
lock_window("TransitionLengthDialog::create_objects");
- add_subwindow(new BC_Title(10, 10, _("Seconds:")));
- text = new TransitionLengthText(mwindow, this, 100, 10);
+ add_subwindow(units_popup = new TransitionUnitsPopup(this, 10, 10));
+ units_popup->create_objects();
+ text = new TransitionLengthText(mwindow, this, 160, 10);
text->create_objects();
+ text->set_precision(3);
+ text->set_increment(0.1);
add_subwindow(new BC_OKButton(this));
add_subwindow(new BC_CancelButton(this));
show_window();
}
-
-
-
-
TransitionLengthText::TransitionLengthText(MWindow *mwindow,
- TransitionLengthDialog *gui,
- int x,
- int y)
- : BC_TumbleTextBox(gui,
- (float)gui->thread->length,
- (float)0,
- (float)100,
- x,
- y,
- 100)
+ TransitionLengthDialog *gui, int x, int y)
+ : BC_TumbleTextBox(gui, (float)gui->thread->new_length,
+ 0.f, 100.f, x, y, 100)
{
this->mwindow = mwindow;
this->gui = gui;
int TransitionLengthText::handle_event()
{
- double result = atof(get_text());
- if(!EQUIV(result, gui->thread->length))
- {
- gui->thread->length = result;
- mwindow->gui->lock_window();
- mwindow->gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
- mwindow->gui->unlock_window();
- }
-
- return 1;
+ const char *text = get_text();
+ int units = gui->units_popup->units;
+ EDLSession *session = gui->mwindow->edl->session;
+ double result = Units::text_to_seconds(text, session->sample_rate,
+ units, session->frame_rate, session->frames_per_foot);
+ return gui->thread->update(result);
}
+int TransitionLengthText::handle_up_down(int dir)
+{
+ double delta = 0;
+ int units = gui->units_popup->units;
+ EDLSession *session = gui->mwindow->edl->session;
+ switch( units ) {
+ case TIME_SECONDS:
+ case TIME_HMS:
+ delta = 0.1;
+ break;
+ case TIME_HMSF:
+ case TIME_FRAMES:
+ delta = session->frame_rate > 0 ? 1./session->frame_rate : 0;
+ break;
+ case TIME_SAMPLES:
+ delta = session->sample_rate > 0 ? 1./session->sample_rate : 0;
+ break;
+ }
+ double length = gui->thread->new_length + delta * dir;
+ char text[BCSTRLEN];
+ Units::totext(text, length, units,
+ session->sample_rate, session->frame_rate,
+ session->frames_per_foot);
+ update(text);
+ return gui->thread->update(length);
+}
-
-
-
-
-
-
-
+int TransitionLengthText::handle_up_event()
+{
+ return handle_up_down(+1);
+}
+int TransitionLengthText::handle_down_event()
+{
+ return handle_up_down(-1);
+}
TransitionPopup::TransitionPopup(MWindow *mwindow, MWindowGUI *gui)
int TransitionPopup::update(Transition *transition)
{
this->transition = transition;
- this->length = transition->edit->track->from_units(transition->length);
show->set_checked(transition->show);
on->set_checked(transition->on);
char len_text[50];
}
-
-
-
TransitionPopupAttach::TransitionPopupAttach(MWindow *mwindow, TransitionPopup *popup)
: BC_MenuItem(_("Attach..."))
{
}
-
-
-
-
-
TransitionPopupDetach::TransitionPopupDetach(MWindow *mwindow, TransitionPopup *popup)
: BC_MenuItem(_("Detach"))
{
}
-
-
-
-
TransitionPopupShow::TransitionPopupShow(MWindow *mwindow, TransitionPopup *popup)
: BC_MenuItem(_("Show"))
{
}
-
-
-
-
-
-
TransitionPopupLength::TransitionPopupLength(MWindow *mwindow, TransitionPopup *popup)
: BC_MenuItem(_("Length"))
{
int TransitionPopupLength::handle_event()
{
- popup->length_thread->start(popup->transition,
- popup->length);
+ Transition *transition = popup->transition;
+ double length = transition->edit->track->from_units(transition->length);
+ popup->length_thread->start(popup->transition, length);
return 1;
}
-
-
-
-
-
-
-
-
-
-
-
BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
int64_t default_value, int x, int y)
: BC_TextBox(x, y, popup->text_w, 1, default_value)
-
BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
int64_t default_value, int64_t min, int64_t max,
int x, int y, int text_w)
x += textbox->get_w();
tumbler = use_float ?
- (BC_Tumbler *)new BC_FTumbler(textbox, min_f, max_f, x, y) :
- (BC_Tumbler *)new BC_ITumbler(textbox, min, max, x, y);
+ (BC_Tumbler *)new BC_FTextTumbler(this, min_f, max_f, x, y) :
+ (BC_Tumbler *)new BC_ITextTumbler(this, min, max, x, y);
parent_window->add_subwindow(tumbler);
tumbler->set_increment(increment);
return 0;
}
+int BC_TumbleTextBox::handle_up_event()
+{
+ return use_float ?
+ ((BC_FTumbler *)tumbler)->BC_FTumbler::handle_up_event() :
+ ((BC_ITumbler *)tumbler)->BC_ITumbler::handle_up_event() ;
+}
+
+int BC_TumbleTextBox::handle_down_event()
+{
+ return use_float ?
+ ((BC_FTumbler *)tumbler)->BC_FTumbler::handle_down_event() :
+ ((BC_ITumbler *)tumbler)->BC_ITumbler::handle_down_event() ;
+}
+
const char* BC_TumbleTextBox::get_text()
{
return textbox->get_text();
};
+class BC_TumbleTextBox;
class BC_TumbleTextBoxText;
-class BC_TumbleTextBoxTumble;
+class BC_FTextTumbler;
+class BC_ITextTumbler;
+
class BC_TumbleTextBox
{
int create_objects();
void reset();
virtual int handle_event();
+ virtual int handle_up_event();
+ virtual int handle_down_event();
const char* get_text();
const wchar_t* get_wtext();
BC_TextBox* get_textbox();
void set_tooltip(const char *text);
friend class BC_TumbleTextBoxText;
- friend class BC_TumbleTextBoxTumble;
+ friend class BC_FTextTumbler;
+ friend class BC_ITextTumbler;
private:
int x, y, text_w;
BC_TumbleTextBox *popup;
};
+class BC_FTextTumbler : public BC_FTumbler
+{
+public:
+ BC_FTextTumbler(BC_TumbleTextBox *tumble_text,
+ float min_f, float max_f, int x, int y)
+ : BC_FTumbler(tumble_text->textbox, min_f, max_f, x, y) {
+ this->tumble_text = tumble_text;
+ }
+ ~BC_FTextTumbler() {}
+ int handle_up_event() { return tumble_text->handle_up_event(); }
+ int handle_down_event() { return tumble_text->handle_down_event(); }
+
+ BC_TumbleTextBox *tumble_text;
+};
+
+class BC_ITextTumbler : public BC_ITumbler
+{
+public:
+ BC_ITextTumbler(BC_TumbleTextBox *tumble_text,
+ int64_t min, int64_t max, int x, int y)
+ : BC_ITumbler(tumble_text->textbox, min, max, x, y) {
+ this->tumble_text = tumble_text;
+ }
+ ~BC_ITextTumbler() {}
+ int handle_up_event() { return tumble_text->handle_up_event(); }
+ int handle_down_event() { return tumble_text->handle_down_event(); }
+
+ BC_TumbleTextBox *tumble_text;
+};
+
class BC_TextMenu : public BC_PopupMenu
{