#include "automation.h"
#include "bccolors.h"
+#include "bctimer.h"
#include "clip.h"
#include "condition.h"
#include "cpanel.h"
CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
- : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100)
+ : BC_TumbleTextBox(gui, (float)value, (float)-65536, (float)65536, x, y, 100, 3)
{
this->gui = gui;
set_log_floatincrement(log_increment);
}
CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
- : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100)
+ : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 100, 3)
{
this->gui = gui;
}
mwindow->edl->session->crop_y2 = atol(height->get_text()) +
mwindow->edl->session->crop_y1;
update();
- mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
- mwindow->cwindow->gui->canvas->draw_refresh();
- mwindow->cwindow->gui->unlock_window();
+ mwindow->cwindow->gui->canvas->redraw(1);
}
void CWindowCropGUI::update()
void CWindowCameraGUI::update_preview()
{
- mwindow->gui->lock_window("CWindowCameraGUI::update_preview");
- mwindow->restart_brender();
- mwindow->gui->draw_overlays(1);
- mwindow->sync_parameters(CHANGE_PARAMS);
- mwindow->gui->unlock_window();
- mwindow->cwindow->refresh_frame(CHANGE_NONE);
- mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
- mwindow->cwindow->gui->canvas->draw_refresh();
- mwindow->cwindow->gui->unlock_window();
+ CWindowGUI *cgui = mwindow->cwindow->gui;
+ cgui->lock_window("CWindowCameraGUI::update_preview");
+ cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+ cgui->unlock_window();
}
void CWindowProjectorGUI::update_preview()
{
- mwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
- mwindow->restart_brender();
- mwindow->sync_parameters(CHANGE_PARAMS);
- mwindow->gui->draw_overlays(1);
- mwindow->gui->unlock_window();
- mwindow->cwindow->refresh_frame(CHANGE_NONE);
- mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
- mwindow->cwindow->gui->canvas->draw_refresh();
- mwindow->cwindow->gui->unlock_window();
+ CWindowGUI *cgui = mwindow->cwindow->gui;
+ cgui->lock_window("CWindowProjectorGUI::update_preview");
+ cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+ cgui->unlock_window();
}
void CWindowProjectorGUI::handle_event()
}
-CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
+CWindowMaskName::CWindowMaskName(MWindow *mwindow,
CWindowToolGUI *gui, int x, int y, const char *text)
- : BC_PopupMenu(x, y, 220, text, 1)
+ : BC_PopupTextBox(gui, 0, text, x, y, 100, 160)
{
this->mwindow = mwindow;
this->gui = gui;
}
-void CWindowMaskMode::create_objects()
+CWindowMaskName::~CWindowMaskName()
{
- add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
- add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
}
-char* CWindowMaskMode::mode_to_text(int mode)
+int CWindowMaskName::handle_event()
{
- switch(mode)
- {
- case MASK_MULTIPLY_ALPHA:
- return _("Multiply alpha");
- break;
-
- case MASK_SUBTRACT_ALPHA:
- return _("Subtract alpha");
- break;
+ Track *track;
+ MaskAutos *autos;
+ MaskAuto *keyframe;
+ SubMask *mask;
+ MaskPoint *point;
+//printf("CWindowMaskGUI::update 1\n");
+ ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
+ if( track ) {
+ int k = get_number();
+ if( k < 0 ) k = mwindow->edl->session->cwindow_mask;
+ else mwindow->edl->session->cwindow_mask = k;
+ if( k >= 0 && k < mask_items.size() ) {
+ mask_items[k]->set_text(get_text());
+ update_list(&mask_items);
+ }
+#ifdef USE_KEYFRAME_SPANNING
+ MaskAuto temp_keyframe(mwindow->edl, autos);
+ temp_keyframe.copy_data(keyframe);
+ SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
+ memset(submask->name, 0, sizeof(submask->name));
+ strncpy(submask->name, get_text(), sizeof(submask->name)-1);
+ ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
+#else
+ for(MaskAuto *current = (MaskAuto*)autos->default_auto; current; ) {
+ SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
+ memset(submask->name, 0, sizeof(submask->name));
+ strncpy(submask->name, get_text(), sizeof(submask->name));
+ current = current == (MaskAuto*)autos->default_auto ?
+ (MaskAuto*)autos->first : (MaskAuto*)NEXT;
+ }
+#endif
+ gui->update();
+ gui->update_preview();
}
-
- return _("Subtract alpha");
+ return 1;
}
-int CWindowMaskMode::text_to_mode(char *text)
+void CWindowMaskName::update_items(MaskAuto *keyframe)
{
- if(!strcasecmp(text, _("Multiply alpha")))
- return MASK_MULTIPLY_ALPHA;
- else
- if(!strcasecmp(text, _("Subtract alpha")))
- return MASK_SUBTRACT_ALPHA;
+ mask_items.remove_all_objects();
+ int sz = keyframe->masks.size();
+ for( int i=0; i<sz; ++i ) {
+ SubMask *sub_mask = keyframe->masks.get(i);
+ char *text = sub_mask->name;
+ mask_items.append(new BC_ListBoxItem(text));
+ }
+ update_list(&mask_items);
+}
+
- return MASK_SUBTRACT_ALPHA;
+CWindowMaskDelMask::CWindowMaskDelMask(MWindow *mwindow,
+ CWindowToolGUI *gui, int x, int y)
+ : BC_GenericButton(x, y, _("Delete"))
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip(_("Delete mask"));
}
-int CWindowMaskMode::handle_event()
+int CWindowMaskDelMask::handle_event()
{
MaskAutos *autos;
MaskAuto *keyframe;
Track *track;
MaskPoint *point;
SubMask *mask;
+ int total_points;
+
// Get existing keyframe
((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
- if(track)
- {
- mwindow->undo->update_undo_before(_("mask mode"), 0);
+
+ if( track ) {
+ mwindow->undo->update_undo_before(_("mask delete"), 0);
+
#ifdef USE_KEYFRAME_SPANNING
// Create temp keyframe
MaskAuto temp_keyframe(mwindow->edl, autos);
temp_keyframe.copy_data(keyframe);
-// Update parameter
- temp_keyframe.mode = text_to_mode(get_text());
+ SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
+ submask->points.remove_all_objects();
+ total_points = 0;
// Commit change to span of keyframes
- autos->update_parameter(&temp_keyframe);
+ ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
#else
- ((MaskAuto*)autos->default_auto)->mode =
- text_to_mode(get_text());
+ for(MaskAuto *current = (MaskAuto*)autos->default_auto; current; ) {
+ SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
+ submask->points.clear();
+ current = current == (MaskAuto*)autos->default_auto ?
+ (MaskAuto*)autos->first : (MaskAuto*)NEXT;
+ }
+ total_points = 0;
#endif
- mwindow->undo->update_undo_after(_("mask mode"), LOAD_AUTOMATION);
+ if( mwindow->cwindow->gui->affected_point >= total_points )
+ mwindow->cwindow->gui->affected_point =
+ total_points > 0 ? total_points-1 : 0;
+
+ gui->update();
+ gui->update_preview();
+ mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
}
-//printf("CWindowMaskMode::handle_event 1\n");
- gui->update_preview();
return 1;
}
-
-
-
-
-
-
-
-CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
- CWindowToolGUI *gui,
- int x,
- int y)
+CWindowMaskDelPoint::CWindowMaskDelPoint(MWindow *mwindow,
+ CWindowToolGUI *gui, int x, int y)
: BC_GenericButton(x, y, _("Delete"))
{
this->mwindow = mwindow;
this->gui = gui;
+ set_tooltip(_("Delete point"));
}
-int CWindowMaskDelete::handle_event()
+int CWindowMaskDelPoint::handle_event()
{
MaskAutos *autos;
MaskAuto *keyframe;
Track *track;
MaskPoint *point;
SubMask *mask;
- int total_points = 0;
+ int total_points;
// Get existing keyframe
((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
-
- if(track)
- {
- mwindow->undo->update_undo_before(_("mask delete"), 0);
+ if( track ) {
+ mwindow->undo->update_undo_before(_("point delete"), 0);
#ifdef USE_KEYFRAME_SPANNING
// Create temp keyframe
temp_keyframe.copy_data(keyframe);
// Update parameter
SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
- if( shift_down() )
- submask->points.remove_all_objects();
-
- for(int i = mwindow->cwindow->gui->affected_point;
- i < submask->points.total - 1;
- i++)
- {
- *submask->points.values[i] = *submask->points.values[i + 1];
- }
-
- if(submask->points.total)
- {
- submask->points.remove_object(
- submask->points.values[submask->points.total - 1]);
+ int i = mwindow->cwindow->gui->affected_point;
+ for( ; i<submask->points.total-1; ++i )
+ *submask->points.values[i] = *submask->points.values[i+1];
+ if( submask->points.total > 0 ) {
+ point = submask->points.values[submask->points.total-1];
+ submask->points.remove_object(point);
}
total_points = submask->points.total;
// Commit change to span of keyframes
((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->update_parameter(&temp_keyframe);
#else
- for(MaskAuto *current = (MaskAuto*)autos->default_auto;
- current; )
- {
+ MaskAuto *current = (MaskAuto*)autos->default_auto;
+ while( current ) {
SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
- if( shift_down() )
- submask->points.remove_all_objects();
-
- for(int i = mwindow->cwindow->gui->affected_point;
- i < submask->points.total - 1;
- i++)
- {
- *submask->points.values[i] = *submask->points.values[i + 1];
- }
-
- if(submask->points.total)
- {
- submask->points.remove_object(
- submask->points.values[submask->points.total - 1]);
+ int i = mwindow->cwindow->gui->affected_point;
+ for( ; i<submask->points.total-1; ++i ) {
+ *submask->points.values[i] = *submask->points.values[i+1];
+ if( submask->points.total > 0 ) {
+ point = submask->points.values[submask->points.total-1];
+ submask->points.remove_object(point);
}
total_points = submask->points.total;
-
- if(current == (MaskAuto*)autos->default_auto)
- current = (MaskAuto*)autos->first;
- else
- current = (MaskAuto*)NEXT;
+ current = current == (MaskAuto*)autos->default_auto ?
+ (MaskAuto*)autos->first : (MaskAuto*)NEXT;
}
#endif
if( mwindow->cwindow->gui->affected_point >= total_points )
mwindow->undo->update_undo_after(_("mask delete"), LOAD_AUTOMATION);
}
-
return 1;
}
-int CWindowMaskDelete::keypress_event()
+int CWindowMaskDelPoint::keypress_event()
{
- if(get_keypress() == BACKSPACE ||
- get_keypress() == DELETE)
+ if( get_keypress() == BACKSPACE ||
+ get_keypress() == DELETE )
return handle_event();
return 0;
}
-// CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
-// : BC_GenericButton(x, y, _("Cycle next"))
-// {
-// this->mwindow = mwindow;
-// this->gui = gui;
-// }
-// int CWindowMaskCycleNext::handle_event()
-// {
-// MaskAuto *keyframe;
-// MaskAutos *autos;
-// Track *track;
-// MaskPoint *point;
-// SubMask *mask;
-// ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
-//
-// MaskPoint *temp;
-//
-// // Should apply to all keyframes
-// if(keyframe && mask->points.total)
-// {
-// temp = mask->points.values[0];
-//
-// for(int i = 0; i < mask->points.total - 1; i++)
-// {
-// mask->points.values[i] = mask->points.values[i + 1];
-// }
-// mask->points.values[mask->points.total - 1] = temp;
-//
-// mwindow->cwindow->gui->affected_point--;
-// if(mwindow->cwindow->gui->affected_point < 0)
-// mwindow->cwindow->gui->affected_point = mask->points.total - 1;
-//
-// gui->update();
-// gui->update_preview();
-// }
-//
-// return 1;
-// }
-//
-// CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
-// : BC_GenericButton(x, y, _("Cycle prev"))
-// {
-// this->mwindow = mwindow;
-// this->gui = gui;
-// }
-// int CWindowMaskCyclePrev::handle_event()
-// {
-// MaskAuto *keyframe;
-// MaskAutos *autos;
-// Track *track;
-// MaskPoint *point;
-// SubMask *mask;
-// ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
-//
-// // Should apply to all keyframes
-// MaskPoint *temp;
-// if(keyframe && mask->points.total)
-// {
-// temp = mask->points.values[mask->points.total - 1];
-//
-// for(int i = mask->points.total - 1; i > 0; i--)
-// {
-// mask->points.values[i] = mask->points.values[i - 1];
-// }
-// mask->points.values[0] = temp;
-//
-// mwindow->cwindow->gui->affected_point++;
-// if(mwindow->cwindow->gui->affected_point >= mask->points.total)
-// mwindow->cwindow->gui->affected_point = 0;
-//
-// gui->update();
-// gui->update_preview();
-// }
-// return 1;
-// }
-
-
-CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
- CWindowToolGUI *gui,
- int x,
- int y)
- : BC_TumbleTextBox(gui,
- (int64_t)mwindow->edl->session->cwindow_mask,
- (int64_t)0,
- (int64_t)SUBMASKS - 1,
- x,
- y,
- 100)
-{
- this->mwindow = mwindow;
- this->gui = gui;
-}
-
-CWindowMaskNumber::~CWindowMaskNumber()
-{
-}
-
-int CWindowMaskNumber::handle_event()
-{
- mwindow->edl->session->cwindow_mask = atol(get_text());
- gui->update();
- gui->update_preview();
- return 1;
-}
CWindowMaskAffectedPoint::CWindowMaskAffectedPoint(MWindow *mwindow,
int active_point = affected_point;
if( affected_point >= total_points )
affected_point = total_points - 1;
- else if( affected_point < 0 )
+ if( affected_point < 0 )
affected_point = 0;
if( active_point != affected_point )
update((int64_t)affected_point);
}
+CWindowMaskFocus::CWindowMaskFocus(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
+ : BC_CheckBox(x, y, ((CWindowMaskGUI*)gui)->focused, _("Focus"))
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip("Center for rotate/scale");
+}
+CWindowMaskFocus::~CWindowMaskFocus()
+{
+}
+
+int CWindowMaskFocus::handle_event()
+{
+ ((CWindowMaskGUI*)gui)->focused = get_value();
+ gui->update();
+ gui->update_preview();
+ return 1;
+}
+
+CWindowMaskDrawMarkers::CWindowMaskDrawMarkers(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
+ : BC_CheckBox(x, y, ((CWindowMaskGUI*)gui)->markers, _("Markers"))
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip("Display points");
+}
+
+CWindowMaskDrawMarkers::~CWindowMaskDrawMarkers()
+{
+}
+
+int CWindowMaskDrawMarkers::handle_event()
+{
+ ((CWindowMaskGUI*)gui)->markers = get_value();
+ gui->update();
+ gui->update_preview();
+ return 1;
+}
+
+CWindowMaskDrawBoundary::CWindowMaskDrawBoundary(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
+ : BC_CheckBox(x, y, ((CWindowMaskGUI*)gui)->boundary, _("Boundary"))
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip("Display mask outline");
+}
+
+CWindowMaskDrawBoundary::~CWindowMaskDrawBoundary()
+{
+}
+
+int CWindowMaskDrawBoundary::handle_event()
+{
+ ((CWindowMaskGUI*)gui)->boundary = get_value();
+ gui->update();
+ gui->update_preview();
+ return 1;
+}
CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
- : BC_TumbleTextBox(gui,
- (int64_t)0,
- (int64_t)0,
- (int64_t)0xff,
- x,
- y,
- 100)
+ : BC_TumbleTextBox(gui, 0, -FEATHER_MAX, FEATHER_MAX, x, y, 64, 2)
{
this->mwindow = mwindow;
this->gui = gui;
CWindowMaskFeather::~CWindowMaskFeather()
{
}
-int CWindowMaskFeather::handle_event()
+
+int CWindowMaskFeather::update(float v)
+{
+ CWindowMaskGUI *mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->feather_slider->update(v);
+ return BC_TumbleTextBox::update(v);
+}
+
+int CWindowMaskFeather::update_value(float v)
{
MaskAutos *autos;
MaskAuto *keyframe;
// Get existing keyframe
((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
mask, point, create_it);
-
- if(track)
- {
+ if( track ) {
+ int gang = ((CWindowMaskGUI*)gui)->gang_feather->get_value();
#ifdef USE_KEYFRAME_SPANNING
-// Create temp keyframe
MaskAuto temp_keyframe(mwindow->edl, autos);
temp_keyframe.copy_data(keyframe);
-// Update parameter
- temp_keyframe.feather = atof(get_text());
-// Commit change to span of keyframes
- autos->update_parameter(&temp_keyframe);
-#else
- keyframe->feather = atof(get_text());
+ keyframe = &temp_keyframe;
+#endif
+ float change = v - mask->feather;
+ int k = mwindow->edl->session->cwindow_mask;
+ int n = gang ? keyframe->masks.size() : k+1;
+ for( int i=gang? 0 : k; i<n; ++i ) {
+ SubMask *sub_mask = keyframe->get_submask(i);
+ float feather = sub_mask->feather + change;
+ bclamp(feather, -FEATHER_MAX, FEATHER_MAX);
+ sub_mask->feather = feather;
+ }
+#ifdef USE_KEYFRAME_SPANNING
+ autos->update_parameter(keyframe);
#endif
-
gui->update_preview();
}
return 1;
}
+int CWindowMaskFeather::handle_event()
+{
+ float v = atof(get_text());
+ CWindowMaskGUI * mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->feather_slider->update(v);
+ return mask_gui->feather->update_value(v);
+}
-CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
- : BC_ISlider(x,
- y,
- 0,
- 200,
- 200,
- 0,
- 100,
- 0)
+CWindowMaskFeatherSlider::CWindowMaskFeatherSlider(MWindow *mwindow,
+ CWindowToolGUI *gui, int x, int y, int w, float v)
+ : BC_FSlider(x, y, 0, w, w, -FEATHER_MAX, FEATHER_MAX, v)
{
this->mwindow = mwindow;
this->gui = gui;
+ set_precision(0.01);
+ timer = new Timer();
+ stick = 0;
+ last_v = 0;
}
-CWindowMaskValue::~CWindowMaskValue()
+CWindowMaskFeatherSlider::~CWindowMaskFeatherSlider()
{
+ delete timer;
}
-int CWindowMaskValue::handle_event()
+int CWindowMaskFeatherSlider::handle_event()
+{
+ float v = get_value();
+ if( stick > 0 ) {
+ int64_t ms = timer->get_difference();
+ if( ms < 250 && --stick > 0 ) {
+ if( get_value() == 0 ) return 1;
+ update(v = 0);
+ }
+ else {
+ stick = 0;
+ last_v = v;
+ }
+ }
+ else if( (last_v>=0 && v<0) || (last_v<0 && v>=0) ) {
+ stick = 16;
+ v = 0;
+ }
+ else
+ last_v = v;
+ timer->update();
+ CWindowMaskGUI * mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->feather->BC_TumbleTextBox::update(v);
+ return mask_gui->feather->update_value(v);
+}
+
+int CWindowMaskFeatherSlider::update(float v)
+{
+ return BC_FSlider::update(v);
+}
+
+CWindowMaskFade::CWindowMaskFade(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
+ : BC_TumbleTextBox(gui, 0, -100.f, 100.f, x, y, 64, 2)
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+}
+CWindowMaskFade::~CWindowMaskFade()
+{
+}
+
+int CWindowMaskFade::update(float v)
+{
+ CWindowMaskGUI *mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->fade_slider->update(v);
+ return BC_TumbleTextBox::update(v);
+}
+
+int CWindowMaskFade::update_value(float v)
{
MaskAutos *autos;
MaskAuto *keyframe;
int create_it = 1;
#endif
- mwindow->undo->update_undo_before(_("mask value"), this);
- ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
- mask, point, create_it);
+ mwindow->undo->update_undo_before(_("mask fade"), this);
- if(track)
- {
+// Get existing keyframe
+ ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe,
+ mask, point, create_it);
+ if( track ) {
+ int gang = ((CWindowMaskGUI*)gui)->gang_fader->get_value();
#ifdef USE_KEYFRAME_SPANNING
-// Create temp keyframe
MaskAuto temp_keyframe(mwindow->edl, autos);
temp_keyframe.copy_data(keyframe);
-// Update parameter
- temp_keyframe.value = get_value();
-// Commit change to span of keyframes
- autos->update_parameter(&temp_keyframe);
-#else
- keyframe->value = get_value();
+ keyframe = &temp_keyframe;
#endif
+ float change = v - mask->fader;
+ int k = mwindow->edl->session->cwindow_mask;
+ int n = gang ? keyframe->masks.size() : k+1;
+ for( int i=gang? 0 : k; i<n; ++i ) {
+ SubMask *sub_mask = keyframe->get_submask(i);
+ float fader = sub_mask->fader + change;
+ bclamp(fader, -100.f, 100.f);
+ sub_mask->fader = fader;
+ }
+#ifdef USE_KEYFRAME_SPANNING
+ autos->update_parameter(keyframe);
+#endif
+ gui->update_preview();
}
- gui->update_preview();
- mwindow->undo->update_undo_after(_("mask value"), LOAD_AUTOMATION);
+ mwindow->undo->update_undo_after(_("mask fade"), LOAD_AUTOMATION);
return 1;
}
+int CWindowMaskFade::handle_event()
+{
+ float v = atof(get_text());
+ CWindowMaskGUI * mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->fade_slider->update(v);
+ return mask_gui->fade->update_value(v);
+}
+
+CWindowMaskFadeSlider::CWindowMaskFadeSlider(MWindow *mwindow, CWindowToolGUI *gui,
+ int x, int y, int w)
+ : BC_ISlider(x, y, 0, w, w, -200, 200, 0)
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ timer = new Timer();
+ stick = 0;
+ last_v = 0;
+}
+
+CWindowMaskFadeSlider::~CWindowMaskFadeSlider()
+{
+ delete timer;
+}
+
+int CWindowMaskFadeSlider::handle_event()
+{
+ float v = 100*get_value()/200;
+ if( stick > 0 ) {
+ int64_t ms = timer->get_difference();
+ if( ms < 250 && --stick > 0 ) {
+ if( get_value() == 0 ) return 1;
+ update(v = 0);
+ }
+ else {
+ stick = 0;
+ last_v = v;
+ }
+ }
+ else if( (last_v>=0 && v<0) || (last_v<0 && v>=0) ) {
+ stick = 16;
+ v = 0;
+ }
+ else
+ last_v = v;
+ timer->update();
+ CWindowMaskGUI *mask_gui = (CWindowMaskGUI*)gui;
+ mask_gui->fade->BC_TumbleTextBox::update(v);
+ return mask_gui->fade->update_value(v);
+}
+
+int CWindowMaskFadeSlider::update(int64_t v)
+{
+ return BC_ISlider::update(200*v/100);
+}
+
+CWindowMaskGangFader::CWindowMaskGangFader(MWindow *mwindow,
+ CWindowToolGUI *gui, int x, int y)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("gangpatch_data"), 0)
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip(_("Gang fader"));
+}
+
+CWindowMaskGangFader::~CWindowMaskGangFader()
+{
+}
+
+int CWindowMaskGangFader::handle_event()
+{
+ return 1;
+}
CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
: BC_CheckBox(x,
((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
if (keyframe) {
- keyframe->apply_before_plugins = get_value();
+ int v = get_value();
+#ifdef USE_KEYFRAME_SPANNING
+ MaskAuto temp_keyframe(gui->mwindow->edl, autos);
+ temp_keyframe.copy_data(keyframe);
+ temp_keyframe.apply_before_plugins = v;
+ autos->update_parameter(&temp_keyframe);
+#else
+ keyframe->apply_before_plugins = v;
+#endif
gui->update_preview();
}
return 1;
MaskPoint *point;
((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 1);
- if (keyframe) {
- keyframe->disable_opengl_masking = get_value();
+ if( keyframe ) {
+ int v = get_value();
+#ifdef USE_KEYFRAME_SPANNING
+ MaskAuto temp_keyframe(gui->mwindow->edl, autos);
+ temp_keyframe.copy_data(keyframe);
+ temp_keyframe.disable_opengl_masking = v;
+ autos->update_parameter(&temp_keyframe);
+#else
+ keyframe->disable_opengl_masking = v;
+#endif
gui->update_preview();
}
return 1;
}
+CWindowMaskClrMask::CWindowMaskClrMask(MWindow *mwindow,
+ CWindowMaskGUI *gui, int x, int y)
+ : BC_Button(x, y, mwindow->theme->get_image_set("reset_button"))
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip(_("Delete all masks"));
+}
+CWindowMaskClrMask::~CWindowMaskClrMask()
+{
+}
+int CWindowMaskClrMask::calculate_w(MWindow *mwindow)
+{
+ VFrame *vfrm = *mwindow->theme->get_image_set("reset_button");
+ return vfrm->get_w();
+}
+int CWindowMaskClrMask::handle_event()
+{
+ MaskAutos *autos;
+ MaskAuto *keyframe;
+ Track *track;
+ MaskPoint *point;
+ SubMask *mask;
+// Get existing keyframe
+ ((CWindowMaskGUI*)gui)->get_keyframe(track, autos, keyframe, mask, point, 0);
+ if( track ) {
+ mwindow->undo->update_undo_before(_("del masks"), 0);
+ ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->clear_all();
+ gui->update();
+ gui->update_preview();
+ mwindow->undo->update_undo_after(_("del masks"), LOAD_AUTOMATION);
+ }
+
+ return 1;
+}
+
+CWindowMaskGangFeather::CWindowMaskGangFeather(MWindow *mwindow,
+ CWindowToolGUI *gui, int x, int y)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("gangpatch_data"), 0)
+{
+ this->mwindow = mwindow;
+ this->gui = gui;
+ set_tooltip(_("Gang feather"));
+}
+CWindowMaskGangFeather::~CWindowMaskGangFeather()
+{
+}
+
+int CWindowMaskGangFeather::handle_event()
+{
+ return 1;
+}
CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
: CWindowToolGUI(mwindow, thread,
- _(PROGRAM_NAME ": Mask"), 330, 320)
+ _(PROGRAM_NAME ": Mask"), 360, 440)
{
this->mwindow = mwindow;
this->thread = thread;
- number = 0;
active_point = 0;
+ fade = 0;
feather = 0;
+ focused = 0;
+ markers = 1;
+ boundary = 1;
}
CWindowMaskGUI::~CWindowMaskGUI()
{
lock_window("CWindowMaskGUI::~CWindowMaskGUI");
- delete number;
delete active_point;
+ delete fade;
delete feather;
unlock_window();
}
void CWindowMaskGUI::create_objects()
{
int x = 10, y = 10, margin = mwindow->theme->widget_border;
+ int clr_x = get_w()-x - CWindowMaskClrMask::calculate_w(mwindow);
+ int del_x = clr_x-margin - CWindowMaskDelMask::calculate_w(this,_("Delete"));
//MaskAuto *keyframe = 0;
//Track *track = mwindow->cwindow->calculate_affected_track();
//if(track)
lock_window("CWindowMaskGUI::create_objects");
BC_Title *title;
- add_subwindow(title = new BC_Title(x, y, _("Mode:")));
- add_subwindow(mode = new CWindowMaskMode(mwindow,
- this, x + title->get_w() + margin, y, ""));
- mode->create_objects();
- y += mode->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Value:")));
- add_subwindow(value = new CWindowMaskValue(mwindow, this, x + title->get_w() + margin, y));
- y += value->get_h() + margin;
- add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
- int x1 = x + delete_point->get_w() + 2*margin;
- add_subwindow(title = new BC_Title(x1, y, _("Point:")));
- x1 += title->get_w() + margin;
- active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
- active_point->create_objects();
- y += delete_point->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Mask number:")));
- number = new CWindowMaskNumber(mwindow,
- this, x + title->get_w() + margin, y);
- number->create_objects();
- y += number->get_h() + margin;
+ add_subwindow(title = new BC_Title(x, y, _("Mask:")));
+ int x1 = x + 70;
+ name = new CWindowMaskName(mwindow, this, x1, y, "");
+ name->create_objects();
+ add_subwindow(clr_mask = new CWindowMaskClrMask(mwindow, this, clr_x, y));
+ add_subwindow(del_mask = new CWindowMaskDelMask(mwindow, this, del_x, y));
+ y += name->get_h() + margin;
+ add_subwindow(title = new BC_Title(x, y, _("Fade:")));
+ fade = new CWindowMaskFade(mwindow, this, x1, y);
+ fade->create_objects();
+ int x2 = x1 + fade->get_w() + 2*margin;
+ int w2 = clr_x-2*margin - x2;
+ add_subwindow(fade_slider = new CWindowMaskFadeSlider(mwindow, this, x2, y, w2));
+ add_subwindow(gang_fader = new CWindowMaskGangFader(mwindow, this, clr_x, y));
+ y += fade->get_h() + margin;
add_subwindow(title = new BC_Title(x, y, _("Feather:")));
- feather = new CWindowMaskFeather(mwindow,
- this, x + title->get_w() + margin, y);
+ feather = new CWindowMaskFeather(mwindow, this, x1, y);
feather->create_objects();
- y += feather->get_h() + margin;
+ w2 = clr_x - 2*margin - x2;
+ feather_slider = new CWindowMaskFeatherSlider(mwindow, this, x2, y, w2, 0);
+ add_subwindow(feather_slider);
+ add_subwindow(gang_feather = new CWindowMaskGangFeather(mwindow, this, clr_x, y));
+ y += feather->get_h() + 3*margin;
+
+ add_subwindow(title = new BC_Title(x, y, _("Point:")));
+ active_point = new CWindowMaskAffectedPoint(mwindow, this, x1, y);
+ active_point->create_objects();
+ add_subwindow(del_point = new CWindowMaskDelPoint(mwindow, this, del_x, y));
+ y += active_point->get_h() + margin;
add_subwindow(title = new BC_Title(x, y, "X:"));
- x += title->get_w() + margin;
- this->x = new CWindowCoord(this, x, y, (float)0.0);
+ this->x = new CWindowCoord(this, x1, y, (float)0.0);
this->x->create_objects();
- x += this->x->get_w() + margin;
+ add_subwindow(draw_markers = new CWindowMaskDrawMarkers(mwindow, this, del_x, y));
+ y += this->x->get_h() + margin;
add_subwindow(title = new BC_Title(x, y, "Y:"));
- x += title->get_w() + margin;
- this->y = new CWindowCoord(this, x, y, (float)0.0);
+ this->y = new CWindowCoord(this, x1, y, (float)0.0);
this->y->create_objects();
-
- x = 10;
+ add_subwindow(draw_boundary = new CWindowMaskDrawBoundary(mwindow, this, del_x, y));
y += this->y->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Press Shift to move an end point")));
- y += title->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Press Ctrl to move a control point")));
- y += title->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Shift+click Delete to delete the mask")));
- y += title->get_h() + margin;
- add_subwindow(title = new BC_Title(x, y, _("Press Alt to translate the mask")));
- y += 30;
+ BC_Bar *bar;
+ add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
+ y += bar->get_h() + margin;
+ add_subwindow(title = new BC_Title(x, y, "X:"));
+ focus_x = new CWindowCoord(this, x1, y, (float)0.0);
+ focus_x->create_objects();
+ add_subwindow(focus = new CWindowMaskFocus(mwindow, this, del_x, y));
+ y += focus_x->get_h() + margin;
+ add_subwindow(title = new BC_Title(x, y, "Y:"));
+ focus_y = new CWindowCoord(this, x1, y, (float)0.0);
+ focus_y->create_objects();
+ y += focus_x->get_h() + margin;
add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this, 10, y));
- y += this->apply_before_plugins->get_h() + margin;
+ y += this->apply_before_plugins->get_h();
add_subwindow(this->disable_opengl_masking = new CWindowDisableOpenGLMasking(this, 10, y));
-
+ y += this->disable_opengl_masking->get_h() + margin;
+ add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
+ y += bar->get_h() + margin;
+
+ y += margin;
+ add_subwindow(title = new BC_Title(x, y, _(
+ "Shift+LMB: move an end point\n"
+ "Ctrl+LMB: move a control point\n"
+ "Alt+LMB: to drag translate the mask\n"
+ "Shift+Key Delete to delete the mask\n"
+ "Wheel Up/Dn: rotate around pointer\n"
+ "Shift+Wheel Up/Dn: scale around pointer\n"
+ "Shift+MMB: Toggle focus center at pointer")));
update();
unlock_window();
}
{
int64_t position_i = track->to_units(position, 0);
- if(point)
- {
+ if(point) {
x->update(point->x);
y->update(point->y);
}
- if(mask)
- {
- feather->update((int64_t)autos->get_feather(position_i, PLAY_FORWARD));
- value->update((int64_t)autos->get_value(position_i, PLAY_FORWARD));
- apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
- disable_opengl_masking->update((int64_t)keyframe->disable_opengl_masking);
+ if(mask) {
+ int k = mwindow->edl->session->cwindow_mask;
+ feather->update(autos->get_feather(position_i, k, PLAY_FORWARD));
+ fade->update(autos->get_fader(position_i, k, PLAY_FORWARD));
+ apply_before_plugins->update(keyframe->apply_before_plugins);
+ disable_opengl_masking->update(keyframe->disable_opengl_masking);
}
}
-//printf("CWindowMaskGUI::update 1\n");
active_point->update((int64_t)mwindow->cwindow->gui->affected_point);
- number->update((int64_t)mwindow->edl->session->cwindow_mask);
-
-//printf("CWindowMaskGUI::update 1\n");
- if(track)
- {
-#ifdef USE_KEYFRAME_SPANNING
- mode->set_text(
- CWindowMaskMode::mode_to_text(keyframe->mode));
-#else
- mode->set_text(
- CWindowMaskMode::mode_to_text(((MaskAuto*)autos->default_auto)->mode));
-#endif
+ const char *text = "";
+ if( keyframe ) {
+ name->update_items(keyframe);
+ int k = mwindow->edl->session->cwindow_mask;
+ if( k >= 0 && k < keyframe->masks.size() )
+ text = keyframe->masks[k]->name;
}
-//printf("CWindowMaskGUI::update 2\n");
+ name->update(text);
}
void CWindowMaskGUI::handle_event()
void CWindowMaskGUI::update_preview()
{
- mwindow->gui->lock_window("CWindowMaskGUI::update_preview");
- mwindow->restart_brender();
- mwindow->sync_parameters(CHANGE_PARAMS);
- mwindow->gui->draw_overlays(1);
- mwindow->gui->unlock_window();
- mwindow->cwindow->refresh_frame(CHANGE_NONE);
- mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
- mwindow->cwindow->gui->canvas->draw_refresh();
- mwindow->cwindow->gui->unlock_window();
+ unlock_window();
+ CWindowGUI *cgui = mwindow->cwindow->gui;
+ cgui->lock_window("CWindowMaskGUI::update_preview");
+ cgui->sync_parameters(CHANGE_PARAMS, 0, 1);
+ cgui->unlock_window();
+ lock_window("CWindowMaskGUI::update_preview");
}
+void CWindowMaskGUI::set_focused(int v, float cx, float cy)
+{
+ focus_x->update(cx);
+ focus_y->update(cy);
+ focus->update(focused = v);
+}
CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread)
: CWindowToolGUI(mwindow,