more videoscope layout changes
authorGood Guy <good1.2guy@gmail.com>
Wed, 29 Apr 2020 00:25:43 +0000 (18:25 -0600)
committerGood Guy <good1.2guy@gmail.com>
Wed, 29 Apr 2020 00:25:43 +0000 (18:25 -0600)
cinelerra-5.1/cinelerra/scopewindow.C
cinelerra-5.1/cinelerra/scopewindow.h
cinelerra-5.1/cinelerra/scopewindow.inc
cinelerra-5.1/guicast/bcmenuitem.C
cinelerra-5.1/guicast/bcmenuitem.h

index 283564bc6c4915a9a95320c7082dc820df8e565a..d02a473bf561a8bc96db28991f2d7f1b8b3b8284 100644 (file)
@@ -44,6 +44,7 @@ ScopeUnit::ScopeUnit(ScopeGUI *gui,
        this->gui = gui;
 }
 
+#define SCOPE_SEARCHPATH "/scopes"
 
 #define incr_point(rows,h, iv,comp) { \
 if(iy >= 0 && iy < h) { \
@@ -447,7 +448,7 @@ void ScopeGUI::reset()
        grat_image = 0;
        overlay = 0;
        grat_idx = 0;
-       vect_grats = 0;
+       settings = 0;
 
        output_frame = 0;
        data_frame = 0;
@@ -488,16 +489,13 @@ void ScopeGUI::create_objects()
 
        lock_window("ScopeGUI::create_objects");
        int margin = theme->widget_border;
-       int x = margin;
-       int y = margin;
+       int x = margin, y = margin;
        add_subwindow(scope_menu = new ScopeMenu(this, x, y));
        scope_menu->create_objects();
        int x1 = x + scope_menu->get_w() + 2*margin;
-       add_subwindow(smooth = new ScopeSmooth(this, x1, y));
-       if( use_refresh >= 0 ) {
-               y += smooth->get_h() + margin;
-               add_subwindow(refresh = new ScopeRefresh(this, x, y));
-       }
+       add_subwindow(settings = new ScopeSettings(this, x1, y));
+       settings->create_objects();
+
        create_panels();
        update_toggles();
        show_window();
@@ -509,7 +507,6 @@ void ScopeGUI::create_panels()
 {
        calculate_sizes(get_w(), get_h());
        int slider_w = xS(100);
-       int margin = theme->widget_border;
        if( (use_wave || use_wave_parade) ) {
                int px = wave_x + wave_w - slider_w - xS(5);
                int py = wave_y - ScopeGain::calculate_h() - yS(5);
@@ -541,33 +538,17 @@ void ScopeGUI::create_panels()
                        vectorscope->create_objects();
                        vect_slider = new ScopeVectSlider(this, vx, vy, slider_w);
                        vect_slider->create_objects();
-                       if( use_vector < 0 ) {
-                               vect_grats = new ScopeVectGrats(this, vx, 2*margin);
-                               add_subwindow(vect_grats);
-                               vect_grats->create_objects();
-                       }
                }
                else {
                        vectorscope->reposition_window(
                                vector_x, vector_y, vector_w, vector_h);
                        vectorscope->clear_box(0, 0, vector_w, vector_h);
                        vect_slider->reposition_window(vx, vy);
-                       if( use_vector > 0 ) {
-                               delete vect_grats;  vect_grats = 0;
-                       }
-                       else if( !vect_grats ) {
-                               vect_grats = new ScopeVectGrats(this, vx, 2*margin);
-                               add_subwindow(vect_grats);
-                               vect_grats->create_objects();
-                       }
-                       else
-                               vect_grats->reposition_window(vx, 2*margin);
                }
        }
        else if( !use_vector && vectorscope ) {
                delete vectorscope;  vectorscope = 0;
                delete vect_slider;  vect_slider = 0;
-               delete vect_grats;   vect_grats = 0;
        }
 
        if( (use_hist || use_hist_parade) ) {
@@ -616,7 +597,7 @@ void ScopeGUI::toggle_event()
 void ScopeGUI::calculate_sizes(int w, int h)
 {
        int margin = theme->widget_border;
-       int menu_h = smooth->get_h() + scope_menu->get_h() + margin * 3;
+       int menu_h = scope_menu->get_h() + ScopeGain::calculate_h() + margin * 3;
        int text_w = get_text_width(SMALLFONT, "000") + margin * 2;
        int total_panels = ((use_hist || use_hist_parade) ? 1 : 0) +
                ((use_wave || use_wave_parade) ? 1 : 0) +
@@ -714,8 +695,6 @@ int ScopeGUI::resize_event(int w, int h)
                int vx = vector_x + vector_w - vect_slider->get_w() - margin;
                int vy = vector_y - vect_slider->get_h() - margin;
                vect_slider->reposition_window(vx, vy);
-               if( vect_grats )
-                       vect_grats->reposition_window(vx, 2*margin);
        }
 
        allocate_vframes();
@@ -1263,7 +1242,7 @@ int ScopeScopesOn::handle_event()
 }
 
 ScopeMenu::ScopeMenu(ScopeGUI *gui, int x, int y)
- : BC_PopupMenu(x, y, xS(100), _("Scopes"))
+ : BC_PopupMenu(x, y, xS(110), _("Scopes"))
 {
        this->gui = gui;
 }
@@ -1300,18 +1279,54 @@ void ScopeMenu::update_toggles()
 }
 
 
