switch to solid color for edit title bar
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / resourcepixmap.C
index 2ffd86ca58287ecc74747ca45926331e82f4f38f..eb27656179f97795e7bc18d79c5cc9b533d29f0b 100644 (file)
@@ -46,6 +46,7 @@
 #include "localsession.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
+#include "preferences.h"
 #include "renderengine.h"
 #include "resourcethread.h"
 #include "resourcepixmap.h"
@@ -241,6 +242,27 @@ void ResourcePixmap::draw_data(TrackCanvas *canvas,
 SET_TRACE
 }
 
+
+VFrame *ResourcePixmap::change_title_color(VFrame *title_bg, int color)
+{
+       if( color < 0 ) return title_bg;
+       int colormodel = title_bg->get_color_model();
+       int bpp = BC_CModels::calculate_pixelsize(colormodel);
+       int tw = title_bg->get_w(), th = title_bg->get_h();
+       VFrame *title_bar = new VFrame(tw, th, colormodel);
+       uint8_t cr = (color>>16), cg = (color>>8), cb = (color>>0);
+       uint8_t **bar_rows = title_bar->get_rows();
+       for( int y=0; y<th; ++y ) {
+               uint8_t *cp = bar_rows[y];
+               for( int x=0; x<tw; ++x ) {
+                       cp[0] = cr; cp[1] = cg; cp[2] = cb;
+                       if( bpp > 3 ) cp[3] = 0xff;
+                       cp += bpp;
+               }
+       }
+       return title_bar;
+}
+
 void ResourcePixmap::draw_title(TrackCanvas *canvas,
        Edit *edit, int64_t edit_x, int64_t edit_w,
        int64_t pixmap_x, int64_t pixmap_w)
@@ -253,8 +275,12 @@ void ResourcePixmap::draw_title(TrackCanvas *canvas,
        if( x < 0 ) { w -= -x; x = 0; }
        if( w > pixmap_w ) w -= w - pixmap_w;
 
-       canvas->draw_3segmenth(x, 0, w, total_x, total_w,
-               mwindow->theme->get_image("title_bg_data"), this);
+       VFrame *title_bg = mwindow->theme->get_image("title_bg_data");
+       int color = mwindow->get_title_color(edit);
+       VFrame *title_bar = color < 0 ? title_bg :
+               change_title_color(title_bg, color);
+       canvas->draw_3segmenth(x, 0, w, total_x, total_w, title_bar, this);
+       if( title_bar != title_bg ) delete title_bar;
 
 //     if( total_x > -BC_INFINITY ) {
                char title[BCTEXTLEN];
@@ -334,22 +360,6 @@ SET_TRACE
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, int w)
 {
        w++;