this->gui = gui;
}
+#define SCOPE_SEARCHPATH "/scopes"
#define incr_point(rows,h, iv,comp) { \
if(iy >= 0 && iy < h) { \
grat_image = 0;
overlay = 0;
grat_idx = 0;
- vect_grats = 0;
+ settings = 0;
output_frame = 0;
data_frame = 0;
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();
{
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);
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) ) {
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) +
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();
}
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;
}
}
-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;
}
}
-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;
}
{
}
-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;
-}
-
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.
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 *>
{
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;
};
};
-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:
ScopeMenu *scope_menu;
ScopeWaveSlider *wave_slider;
ScopeVectSlider *vect_slider;
- ScopeVectGrats *vect_grats;
- ScopeSmooth *smooth;
- ScopeRefresh *refresh;
+ ScopeSettings *settings;
VFrame *grat_image;
OverlayFrame *overlay;
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)
{
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)
{