-ScopeVectGrats::ScopeVectGrats(ScopeGUI *gui, int x, int y)
- : BC_PopupMenu(x, y, _("Overlay"))
+ScopeSettingOn::ScopeSettingOn(ScopeSettings *settings, const char *text, int id)
+ : BC_MenuItem(text)
+{
+       this->settings = settings;
+       this->id = id;
+}
+
+int ScopeSettingOn::handle_event()
+{
+       int v = get_checked() ? 0 : 1;
+       set_checked(v);
+       ScopeGUI *gui = settings->gui;
+       switch( id ) {
+       case SCOPE_SMOOTH:
+               gui->use_smooth = v;
+               break;
+       case SCOPE_REFRESH:
+               gui->use_refresh = v;
+               break;
+       }
+       gui->toggle_event();
+       gui->update_toggles();
+       gui->update_scope();
+       gui->show_window();
+       return 1;
+}
+
+ScopeSettings::ScopeSettings(ScopeGUI *gui, int x, int y)
+ : BC_PopupMenu(x, y, xS(125), _("Settings"))
 {
        this->gui = gui;
 }
 
-#define SCOPE_SEARCHPATH "/scopes"
-void ScopeVectGrats::create_objects()
+void ScopeSettings::create_objects()
 {
+       add_item(smooth_on =
+               new ScopeSettingOn(this, _("Smooth"), SCOPE_SMOOTH));
+       smooth_on->set_checked(gui->use_smooth);
+       if( gui->use_refresh >= 0 ) {
+               add_item(refresh_on =
+                       new ScopeSettingOn(this, _("Realtime"), SCOPE_REFRESH));
+               refresh_on->set_checked(gui->use_refresh);
+       }
+       add_item(new BC_MenuItem(_("-Graticule-")));
+
        gui->grat_paths.remove_all_objects();
        ScopeGratItem *item;
-       add_item(item = new ScopeGratItem(this, _("none"), 0));
+       add_item(item = new ScopeGratItem(this, _("None"), 0));
        if( item->idx == gui->grat_idx ) item->set_checked(1);
        gui->grat_paths.append(0);
        FileSystem fs;
@@ -1331,20 +1346,20 @@ void ScopeVectGrats::create_objects()
        }
 }
 
