4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "apatchgui.h"
26 #include "bcwindowbase.h"
28 #include "cwindowgui.h"
31 #include "edlsession.h"
33 #include "floatauto.h"
35 #include "gwindowgui.h"
39 #include "keyframepopup.h"
41 #include "localsession.h"
42 #include "maincursor.h"
45 #include "mwindowgui.h"
50 #include "timelinepane.h"
52 #include "trackcanvas.h"
55 KeyframePopup::KeyframePopup(MWindow *mwindow, MWindowGUI *gui)
56 : BC_PopupMenu(0, 0, 0, "", 0)
58 this->mwindow = mwindow;
68 key_mode_displayed = false;
69 key_edit_displayed = false;
73 KeyframePopup::~KeyframePopup()
75 if( !key_mode_displayed ) {
83 if( !key_edit_displayed ) {
88 void KeyframePopup::create_objects()
90 add_item(key_show = new KeyframePopupShow(mwindow, this));
91 add_item(key_hide = new KeyframePopupHide(mwindow, this));
92 add_item(key_delete = new KeyframePopupDelete(mwindow, this));
93 add_item(key_copy = new KeyframePopupCopy(mwindow, this));
95 key_edit = new KeyframePopupEdit(mwindow, this);
96 key_mbar = new BC_MenuItem("-");
97 key_smooth = new KeyframePopupCurveMode(mwindow, this, FloatAuto::SMOOTH);
98 key_linear = new KeyframePopupCurveMode(mwindow, this, FloatAuto::LINEAR);
99 key_free_t = new KeyframePopupCurveMode(mwindow, this, FloatAuto::TFREE );
100 key_free = new KeyframePopupCurveMode(mwindow, this, FloatAuto::FREE );
101 key_bump = new KeyframePopupCurveMode(mwindow, this, FloatAuto::BUMP );
104 int KeyframePopup::update(Plugin *plugin, KeyFrame *keyframe)
106 gui->get_relative_cursor(popx, popy);
107 key_show->set_text(_("Show Plugin Settings"));
108 this->keyframe_plugin = plugin;
109 this->keyframe_auto = keyframe;
110 this->keyframe_autos = 0;
111 this->keyframe_automation = 0;
112 handle_curve_mode(0, 0);
116 int KeyframePopup::update(Automation *automation, Autos *autos, Auto *auto_keyframe)
118 gui->get_relative_cursor(popx, popy);
119 key_show->set_text(_(GWindowGUI::auto_text[autos->autoidx]));
120 this->keyframe_plugin = 0;
121 this->keyframe_automation = automation;
122 this->keyframe_autos = autos;
123 this->keyframe_auto = auto_keyframe;
124 handle_curve_mode(autos, auto_keyframe);
127 double current_position = mwindow->edl->local_session->get_selectionstart(1);
128 double new_position = keyframe_automation->track->from_units(keyframe_auto->position);
129 mwindow->edl->local_session->set_selectionstart(new_position);
130 mwindow->edl->local_session->set_selectionend(new_position);
131 if (current_position != new_position)
133 mwindow->edl->local_session->set_selectionstart(new_position);
134 mwindow->edl->local_session->set_selectionend(new_position);
135 mwindow->gui->lock_window();
136 mwindow->gui->update(1, NORMAL_DRAW, 1, 1, 1, 1, 0);
137 mwindow->gui->unlock_window();
142 void KeyframePopup::handle_curve_mode(Autos *autos, Auto *auto_keyframe)
143 // determines the type of automation node. if floatauto, adds
144 // menu entries showing the curve mode of the node
147 if( !key_edit_displayed && keyframe_plugin ) {
149 key_edit_displayed = true;
151 else if( key_edit_displayed && !keyframe_plugin ) {
152 remove_item(key_edit);
153 key_edit_displayed = false;
156 if(!key_mode_displayed && autos && autos->get_type() == AUTOMATION_TYPE_FLOAT)
157 { // append additional menu entries showing the curve_mode
159 add_item(key_smooth);
160 add_item(key_linear);
161 add_item(key_free_t);
164 key_mode_displayed = true;
166 else if(key_mode_displayed && (!autos || autos->get_type() != AUTOMATION_TYPE_FLOAT))
167 { // remove additional menu entries
168 remove_item(key_bump);
169 remove_item(key_free);
170 remove_item(key_free_t);
171 remove_item(key_linear);
172 remove_item(key_smooth);
173 remove_item(key_mbar);
174 key_mode_displayed = false;
176 if(key_mode_displayed && auto_keyframe)
177 { // set checkmarks to display current mode
178 key_smooth->toggle_mode((FloatAuto*)auto_keyframe);
179 key_linear->toggle_mode((FloatAuto*)auto_keyframe);
180 key_free_t->toggle_mode((FloatAuto*)auto_keyframe);
181 key_free ->toggle_mode((FloatAuto*)auto_keyframe);
182 key_bump ->toggle_mode((FloatAuto*)auto_keyframe);
187 KeyframePopupDelete::KeyframePopupDelete(MWindow *mwindow, KeyframePopup *popup)
188 : BC_MenuItem(_("Delete keyframe"))
190 this->mwindow = mwindow;
194 KeyframePopupDelete::~KeyframePopupDelete()
198 int KeyframePopupDelete::handle_event()
200 mwindow->undo->update_undo_before(_("delete keyframe"), 0);
201 mwindow->speed_before();
202 delete popup->keyframe_auto;
203 mwindow->speed_after(1);
204 mwindow->undo->update_undo_after(_("delete keyframe"), LOAD_ALL);
206 mwindow->save_backup();
207 mwindow->gui->update(0, NORMAL_DRAW,
209 mwindow->update_plugin_guis();
210 mwindow->restart_brender();
211 mwindow->sync_parameters(CHANGE_EDL);
216 KeyframePopupHide::KeyframePopupHide(MWindow *mwindow, KeyframePopup *popup)
217 : BC_MenuItem(_("Hide keyframe type"))
219 this->mwindow = mwindow;
223 KeyframePopupHide::~KeyframePopupHide()
227 int KeyframePopupHide::handle_event()
229 if( popup->keyframe_autos )
230 mwindow->set_auto_visibility(popup->keyframe_autos, 0);
234 KeyframePopupShow::KeyframePopupShow(MWindow *mwindow, KeyframePopup *popup)
235 : BC_MenuItem(_("Show keyframe settings"))
237 this->mwindow = mwindow;
241 KeyframePopupShow::~KeyframePopupShow()
245 int KeyframePopupShow::handle_event()
247 MWindowGUI *mgui = mwindow->gui;
248 CWindowGUI *cgui = mwindow->cwindow->gui;
249 int cx = popup->popx, cy = popup->popy;
250 int xmargin = mgui->get_w() - xS(200);
251 int ymargin = mgui->get_h() - yS(50);
252 if( cx > xmargin ) cx = xmargin;
253 if( cy > ymargin ) cy = ymargin;
254 xmargin = xS(15); ymargin = yS(15);
255 if( cx < xmargin ) cx = xmargin;
256 if( cy < ymargin ) cy = ymargin;
257 mgui->close_keyvalue_popup();
259 if( popup->keyframe_plugin ) {
260 mwindow->update_plugin_guis();
261 mwindow->show_plugin(popup->keyframe_plugin);
263 else if( popup->keyframe_automation ) {
267 switch( popup->keyframe_autos->autoidx ) {
268 case AUTOMATION_CAMERA_X:
269 case AUTOMATION_CAMERA_Y:
270 case AUTOMATION_CAMERA_Z: {
271 cgui->set_operation(CWINDOW_CAMERA);
274 case AUTOMATION_PROJECTOR_X:
275 case AUTOMATION_PROJECTOR_Y:
276 case AUTOMATION_PROJECTOR_Z: {
277 cgui->set_operation(CWINDOW_PROJECTOR);
280 case AUTOMATION_MASK: {
281 cgui->set_operation(CWINDOW_MASK);
286 PatchGUI *patchgui = mwindow->get_patchgui(popup->keyframe_automation->track);
287 if( !patchgui ) break;
289 switch( popup->keyframe_autos->autoidx ) {
290 case AUTOMATION_MODE: {
291 VKeyModePatch *mode = new VKeyModePatch(mwindow, (VPatchGUI *)patchgui);
292 mgui->add_subwindow(mode);
293 mode->create_objects();
294 mode->activate_menu();
295 mgui->open_keyvalue_popup(mode);
298 case AUTOMATION_PAN: {
299 AKeyPanPatch *pan = new AKeyPanPatch(mwindow, (APatchGUI *)patchgui);
300 mgui->add_subwindow(pan);
301 pan->create_objects();
302 pan->activate(cx, cy);
303 mgui->open_keyvalue_popup(pan);
306 case AUTOMATION_FADE: {
307 FloatAuto *fade_auto = mwindow->get_float_auto(patchgui, AUTOMATION_FADE);
308 int bump = fade_auto->is_bump();
309 switch( patchgui->data_type ) {
311 AKeyFadePatch *fade = new AKeyFadePatch(mwindow,
312 (APatchGUI *)patchgui, bump, cx, cy);
313 mgui->add_subwindow(fade);
314 fade->create_objects();
315 mgui->open_keyvalue_popup(fade);
318 VKeyFadePatch *fade = new VKeyFadePatch(mwindow,
319 (VPatchGUI *)patchgui, bump, cx, cy);
320 mgui->add_subwindow(fade);
321 fade->create_objects();
322 mgui->open_keyvalue_popup(fade);
327 case AUTOMATION_SPEED: {
328 FloatAuto *speed_auto = mwindow->get_float_auto(patchgui, AUTOMATION_SPEED);
329 int bump = speed_auto->is_bump();
330 KeySpeedPatch *speed = new KeySpeedPatch(mwindow, patchgui, bump, cx, cy);
331 mgui->add_subwindow(speed);
332 speed->create_objects();
333 mgui->open_keyvalue_popup(speed);
336 case AUTOMATION_MUTE: {
337 KeyMutePatch *mute = new KeyMutePatch(mwindow, (APatchGUI *)patchgui, cx, cy);
338 mgui->add_subwindow(mute);
339 mute->create_objects();
340 mgui->open_keyvalue_popup(mute);
346 // ensure bringing to front
348 mwindow->show_cwindow();
349 CPanelToolWindow *panel_tool_window =
350 (CPanelToolWindow *)cgui->composite_panel->operation[CWINDOW_TOOL_WINDOW];
351 panel_tool_window->set_shown(0);
352 panel_tool_window->set_shown(1);
354 cgui->unlock_window();
361 KeyframePopupCopy::KeyframePopupCopy(MWindow *mwindow, KeyframePopup *popup)
362 : BC_MenuItem(_("Copy keyframe"))
364 this->mwindow = mwindow;
368 KeyframePopupCopy::~KeyframePopupCopy()
372 int KeyframePopupCopy::handle_event()
376 we want to copy just keyframe under cursor, NOT all keyframes at this frame
377 - very hard to do, so this is good approximation for now...
381 if (popup->keyframe_automation)
384 EDL *edl = mwindow->edl;
385 Track *track = popup->keyframe_automation->track;
386 int64_t position = popup->keyframe_auto->position;
388 // first find out type of our auto
390 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->projector_autos)
391 autoconf.projector = 1;
392 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pzoom_autos)
394 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->camera_autos)
396 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->czoom_autos)
398 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mode_autos)
400 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mask_autos)
402 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pan_autos)
404 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->fade_autos)
406 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mute_autos)
410 // now create a clipboard
411 file.tag.set_title("AUTO_CLIPBOARD");
412 file.tag.set_property("LENGTH", 0);
413 file.tag.set_property("FRAMERATE", edl->session->frame_rate);
414 file.tag.set_property("SAMPLERATE", edl->session->sample_rate);
416 file.append_newline();
417 file.append_newline();
419 /* track->copy_automation(position,
425 file.tag.set_title("TRACK");
427 track->save_header(&file);
429 file.append_newline();
431 track->automation->copy(position,
437 file.tag.set_title("/TRACK");
439 file.append_newline();
440 file.append_newline();
441 file.append_newline();
442 file.append_newline();
444 file.tag.set_title("/AUTO_CLIPBOARD");
446 file.append_newline();
447 file.terminate_string();
449 mwindow->gui->lock_window();
450 mwindow->gui->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
451 mwindow->gui->unlock_window();
455 mwindow->copy_automation();
461 KeyframePopupCurveMode::KeyframePopupCurveMode(
463 KeyframePopup *popup,
465 : BC_MenuItem( get_labeltext(curve_mode))
467 this->curve_mode = curve_mode;
468 this->mwindow = mwindow;
472 KeyframePopupCurveMode::~KeyframePopupCurveMode() { }
475 const char *KeyframePopupCurveMode::get_labeltext(int mode)
478 case FloatAuto::SMOOTH: return _("smooth curve");
479 case FloatAuto::LINEAR: return _("linear segments");
480 case FloatAuto::TFREE: return _("tangent edit");
481 case FloatAuto::FREE: return _("disjoint edit");
482 case FloatAuto::BUMP: return _("bump edit");
484 return _("misconfigured");
488 void KeyframePopupCurveMode::toggle_mode(FloatAuto *keyframe)
490 set_checked(curve_mode == keyframe->curve_mode);
494 int KeyframePopupCurveMode::handle_event()
496 if (popup->keyframe_autos &&
497 popup->keyframe_autos->get_type() == AUTOMATION_TYPE_FLOAT)
499 mwindow->undo->update_undo_before(_("change keyframe curve mode"), 0);
500 ((FloatAuto*)popup->keyframe_auto)->
501 change_curve_mode((FloatAuto::t_mode)curve_mode);
503 // if we switched to some "auto" mode, this may imply a
504 // real change to parameters, so this needs to be undoable...
505 mwindow->undo->update_undo_after(_("change keyframe curve mode"), LOAD_ALL);
506 mwindow->save_backup();
508 mwindow->gui->update(0, NORMAL_DRAW, 0,0,0,0,0); // incremental redraw for canvas
509 mwindow->cwindow->update(0,0, 1, 0,0); // redraw tool window in compositor
510 mwindow->update_plugin_guis();
511 mwindow->restart_brender();
512 mwindow->sync_parameters(CHANGE_EDL);
518 KeyframePopupEdit::KeyframePopupEdit(MWindow *mwindow, KeyframePopup *popup)
519 : BC_MenuItem(_("Edit Params..."))
521 this->mwindow = mwindow;
525 int KeyframePopupEdit::handle_event()
527 mwindow->show_keyframe_gui(popup->keyframe_plugin);
532 KeyframeHidePopup::KeyframeHidePopup(MWindow *mwindow, MWindowGUI *gui)
533 : BC_PopupMenu(0, 0, 0, "", 0)
535 this->mwindow = mwindow;
537 this->keyframe_autos = 0;
540 KeyframeHidePopup::~KeyframeHidePopup()
544 void KeyframeHidePopup::create_objects()
546 add_item(new KeyframeHideItem(mwindow, this));
549 int KeyframeHidePopup::update(Autos *autos)
551 this->keyframe_autos = autos;
555 KeyframeHideItem::KeyframeHideItem(MWindow *mwindow, KeyframeHidePopup *popup)
556 : BC_MenuItem(_("Hide keyframe type"))
558 this->mwindow = mwindow;
563 int KeyframeHideItem::handle_event()
565 if( popup->keyframe_autos )
566 mwindow->set_auto_visibility(popup->keyframe_autos, 0);
572 KeyMutePatch::KeyMutePatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
573 : BC_SubWindow(x, y, 100, 20, GWindowGUI::auto_colors[AUTOMATION_MUTE])
575 this->mwindow = mwindow;
579 void KeyMutePatch::create_objects()
581 key_mute_checkbox = new KeyMuteValue(this);
582 add_subwindow(key_mute_checkbox);
583 key_mute_checkbox->activate();
587 KeyMuteValue::KeyMuteValue(KeyMutePatch *key_mute_patch)
588 : BC_CheckBox(0,0, key_mute_patch->mwindow->
589 get_int_auto(key_mute_patch->patch, AUTOMATION_MUTE)->value,
590 _("Mute"), MEDIUMFONT, RED)
592 this->key_mute_patch = key_mute_patch;
595 int KeyMuteValue::button_release_event()
597 BC_CheckBox::button_release_event();
598 key_mute_patch->mwindow->gui->close_keyvalue_popup();
602 int KeyMuteValue::handle_event()
604 MWindow *mwindow = key_mute_patch->mwindow;
605 PatchGUI *patch = key_mute_patch->patch;
607 patch->change_source = 1;
608 double position = mwindow->edl->local_session->get_selectionstart(1);
609 Autos *mute_autos = patch->track->automation->autos[AUTOMATION_MUTE];
610 int need_undo = !mute_autos->auto_exists_for_editing(position);
611 mwindow->undo->update_undo_before(_("mute"), need_undo ? 0 : this);
612 IntAuto *current = (IntAuto*)mute_autos->get_auto_for_editing(position);
613 current->value = this->get_value();
614 mwindow->undo->update_undo_after(_("mute"), LOAD_AUTOMATION);
615 patch->change_source = 0;
617 mwindow->sync_parameters(CHANGE_PARAMS);
618 if( mwindow->edl->session->auto_conf->autos[AUTOMATION_MUTE] ) {
619 mwindow->gui->update_patchbay();
620 mwindow->gui->draw_overlays(1);
625 KeySpeedPatch::KeySpeedPatch(MWindow *mwindow, PatchGUI *gui,
626 int bump, int x, int y)
627 : BC_SubWindow(x,y, xS(200)+4, yS(bump ? 50 : 24)+4,
628 GWindowGUI::auto_colors[AUTOMATION_SPEED])
630 this->mwindow = mwindow;
633 KeySpeedPatch::~KeySpeedPatch()
637 void KeySpeedPatch::create_objects()
639 int x = 2, x1 = x, y = 2, dy = 0;
640 FloatAuto *speed_auto = mwindow->get_float_auto(gui, AUTOMATION_SPEED);
641 float v = speed_auto->get_value(gui->edge);
642 add_subwindow(key_speed_text = new KeySpeedText(this, x, y, xS(64), v));
643 x += key_speed_text->get_w();
644 dy = bmax(dy, key_speed_text->get_h());
645 VFrame **lok_images = mwindow->theme->get_image_set("lok");
646 int w1 = get_w()-2 - x - lok_images[0]->get_w();
647 add_subwindow(key_speed_slider = new KeySpeedSlider(this, x, y, w1, v));
648 x += key_speed_slider->get_w();
649 dy = bmax(dy, key_speed_slider->get_h());
650 add_subwindow(key_speed_ok = new KeySpeedOK(this, x, y, lok_images));
651 dy = bmax(dy, key_speed_ok->get_h());
652 if( speed_auto->is_bump() ) {
654 set_color(get_resources()->get_bg_color());
655 draw_box(0,y, get_w(),get_h());
656 add_subwindow(auto_edge = new KeySpeedAutoEdge(mwindow, this, x1, y));
657 x1 += auto_edge->get_w() + xS(15);
658 add_subwindow(auto_span = new KeySpeedAutoSpan(mwindow, this, x1, y));
660 draw_3d_border(0,0, get_w(), get_h(), 0);
663 mwindow->speed_before();
666 void KeySpeedPatch::set_edge(int edge)
669 FloatAuto *speed_auto = mwindow->get_float_auto(gui, AUTOMATION_SPEED);
670 float v = speed_auto->get_value(edge);
674 void KeySpeedPatch::set_span(int span)
679 void KeySpeedPatch::update(float v)
681 key_speed_text->update(v);
682 key_speed_slider->update(v);
686 void KeySpeedPatch::update_speed(float v)
688 Track *track = gui->track;
689 if( !track->is_armed() ) return;
690 Autos *speed_autos = track->automation->autos[AUTOMATION_SPEED];
691 double position = mwindow->edl->local_session->get_selectionstart(1);
692 FloatAuto *current = (FloatAuto*)speed_autos->get_auto_for_editing(position);
693 float change = v - current->get_value(gui->edge);
694 if( !change ) return;
695 gui->change_source = 1;
696 int need_undo = !speed_autos->auto_exists_for_editing(position);
697 mwindow->undo->update_undo_before(_("speed"), need_undo ? 0 : this);
698 current->bump_value(v, gui->edge, gui->span);
699 if( track->is_ganged() ) {
700 TrackCanvas *track_canvas = gui->patchbay->pane->canvas;
701 track_canvas->fill_ganged_autos(-1, change, track, current);
702 track_canvas->update_ganged_autos(0, track, current);
703 track_canvas->clear_ganged_autos();
705 mwindow->undo->update_undo_after(_("speed"),
706 LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
707 gui->change_source = 0;
709 mwindow->sync_parameters(CHANGE_PARAMS);
710 if(mwindow->edl->session->auto_conf->autos[AUTOMATION_SPEED]) {
711 mwindow->gui->draw_overlays(1);
715 KeySpeedOK::KeySpeedOK(KeySpeedPatch *key_speed_patch, int x, int y, VFrame **images)
716 : BC_Button(x, y, images)
718 this->key_speed_patch = key_speed_patch;
721 int KeySpeedOK::handle_event()
723 MWindow *mwindow = key_speed_patch->mwindow;
724 mwindow->speed_after(1);
725 mwindow->resync_guis();
726 mwindow->gui->close_keyvalue_popup();
730 KeySpeedText::KeySpeedText(KeySpeedPatch *key_speed_patch, int x, int y, int w, float v)
731 : BC_TextBox(x, y, w, 1, v, 1, MEDIUMFONT, 2)
733 this->key_speed_patch = key_speed_patch;
736 int KeySpeedText::handle_event()
738 float v = atof(get_text());
739 key_speed_patch->update(v);
740 return get_keypress() != RETURN ? 1 :
741 key_speed_patch->key_speed_ok->handle_event();
744 KeySpeedSlider::KeySpeedSlider(KeySpeedPatch *key_speed_patch,
745 int x, int y, int w, float v)
746 : BC_FSlider(x, y, 0, w, w,
747 key_speed_patch->mwindow->edl->local_session->automation_mins[AUTOGROUPTYPE_SPEED],
748 key_speed_patch->mwindow->edl->local_session->automation_maxs[AUTOGROUPTYPE_SPEED],
751 this->key_speed_patch = key_speed_patch;
752 key_speed_patch->mwindow->speed_before();
756 KeySpeedSlider::~KeySpeedSlider()
760 int KeySpeedSlider::handle_event()
764 set_tooltip(get_caption());
766 key_speed_patch->update(get_value());
770 KeySpeedAutoEdge::KeySpeedAutoEdge(MWindow *mwindow,
771 KeySpeedPatch *patch, int x, int y)
772 : BC_Toggle(x, y, mwindow->theme->get_image_set("bump_edge"),
773 patch->gui->edge,_("Edge"))
775 this->mwindow = mwindow;
777 set_tooltip(_("Bump uses left edge"));
780 int KeySpeedAutoEdge::handle_event()
782 patch->set_edge(get_value());
786 KeySpeedAutoSpan::KeySpeedAutoSpan(MWindow *mwindow,
787 KeySpeedPatch *patch, int x, int y)
788 : BC_Toggle(x, y, mwindow->theme->get_image_set("bump_span"),
789 patch->gui->span,_("Span"))
791 this->mwindow = mwindow;
793 set_tooltip(_("Bump spans to next"));
796 int KeySpeedAutoSpan::handle_event()
799 patch->set_span(get_value());