switch to solid color for edit title bar
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / resourcepixmap.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22
23
24 #include "arender.h"
25 #include "aedit.h"
26 #include "asset.h"
27 #include "asset.inc"
28 #include "automation.h"
29 #include "autos.h"
30 #include "bcsignals.h"
31 #include "cache.h"
32 #include "clip.h"
33 #include "bccmodels.h"
34 #include "datatype.h"
35 #include "edit.h"
36 #include "edits.h"
37 #include "edl.h"
38 #include "edlsession.h"
39 #include "file.h"
40 #include "filesystem.h"
41 #include "floatauto.h"
42 #include "floatautos.h"
43 #include "framecache.h"
44 #include "indexfile.h"
45 #include "language.h"
46 #include "localsession.h"
47 #include "mwindow.h"
48 #include "mwindowgui.h"
49 #include "preferences.h"
50 #include "renderengine.h"
51 #include "resourcethread.h"
52 #include "resourcepixmap.h"
53 #include "samples.h"
54 #include "theme.h"
55 #include "timelinepane.h"
56 #include "track.h"
57 #include "trackcanvas.h"
58 #include "transportque.h"
59 #include "vedit.h"
60 #include "vframe.h"
61 #include "wavecache.h"
62
63
64 ResourcePixmap::ResourcePixmap(MWindow *mwindow,
65         MWindowGUI *gui,
66         Edit *edit,
67         int pane_number,
68         int w,
69         int h)
70  : BC_Pixmap(gui, w, h)
71 {
72         reset();
73
74         this->mwindow = mwindow;
75         this->gui = gui;
76         this->pane_number = pane_number;
77         startsource = edit->startsource;
78         data_type = edit->track->data_type;
79         if( edit->asset ) {
80                 source_framerate = edit->asset->frame_rate;
81                 source_samplerate = edit->asset->sample_rate;
82         }
83         else
84         if( edit->nested_edl ) {
85                 source_framerate = edit->nested_edl->session->frame_rate;
86                 source_samplerate = edit->nested_edl->session->sample_rate;
87         }
88
89         project_framerate = edit->edl->session->frame_rate;
90         project_samplerate = edit->edl->session->sample_rate;
91         edit_id = edit->id;  pixmap_w = w;  pixmap_h = h;
92 }
93
94 ResourcePixmap::~ResourcePixmap()
95 {
96 }
97
98
99 void ResourcePixmap::reset()
100 {
101         edit_x = 0;
102         pixmap_x = 0;
103         pixmap_w = 0;
104         pixmap_h = 0;
105         zoom_sample = 0;
106         zoom_track = 0;
107         zoom_y = 0;
108         visible = 1;
109 }
110
111 void ResourcePixmap::resize(int w, int h)
112 {
113         int new_w = (w > get_w()) ? w : get_w();
114         int new_h = (h > get_h()) ? h : get_h();
115
116         BC_Pixmap::resize(new_w, new_h);
117 }
118
119 void ResourcePixmap::update_settings(Edit *edit,
120         int64_t edit_x, int64_t edit_w,
121         int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h)
122 {
123         this->edit_id = edit->id;
124         this->edit_x = edit_x;
125         this->pixmap_x = pixmap_x;
126         this->pixmap_w = pixmap_w;
127         this->pixmap_h = pixmap_h;
128
129         startsource = edit->startsource;
130         if( edit->asset )
131                 source_framerate = edit->asset->frame_rate;
132         else
133         if( edit->nested_edl )
134                 source_framerate = edit->nested_edl->session->frame_rate;
135         if( edit->asset )
136                 source_samplerate = edit->asset->sample_rate;
137         else if( edit->nested_edl )
138                 source_samplerate = edit->nested_edl->session->sample_rate;
139
140         project_framerate = edit->edl->session->frame_rate;
141         project_samplerate = edit->edl->session->sample_rate;
142         zoom_sample = mwindow->edl->local_session->zoom_sample;
143         zoom_track = mwindow->edl->local_session->zoom_track;
144         zoom_y = mwindow->edl->local_session->zoom_y;
145 }
146
147 void ResourcePixmap::draw_data(TrackCanvas *canvas,
148         Edit *edit, int64_t edit_x, int64_t edit_w,
149         int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h,
150         int mode, int indexes_only)
151 {
152 // Get new areas to fill in relative to pixmap
153 // Area to redraw relative to pixmap
154         int refresh_x = 0;
155         int refresh_w = 0;
156
157 // Ignore if called by resourcethread.
158 //      if( mode == IGNORE_THREAD ) return;
159
160         int y = 0;
161         if( edit->track->show_titles() )
162                 y += mwindow->theme->get_image("title_bg_data")->get_h();
163
164 // If want indexes only & index can't be drawn, don't do anything.
165         int need_redraw = 0;
166         int64_t index_zoom = 0;
167         Indexable *indexable = 0;
168         if( edit->asset ) indexable = edit->asset;
169         if( edit->nested_edl ) indexable = edit->nested_edl;
170         if( indexable && indexes_only ) {
171                 IndexFile indexfile(mwindow, indexable);
172                 if( !indexfile.open_index() ) {
173                         index_zoom = indexable->index_state->index_zoom;
174                         indexfile.close_index();
175                 }
176
177                 if( index_zoom ) {
178                         if( data_type == TRACK_AUDIO ) {
179                                 double asset_over_session = (double)indexable->get_sample_rate() /
180                                         mwindow->edl->session->sample_rate;
181                                 if( index_zoom <= mwindow->edl->local_session->zoom_sample *
182                                         asset_over_session )
183                                         need_redraw = 1;
184                         }
185                 }
186
187                 if( !need_redraw )
188                         return;
189         }
190
191 /* Incremental drawing is not possible with resource thread */
192 // Redraw everything
193         refresh_x = 0;
194         refresh_w = pixmap_w;
195
196 // Draw background image
197         if( refresh_w > 0 )
198                 mwindow->theme->draw_resource_bg(canvas,
199                         this,
200                         edit_x,
201                         edit_w,
202                         pixmap_x,
203                         refresh_x,
204                         y,
205                         refresh_x + refresh_w,
206                         mwindow->edl->local_session->zoom_track + y);
207 //printf("ResourcePixmap::draw_data 70\n");
208
209
210 // Draw media which already exists
211         Track *track = edit->track;
212         if( track->draw ) {
213                 switch( track->data_type )
214                 {
215                         case TRACK_AUDIO:
216                                 draw_audio_resource(canvas,
217                                         edit,
218                                         refresh_x,
219                                         refresh_w);
220                                 break;
221
222                         case TRACK_VIDEO:
223                                 draw_video_resource(canvas,
224                                         edit,
225                                         edit_x,
226                                         edit_w,
227                                         pixmap_x,
228                                         pixmap_w,
229                                         refresh_x,
230                                         refresh_w,
231                                         mode);
232                                 break;
233
234                         case TRACK_SUBTITLE:
235                                 draw_subttl_resource(canvas,
236                                         edit,
237                                         refresh_x,
238                                         refresh_w);
239                                 break;
240                 }
241         }
242 SET_TRACE
243 }
244
245
246 VFrame *ResourcePixmap::change_title_color(VFrame *title_bg, int color)
247 {
248         if( color < 0 ) return title_bg;
249         int colormodel = title_bg->get_color_model();
250         int bpp = BC_CModels::calculate_pixelsize(colormodel);
251         int tw = title_bg->get_w(), th = title_bg->get_h();
252         VFrame *title_bar = new VFrame(tw, th, colormodel);
253         uint8_t cr = (color>>16), cg = (color>>8), cb = (color>>0);
254         uint8_t **bar_rows = title_bar->get_rows();
255         for( int y=0; y<th; ++y ) {
256                 uint8_t *cp = bar_rows[y];
257                 for( int x=0; x<tw; ++x ) {
258                         cp[0] = cr; cp[1] = cg; cp[2] = cb;
259                         if( bpp > 3 ) cp[3] = 0xff;
260                         cp += bpp;
261                 }
262         }
263         return title_bar;
264 }
265
266 void ResourcePixmap::draw_title(TrackCanvas *canvas,
267         Edit *edit, int64_t edit_x, int64_t edit_w,
268         int64_t pixmap_x, int64_t pixmap_w)
269 {
270 // coords relative to pixmap
271         int64_t total_x = edit_x - pixmap_x, total_w = edit_w;
272         int64_t x = total_x, w = total_w;
273         int left_margin = 10;
274
275         if( x < 0 ) { w -= -x; x = 0; }
276         if( w > pixmap_w ) w -= w - pixmap_w;
277
278         VFrame *title_bg = mwindow->theme->get_image("title_bg_data");
279         int color = mwindow->get_title_color(edit);
280         VFrame *title_bar = color < 0 ? title_bg :
281                 change_title_color(title_bg, color);
282         canvas->draw_3segmenth(x, 0, w, total_x, total_w, title_bar, this);
283         if( title_bar != title_bg ) delete title_bar;
284
285 //      if( total_x > -BC_INFINITY ) {
286                 char title[BCTEXTLEN];
287                 edit->get_title(title);
288                 canvas->set_color(mwindow->theme->title_color);
289                 canvas->set_font(mwindow->theme->title_font);
290
291 // Justify the text on the left boundary of the edit if it is visible.
292 // Otherwise justify it on the left side of the screen.
293                 int text_x = total_x + left_margin;
294                 text_x = MAX(left_margin, text_x);
295 //printf("ResourcePixmap::draw_title 1 %d\n", text_x);
296                 canvas->draw_text(text_x,
297                         canvas->get_text_ascent(mwindow->theme->title_font) + 2,
298                         title, strlen(title), this);
299 //      }
300 }
301
302
303 // Need to draw one more x
304 void ResourcePixmap::draw_audio_resource(TrackCanvas *canvas, Edit *edit, int x, int w)
305 {
306         if( w <= 0 ) return;
307         if( !edit->asset && !edit->nested_edl ) return;
308         Indexable *indexable = 0;
309         if( edit->asset ) indexable = edit->asset;
310         if( edit->nested_edl ) indexable = edit->nested_edl;
311 // printf("ResourcePixmap::draw_audio_resource %d x=%d w=%d\n", __LINE__, x, w);
312 SET_TRACE
313
314         IndexState *index_state = indexable->index_state;
315         double asset_over_session = (double)indexable->get_sample_rate() /
316                 mwindow->edl->session->sample_rate;
317
318 // Develop strategy for drawing
319 // printf("ResourcePixmap::draw_audio_resource %d %p %d\n",
320 // __LINE__,
321 // index_state,
322 // index_state->index_status);
323         switch( index_state->index_status )
324         {
325                 case INDEX_NOTTESTED:
326                         return;
327                         break;
328 // Disabled.  All files have an index.
329 //              case INDEX_TOOSMALL:
330 //                      draw_audio_source(canvas, edit, x, w);
331 //                      break;
332                 case INDEX_BUILDING:
333                 case INDEX_READY:
334                 {
335                         IndexFile indexfile(mwindow, indexable);
336                         if( !indexfile.open_index() ) {
337                                 if( index_state->index_zoom >
338                                                 mwindow->edl->local_session->zoom_sample *
339                                                 asset_over_session ) {
340 //printf("ResourcePixmap::draw_audio_resource %d\n", __LINE__);
341
342                                         draw_audio_source(canvas, edit, x, w);
343                                 }
344                                 else {
345 //printf("ResourcePixmap::draw_audio_resource %d\n", __LINE__);
346                                         indexfile.draw_index(canvas,
347                                                 this,
348                                                 edit,
349                                                 x,
350                                                 w);
351 SET_TRACE
352                                 }
353
354                                 indexfile.close_index();
355 SET_TRACE
356                         }
357                         break;
358                 }
359         }
360 }
361
362
363 void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, int w)
364 {
365         w++;
366         Indexable *indexable = edit->get_source();
367         int center_pixel = mwindow->edl->local_session->zoom_track / 2;
368         if( edit->track->show_titles() )
369                 center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
370         int64_t scale_y = mwindow->edl->local_session->zoom_y;
371         int y_max = center_pixel + scale_y / 2 - 1;
372
373         double project_zoom = mwindow->edl->local_session->zoom_sample;
374         FloatAutos *speed_autos = !edit->track->has_speed() ? 0 :
375                 (FloatAutos *)edit->track->automation->autos[AUTOMATION_SPEED];
376         int64_t edit_position = (x + pixmap_x - edit_x) * project_zoom;
377         int64_t start_position = edit->startsource;
378         start_position += !speed_autos ? edit_position :
379                 speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
380         int64_t end_position = edit->startsource;
381         edit_position = (x + w + pixmap_x - edit_x) * project_zoom;
382         end_position += !speed_autos ? edit_position :
383                 speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
384
385         double session_sample_rate = mwindow->edl->session->sample_rate;
386         double asset_over_session = (double)indexable->get_sample_rate() / session_sample_rate;
387         start_position *= asset_over_session;
388         end_position *= asset_over_session;
389         int sample_size = end_position - start_position;
390         if( sample_size < 0 ) sample_size = 0;
391         int source_samples = sample_size + 1;
392
393 // Single sample zoom
394         if( mwindow->edl->local_session->zoom_sample == 1 ) {
395                 Samples *buffer = 0;
396                 int result = 0;
397                 canvas->set_color(mwindow->theme->audio_color);
398
399                 if( indexable->is_asset ) {
400                         mwindow->gui->unlock_window();
401                         File *source = mwindow->audio_cache->check_out(edit->asset, mwindow->edl);
402                         mwindow->gui->lock_window("draw_audio_source");
403
404                         if( !source ) {
405                                 printf(_("ResourcePixmap::draw_audio_source: failed to check out %s for drawing.\n"), edit->asset->path);
406                                 return;
407                         }
408
409                         source->set_audio_position(start_position);
410                         source->set_channel(edit->channel);
411                         buffer = new Samples(source_samples);
412                         result = source->read_samples(buffer, source_samples);
413                         mwindow->audio_cache->check_in(edit->asset);
414                 }
415                 else {
416                         if( mwindow->gui->render_engine &&
417                                 mwindow->gui->render_engine_id != indexable->id ) {
418                                 delete mwindow->gui->render_engine;
419                                 mwindow->gui->render_engine = 0;
420                         }
421
422                         if( !mwindow->gui->render_engine ) {
423                                 TransportCommand command;
424                                 command.command = NORMAL_FWD;
425                                 command.get_edl()->copy_all(edit->nested_edl);
426                                 command.change_type = CHANGE_ALL;
427                                 command.realtime = 0;
428                                 mwindow->gui->render_engine = new RenderEngine(0,
429                                         mwindow->preferences, 0, 0);
430                                 mwindow->gui->render_engine_id = edit->nested_edl->id;
431                                 mwindow->gui->render_engine->set_acache(mwindow->audio_cache);
432                                 mwindow->gui->render_engine->arm_command(&command);
433                         }
434
435                         if( mwindow->gui->render_engine->arender ) {
436                                 Samples *buffers[MAX_CHANNELS];
437                                 memset(buffers, 0, sizeof(buffers));
438                                 int nch = indexable->get_audio_channels(), ch = edit->channel;
439                                 for( int i=0; i<nch; ++i )
440                                         buffers[i] = new Samples(source_samples);
441                                 mwindow->gui->render_engine->arender->process_buffer(
442                                         buffers, source_samples, start_position);
443                                 for( int i=0; i<nch; ++i )
444                                         if( i != ch ) delete buffers[i];
445                                 buffer = buffers[ch];
446                         }
447                 }
448
449                 if( !result ) {
450                         double *samples = buffer->get_data();
451                         int y1 = center_pixel - samples[0] * scale_y / 2;
452                         int y2 = CLIP(y1, 0, y_max);
453
454                         for( int x0=0; x0<w; ++x0 ) {
455                                 int x1 = x0 + x, x2 = x1 + 1;
456                                 edit_position = (x1 + pixmap_x - edit_x) * project_zoom;
457                                 int64_t speed_position = edit->startsource;
458                                 speed_position += !speed_autos ? edit_position :
459                                         speed_autos->automation_integral(
460                                                 edit->startproject, edit_position, PLAY_FORWARD);
461                                 int j = speed_position * asset_over_session - start_position;
462                                 CLAMP(j, 0, sample_size);
463                                 int y0 = y2;
464                                 y1 = center_pixel - samples[j] * scale_y / 2;
465                                 y2 = CLIP(y1, 0, y_max);
466 //printf("ResourcePixmap::draw_audio_source %d %d %d\n", __LINE__, y1, y2);
467                                 canvas->draw_line(x0, y0, x2, y2, this);
468                         }
469                 }
470
471                 delete buffer;
472         }
473         else {
474                 edit_position = (x + pixmap_x - edit_x) * project_zoom;
475                 int64_t speed_position = edit->startsource;
476                 speed_position += !speed_autos ? edit_position :
477                         speed_autos->automation_integral(
478                                 edit->startproject, edit_position, PLAY_FORWARD);
479                 int64_t next_position = asset_over_session * speed_position;
480 // Multiple sample zoom
481                 int first_pixel = 1, prev_y1 = -1, prev_y2 = y_max;
482                 canvas->set_color(mwindow->theme->audio_color);
483                 ++x;
484
485 // Draw each pixel from the cache
486 //printf("ResourcePixmap::draw_audio_source %d x=%d w=%d\n", __LINE__, x, w);
487                 for( int x2=x+w; x<x2; ++x ) {
488                         int64_t prev_position = next_position;
489                         edit_position = (x + pixmap_x - edit_x) * project_zoom;
490                         speed_position = edit->startsource;
491                         speed_position += !speed_autos ? edit_position :
492                                 speed_autos->automation_integral(
493                                         edit->startproject, edit_position, PLAY_FORWARD);
494                         next_position = speed_position * asset_over_session;
495 // Starting sample of pixel relative to asset rate.
496                         WaveCacheItem *item = mwindow->wave_cache->get_wave(indexable->id,
497                                         edit->channel, prev_position, next_position);
498                         if( item ) {
499 //printf("ResourcePixmap::draw_audio_source %d\n", __LINE__);
500                                 int y_lo = (int)(center_pixel - item->low * scale_y / 2);
501                                 int y1 = CLIP(y_lo, 0, y_max);
502                                 int y_hi = (int)(center_pixel - item->high * scale_y / 2);
503                                 int y2 = CLIP(y_hi, 0, y_max);
504                                 if( !first_pixel ) {
505                                         y_lo = MIN(y1,prev_y2);
506                                         y_hi = MAX(y2,prev_y1);
507                                 }
508                                 else {
509                                         first_pixel = 0;
510                                         y_lo = y1;  y_hi = y2;
511                                 }
512                                 prev_y1 = y1;  prev_y2 = y2;
513                                 canvas->draw_line(x, y_lo, x, y_hi, this);
514 //printf("ResourcePixmap::draw_audio_source %d %d %d %d\n", __LINE__, x, y1, y2);
515                                 mwindow->wave_cache->unlock();
516                         }
517                         else {
518 //printf("ResourcePixmap::draw_audio_source %d\n", __LINE__);
519                                 gui->resource_thread->add_wave(this,
520                                         canvas->pane->number, indexable, x,
521                                         edit->channel, prev_position, next_position);
522                                 first_pixel = 1;  prev_y1 = -1;  prev_y2 = y_max;
523                         }
524                 }
525         }
526
527         canvas->test_timer();
528 }
529
530 void ResourcePixmap::draw_wave(TrackCanvas *canvas,
531         int x, double high, double low)
532 {
533         int top_pixel = 0;
534         if( mwindow->edl->session->show_titles )
535                 top_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
536         int center_pixel = mwindow->edl->local_session->zoom_track / 2 + top_pixel;
537         int bottom_pixel = top_pixel + mwindow->edl->local_session->zoom_track;
538         int y1 = (int)(center_pixel -
539                 low * mwindow->edl->local_session->zoom_y / 2);
540         int y2 = (int)(center_pixel -
541                 high * mwindow->edl->local_session->zoom_y / 2);
542         CLAMP(y1, top_pixel, bottom_pixel);
543         CLAMP(y2, top_pixel, bottom_pixel);
544         canvas->set_color(mwindow->theme->audio_color);
545         canvas->draw_line(x, y1, x, y2, this);
546 }
547
548
549 void ResourcePixmap::draw_video_resource(TrackCanvas *canvas,
550         Edit *edit, int64_t edit_x, int64_t edit_w, int64_t pixmap_x, int64_t pixmap_w,
551         int refresh_x, int refresh_w, int mode)
552 {
553 //PRINT_TRACE
554 //BC_Signals::dump_stack();
555
556 // pixels spanned by a picon
557         int64_t picon_w = Units::round(edit->picon_w());
558         int64_t picon_h = edit->picon_h();
559 //      if( picon_w <= 0 || picon_w > edit_w ) return;
560 // Don't draw video if picon is empty, or edit only hairline
561         if( picon_w < 1 || edit_w < 2 ) return;
562 // or bigger than edit and fills at less than 1.5 percent timeline
563         if( picon_w > edit_w && edit_w < canvas->get_w()/64 ) return;
564
565 // Frames spanned by a picon
566         double frame_w = edit->frame_w();
567 // pixels spanned by a frame
568         if( frame_w < picon_w ) frame_w = picon_w;
569 // Current pixel relative to pixmap
570         int y = 0;
571         if( edit->track->show_titles() )
572                 y += mwindow->theme->get_image("title_bg_data")->get_h();
573
574 // Frame in project touched by current pixel
575         FloatAutos *speed_autos = !edit->track->has_speed() ? 0 :
576                 (FloatAutos *)edit->track->automation->autos[AUTOMATION_SPEED];
577         Indexable *indexable = edit->get_source();
578         double session_sample_rate = mwindow->edl->session->sample_rate;
579         double project_zoom = mwindow->edl->local_session->zoom_sample / session_sample_rate;
580         int skip_frames = Units::to_int64(((int64_t)refresh_x + pixmap_x - edit_x) / frame_w);
581         int x = Units::to_int64(skip_frames * frame_w) + edit_x - pixmap_x;
582
583 // Draw only cached frames
584         while( x < refresh_x + refresh_w ) {
585                 int64_t edit_position =
586                         edit->track->to_units((x + pixmap_x - edit_x) * project_zoom, 0);
587                 int64_t speed_position = edit->startsource;
588                 speed_position += !speed_autos ? edit_position :
589                          speed_autos->automation_integral(
590                                 edit->startproject, edit_position, PLAY_FORWARD);
591                 VFrame *picon_frame = indexable->id < 0 ? 0 :
592                         mwindow->frame_cache->get_frame_ptr(speed_position, edit->channel,
593                                 mwindow->edl->session->frame_rate, BC_RGB888,
594                                 picon_w, picon_h, indexable->id);
595                 if( picon_frame ) {
596                         draw_vframe(picon_frame, x, y, picon_w, picon_h, 0, 0);
597                         mwindow->frame_cache->unlock();
598                 }
599                 else if( mode != IGNORE_THREAD ) {
600 // Set picon thread to draw in background
601 // printf("ResourcePixmap::draw_video_resource %d %d %lld\n",
602 // __LINE__, mwindow->frame_cache->total(), source_frame);
603                         gui->resource_thread->add_picon(this, canvas->pane->number, x, y,
604                                 picon_w, picon_h, mwindow->edl->session->frame_rate,
605                                 speed_position, edit->channel, indexable);
606                 }
607                 x += frame_w;
608                 canvas->test_timer();
609         }
610 }
611
612 #include "strack.h"
613
614 void ResourcePixmap::draw_subttl_resource(TrackCanvas *canvas, Edit *edit, int x, int w)
615 {
616         SEdit *sedit = (SEdit *)edit;
617         char *text = sedit->get_text();
618         if( !*text || w < 10 ) return;
619         int center_pixel = canvas->resource_h() / 2;
620         if( edit->track->show_titles() )
621                 center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
622         int64_t scale_y = mwindow->edl->local_session->zoom_y;
623         int x0 = edit_x;
624         if( x0 < 0 ) x0 = -x0;
625         int x1 = (int)(pixmap_x - x0 + x);
626         int y_max = center_pixel + scale_y / 2 - 1;
627         int font = MEDIUMFONT, color = WHITE;
628         canvas->set_font(font);
629         canvas->set_color(color);
630         int ch = canvas->get_text_height(font);
631         int hh = canvas->get_text_height(font,text) + ch/2;
632         int y1 = y_max - hh - 10;
633         if( y1 < 0 ) y1 = 0;
634         canvas->draw_text(x1, y1, text, -1, this);
635 }
636
637 void ResourcePixmap::dump()
638 {
639         printf("ResourcePixmap %p\n", this);
640         printf(" edit %jx edit_x %jd pixmap_x %jd pixmap_w %jd visible %d\n",
641                 edit_id, edit_x, pixmap_x, pixmap_w, visible);
642 }
643