-ScopeGratItem::ScopeGratItem(ScopeVectGrats *vect_grats, const char *text, int idx)
+ScopeGratItem::ScopeGratItem(ScopeSettings *settings, const char *text, int idx)
  : BC_MenuItem(text)
 {
-       this->vect_grats = vect_grats;
+       this->settings = settings;
        this->idx = idx;
 }
 
 int ScopeGratItem::handle_event()
 {
-       for( int i=0,n=vect_grats->total_items(); i<n; ++i ) {
-               ScopeGratItem *item = (ScopeGratItem *)vect_grats->get_item(i);
+       for( int i=0,n=settings->total_items(); i<n; ++i ) {
+               ScopeGratItem *item = (ScopeGratItem *)settings->get_item(i);
                item->set_checked(item->idx == idx);
        }       
-       vect_grats->gui->update_graticule(idx);
+       settings->gui->update_graticule(idx);
        return 1;
 }
 
@@ -1432,30 +1447,3 @@ ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w)
 {
 }
 
-ScopeSmooth::ScopeSmooth(ScopeGUI *gui, int x, int y)
- : BC_CheckBox(x, y, gui->use_smooth, _("Smooth"))
-{
-       this->gui = gui;
-}
-
-int ScopeSmooth::handle_event()
-{
-       gui->use_smooth = get_value();
-       gui->update_scope();
-       gui->toggle_event();
-       return 1;
-}
-
-ScopeRefresh::ScopeRefresh(ScopeGUI *gui, int x, int y)
- : BC_CheckBox(x, y, gui->use_refresh, _("Refresh only"))
-{
-       this->gui = gui;
-}
-
-int ScopeRefresh::handle_event()
-{
-       gui->use_refresh = get_value();
-       gui->toggle_event();
-       return 1;
-}
-
index 1f73fc363b2b24b91b944b7b8f7a7f1dcd1de802..123f45506feea9e29dd2cc6c40b66bf09e012236 100644 (file)
@@ -36,6 +36,7 @@ enum {
        SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
        SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
        SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
+       SCOPE_SMOOTH, SCOPE_REFRESH,
 };
 
 // Number of divisions in histogram.
@@ -167,6 +168,15 @@ public:
        ScopeScopesOn *vect_wheel;
 };
 
+class ScopeSettingOn : public BC_MenuItem
+{
+public:
+       ScopeSettingOn(ScopeSettings *settings, const char *text, int id);
+       int handle_event();
+
+       ScopeSettings *settings;
+       int id;
+};
 
 class ScopeGratPaths : public ArrayList<const char *>
 {
@@ -178,20 +188,22 @@ public:
 class ScopeGratItem : public BC_MenuItem
 {
 public:
-       ScopeGratItem(ScopeVectGrats *vect_grats, const char *text, int idx);
+       ScopeGratItem(ScopeSettings *settings, const char *text, int idx);
        int handle_event();
 
-       ScopeVectGrats *vect_grats;
+       ScopeSettings *settings;
        int idx;
 };
 
-class ScopeVectGrats : public BC_PopupMenu
+class ScopeSettings : public BC_PopupMenu
 {
 public:
-       ScopeVectGrats(ScopeGUI *gui, int x, int y);
+       ScopeSettings(ScopeGUI *gui, int x, int y);
        void create_objects();
 
        ScopeGUI *gui;
+       ScopeSettingOn *smooth_on;
+       ScopeSettingOn *refresh_on;
 };
 
 
@@ -249,23 +261,6 @@ public:
 };
 
 
