X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fgraphic%2Fgraphic.C;h=3fb5c066538f165e475eb8e4078879cd90f64ed7;hp=ad2eae77d9dca3fc2d0c18390c559a5b3c513253;hb=b104b77f5296719bd5e6de8472eb71542ddaedec;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/plugins/graphic/graphic.C b/cinelerra-5.1/plugins/graphic/graphic.C index ad2eae77..3fb5c066 100644 --- a/cinelerra-5.1/plugins/graphic/graphic.C +++ b/cinelerra-5.1/plugins/graphic/graphic.C @@ -40,10 +40,10 @@ // Canvas parameters #define MAJOR_DIVISIONS 7 #define MINOR_DIVISIONS 5 -#define LINE_W4 12 -#define LINE_W3 10 -#define LINE_W2 5 -#define LINE_W1 2 +#define LINE_W4 xS(12) +#define LINE_W3 xS(10) +#define LINE_W2 xS(5) +#define LINE_W1 xS(2) @@ -227,7 +227,7 @@ int GraphicCanvas::button_release_event() return 0; } -#define BOX_SIZE 10 +#define BOX_SIZE xS(10) int GraphicCanvas::freq_to_y(int freq, ArrayList *points, @@ -320,29 +320,15 @@ void GraphicCanvas::process(int buttonpress, int motion, int draw) if(draw) { clear_box(0, 0, get_w(), get_h()); - - int niquist = plugin->PluginAClient::project_sample_rate / 2; - int total_frames = plugin->get_gui_update_frames(); - GraphicGUIFrame *frame = (GraphicGUIFrame*)plugin->get_gui_frame(); - - if(frame) - { - delete plugin->last_frame; - plugin->last_frame = frame; - } - else - { - frame = plugin->last_frame; - } -// Draw most recent frame - if(frame) - { +// delete frames up to current tracking position + double tracking_position = plugin->get_tracking_position(); + GraphicGUIFrame *frame = (GraphicGUIFrame *) + plugin->get_gui_frame(tracking_position, 1); + if( frame ) { + int y1 = 0, y2 = 0; set_color(MEGREY); - int y1 = 0; - int y2 = 0; - for(int i = 0; i < get_w(); i++) { @@ -366,23 +352,7 @@ void GraphicCanvas::process(int buttonpress, int motion, int draw) y1 = y2; } } -//printf( "\n"); - - total_frames--; - } - - - - - - -// Delete remaining frames - while(total_frames > 0) - { - PluginClientFrame *frame = plugin->get_gui_frame(); - - if(frame) delete frame; - total_frames--; + delete frame; } } @@ -699,7 +669,7 @@ int GraphicReset::handle_event() GraphicSize::GraphicSize(GraphicGUI *window, GraphicEQ *plugin, int x, int y) - : BC_PopupMenu(x, y, 100, "4096", 1) + : BC_PopupMenu(x, y, xS(120), "4096", 1) { this->plugin = plugin; this->window = window; @@ -766,8 +736,8 @@ GraphicGUI::GraphicGUI(GraphicEQ *plugin) : PluginClientWindow(plugin, plugin->w, plugin->h, - 320, - 200, + xS(320), + yS(200), 1) { this->plugin = plugin; @@ -802,12 +772,12 @@ void GraphicGUI::create_objects() // int y1 = y; add_subwindow(freq_title = new BC_Title(x, y, _("Frequency:"))); x += freq_title->get_w() + margin; - add_subwindow(freq_text = new FreqTextBox(plugin, this, x, y, 100)); + add_subwindow(freq_text = new FreqTextBox(plugin, this, x, y, xS(100))); x += freq_text->get_w() + margin; add_subwindow(level_title = new BC_Title(x, y, _("Level:"))); x += level_title->get_w() + margin; - add_subwindow(value_text = new ValueTextBox(plugin, this, x, y, 100)); + add_subwindow(value_text = new ValueTextBox(plugin, this, x, y, xS(100))); x += value_text->get_w() + margin; add_subwindow(reset = new GraphicReset(plugin, this, x, y)); @@ -902,7 +872,7 @@ int GraphicGUI::keypress_event() } } } - return 0; + return context_help_check_and_show(); } @@ -1007,23 +977,6 @@ void GraphicGUI::update_textboxes() } - - - - - - - - - - - - - - - - - GraphicEQ::GraphicEQ(PluginServer *server) : PluginAClient(server) { @@ -1031,8 +984,8 @@ GraphicEQ::GraphicEQ(PluginServer *server) fft = 0; need_reconfigure = 1; active_point = -1; - w = 640; - h = 480; + w = xS(640); + h = yS(480); } GraphicEQ::~GraphicEQ() @@ -1066,32 +1019,21 @@ void GraphicEQ::read_data(KeyFrame *keyframe) input.set_shared_input(keyframe->xbuf); config.points.remove_all_objects(); - while(!result) - { - result = input.read_tag(); - - if(!result) - { - if(input.tag.title_is("GRAPHICEQ")) - { - config.window_size = input.tag.get_property("WINDOW_SIZE", config.window_size); - if(is_defaults()) - { - w = input.tag.get_property("W", w); - h = input.tag.get_property("H", h); - } - } - else - if(input.tag.title_is("POINT")) - { - GraphicPoint *point; - config.points.append(point = new GraphicPoint); - point->freq = input.tag.get_property("X", 0); - point->value = input.tag.get_property("Y", 0.0); + while( !(result = input.read_tag()) ) { + if(input.tag.title_is("GRAPHICEQ")) { + config.window_size = input.tag.get_property("WINDOW_SIZE", config.window_size); + if(is_defaults()) { + w = input.tag.get_property("W", w); + h = input.tag.get_property("H", h); } } + else if(input.tag.title_is("POINT")) { + GraphicPoint *point; + config.points.append(point = new GraphicPoint); + point->freq = input.tag.get_property("X", 0); + point->value = input.tag.get_property("Y", 0.0); + } } - // if(!active_point_exists()) active_point = -1; } @@ -1112,8 +1054,7 @@ void GraphicEQ::save_data(KeyFrame *keyframe) output.append_tag(); output.append_newline(); - for(int i = 0; i < config.points.total; i++) - { + for(int i = 0; i < config.points.total; i++) { output.tag.set_title("POINT"); output.tag.set_property("X", config.points.values[i]->freq); output.tag.set_property("Y", config.points.values[i]->value); @@ -1131,41 +1072,35 @@ void GraphicEQ::update_gui() { if( !thread ) return; GraphicGUI *window = (GraphicGUI *)thread->window; + window->lock_window("GraphicEQ::update_gui"); //lock here for points, needed by window cursor_motion callback // deleted in load_configuration by read_data - window->lock_window("GraphicEQ::update_gui"); if( load_configuration() && window->canvas->state != GraphicCanvas::DRAG_POINT ) { window->update_canvas(); window->update_textboxes(); } - else { - int total_frames = get_gui_update_frames(); -//printf("ParametricEQ::update_gui %d %d\n", __LINE__, total_frames); - if( total_frames ) - window->update_canvas(); + else if( pending_gui_frame() ) { + window->update_canvas(); } window->unlock_window(); } void GraphicEQ::reconfigure() { - if(fft && fft->window_size != config.window_size) - { + if(fft && fft->window_size != config.window_size) { delete fft; fft = 0; } - if(!fft) - { + if(!fft) { fft = new GraphicFFT(this); fft->initialize(config.window_size); } calculate_envelope(&config.points, envelope); - for(int i = 0; i < config.window_size / 2; i++) - { + for(int i = 0; i < config.window_size / 2; i++) { if(envelope[i] < 0) envelope[i] = 0; } @@ -1299,15 +1234,14 @@ void GraphicEQ::calculate_envelope(ArrayList *points, } - - GraphicGUIFrame::GraphicGUIFrame(int window_size, int sample_rate) - : PluginClientFrame(window_size / 2, window_size / 2, sample_rate) + : PluginClientFrame() { - data = new double[window_size / 2]; + this->window_size = window_size; + data_size = window_size / 2; + data = new double[data_size]; freq_max = 0; time_max = 0; - this->window_size = window_size; } GraphicGUIFrame::~GraphicGUIFrame() @@ -1316,10 +1250,6 @@ GraphicGUIFrame::~GraphicGUIFrame() } - - - - GraphicFFT::GraphicFFT(GraphicEQ *plugin) : CrossfadeFFT() {