-class ScopeSmooth : public BC_CheckBox
-{
-public:
-       ScopeSmooth(ScopeGUI *gui, int x, int y);
-       int handle_event();
-       ScopeGUI *gui;
-};
-
-class ScopeRefresh : public BC_CheckBox
-{
-public:
-       ScopeRefresh(ScopeGUI *gui, int x, int y);
-       int handle_event();
-       ScopeGUI *gui;
-};
-
-
 class ScopeGUI : public PluginClientWindow
 {
 public:
@@ -309,9 +304,7 @@ public:
        ScopeMenu *scope_menu;
        ScopeWaveSlider *wave_slider;
        ScopeVectSlider *vect_slider;
-       ScopeVectGrats *vect_grats;
-       ScopeSmooth *smooth;
-       ScopeRefresh *refresh;
+       ScopeSettings *settings;
        VFrame *grat_image;
        OverlayFrame *overlay;
 
index ebda640e0748ceb2c7f27400675582bde95ddf80..dcd4e4e04d0df4cc757dfef7d662f45bc7b2df6f 100644 (file)
@@ -12,13 +12,12 @@ class ScopeScopesOn;
 class ScopeMenu;
 class ScopeGratPaths;
 class ScopeGratItem;
-class ScopeVectGrats;
+class ScopeSettings;
 class ScopeGainReset;
 class ScopeGainSlider;
 class ScopeGain;
 class ScopeWaveSlider;
 class ScopeVectSlider;
-class ScopeSmooth;
 class ScopeGUI;
 
 #endif
index f672e77367a2e2d62f57d32c2630ea8d92aff1ae..7c8551f4234036f42935ad332d462f2a9b423f60 100644 (file)
@@ -319,15 +319,14 @@ int BC_MenuItem::draw()
        int text_line = top_level->get_text_descent(MEDIUMFONT);
        BC_Resources *resources = top_level->get_resources();
 
-       if(!strcmp(text, "-"))
-       {
-               menu_popup->get_popup()->set_color(DKGREY);
-               menu_popup->get_popup()->draw_line(xS(5), y + h / 2, menu_popup->get_w() - xS(5), y + h / 2);
-               menu_popup->get_popup()->set_color(LTGREY);
-               menu_popup->get_popup()->draw_line(xS(5), y + h / 2 + 1, menu_popup->get_w() - xS(5), y + h / 2 + 1);
+       if(!strcmp(text, "-")) {
+               int bx = xS(5), by = y+h/2, bw = menu_popup->get_w()-xS(10);
+               draw_bar(bx, by, bw);
        }
-       else
-       {
+       else if( text[0] == '-' && text[strlen(text)-1] == '-' ) {
+               draw_title_bar();
+       }
+       else {
                int xoffset = 0, yoffset = 0;
                if(highlighted)
                {
@@ -418,6 +417,33 @@ int BC_MenuItem::draw()
        return 0;
 }
 
+void BC_MenuItem::draw_bar(int bx, int by, int bw)
+{
+       BC_Popup *popup = menu_popup->get_popup();
+       popup->set_color(DKGREY);
+       popup->draw_line(bx, by, bx+bw, by);
+       popup->set_color(LTGREY);  ++by;
+       popup->draw_line(bx, by, bx+bw, by);
+}
+
+void BC_MenuItem::draw_title_bar()
+{
+       BC_Popup *popup = menu_popup->get_popup();
+       int len = strlen(text)-2;
+       if( len <= 0 ) return;
+       int tw = popup->get_text_width(MEDIUMFONT, text+1, len);
+       int th = popup->get_text_ascent(MEDIUMFONT);
+       int mw = menu_popup->get_w(), lw = mw - tw;
+       int x1 = xS(5), y1 = y+h/2;
+       int tx = lw/4, ty = y1 + th/2;
+       int w1 = tx - x1 - xS(5);
+       if( w1 > 0 ) draw_bar(x1, y1, w1);
+       BC_Resources *resources = top_level->get_resources();
+       popup->set_color(resources->text_background_hi);
+       popup->draw_text(tx, ty, text+1, len);
+       int x2 = tx + tw + xS(5), w2 = mw - xS(5) - x2;
+       if( w2 > 0 ) draw_bar(x2, y1, w2);
+}
 
 int BC_MenuItem::add_submenu(BC_SubMenu *submenu)
 {
index e167b9835cb681a02b55240e4733d10c615a79f5..7f97740af14ad3054d67808a090b968efea4eb80 100644 (file)
@@ -71,6 +71,9 @@ public:
        void set_enabled(int v);
 
 private:
+       void draw_bar(int bx, int by, int bw);
+       void draw_title_bar();
+
        BC_WindowBase *top_level;
        BC_MenuBar *menu_bar;
        BC_MenuPopup *menu_popup;