smooth box, frame total

This commit is contained in:
David Rose 2006-01-18 03:31:45 +00:00
parent 8851a4edde
commit 59bdb24719
5 changed files with 74 additions and 43 deletions

View File

@ -124,11 +124,9 @@ do_update() {
// We put a separator between the above frame collector and the
// first level collector.
if (needs_separator) {
/*
mii.fMask = MIIM_FTYPE;
mii.fType = MFT_SEPARATOR;
InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii);
*/
GtkWidget *sep = gtk_separator_menu_item_new();
gtk_widget_show(sep);
gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep);
needs_separator = false;
}
@ -140,18 +138,19 @@ do_update() {
/*
// Also a menu item for a piano roll (following a separator).
mii.fMask = MIIM_FTYPE;
mii.fType = MFT_SEPARATOR;
InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii);
GtkWidget *sep = gtk_separator_menu_item_new();
gtk_widget_show(sep);
gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep);
GtkStatsMonitor::MenuDef menu_def(_thread_index, -1, false);
int menu_id = _monitor->get_menu_id(menu_def);
GtkStatsMonitor::MenuDef smd(_thread_index, -1, false);
const GtkStatsMonitor::MenuDef *menu_def = _monitor->add_menu(smd);
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID;
mii.fType = MFT_STRING;
mii.wID = menu_id;
mii.dwTypeData = "Piano Roll";
InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii);
GtkWidget *menu_item = gtk_menu_item_new_with_label("Piano Roll");
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(_menu), menu_item);
g_signal_connect_swapped(G_OBJECT(menu_item), "activate",
G_CALLBACK(handle_menu), (void *)(const void *)menu_def);
*/
}

View File

@ -100,10 +100,16 @@ GtkStatsGraph(GtkStatsMonitor *monitor, int thread_index) :
gtk_frame_set_shadow_type(GTK_FRAME(graph_frame), GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(graph_frame), _graph_window);
// A VBox to hold the graph's frame, and any numbers (scale legend?
// total?) above it.
_graph_vbox = gtk_vbox_new(FALSE, 0);
gtk_box_pack_end(GTK_BOX(_graph_vbox), graph_frame,
TRUE, TRUE, 0);
// An HBox to hold the graph's frame, and the scale legend to the
// right of it.
_graph_hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(_graph_hbox), graph_frame,
gtk_box_pack_start(GTK_BOX(_graph_hbox), _graph_vbox,
TRUE, TRUE, 0);
// An HPaned to hold the label stack and the graph hbox.

View File

@ -86,6 +86,7 @@ protected:
GtkWidget *_window;
GtkWidget *_graph_window;
GtkWidget *_graph_hbox;
GtkWidget *_graph_vbox;
GtkWidget *_hpaned;
GtkWidget *_scale_area;
GtkStatsLabelStack _label_stack;

View File

@ -54,9 +54,23 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
set_guide_bar_units(get_guide_bar_units() | GBU_show_units);
}
_smooth_check_box = 0;
// Put some stuff on top of the graph.
_top_hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(_graph_vbox), _top_hbox,
FALSE, FALSE, 0);
// Add a DrawingArea widget to display all of the scale units.
_smooth_check_box = gtk_check_button_new_with_label("Smooth");
g_signal_connect(G_OBJECT(_smooth_check_box), "toggled",
G_CALLBACK(toggled_callback), this);
_total_label = gtk_label_new("");
gtk_box_pack_start(GTK_BOX(_top_hbox), _smooth_check_box,
FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(_top_hbox), _total_label,
FALSE, FALSE, 0);
// Add a DrawingArea widget to the right of the graph, to display
// all of the scale units.
_scale_area = gtk_drawing_area_new();
g_signal_connect(G_OBJECT(_scale_area), "expose_event",
G_CALLBACK(expose_event_callback), this);
@ -119,16 +133,11 @@ new_data(int thread_index, int frame_number) {
if (!_pause) {
update();
/*
string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name());
if (_net_value_text != text) {
_net_value_text = text;
RECT rect;
GetClientRect(_window, &rect);
rect.bottom = _top_margin;
InvalidateRect(_window, &rect, TRUE);
gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str());
}
*/
}
}
@ -437,10 +446,9 @@ set_drag_mode(GtkStatsGraph::DragMode drag_mode) {
default:
// Restore smoothing according to the current setting of the check
// box.
/*
int result = SendMessage(_smooth_check_box, BM_GETCHECK, 0, 0);
set_average_mode(result == BST_CHECKED);
*/
bool active =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_smooth_check_box));
set_average_mode(active);
break;
}
}
@ -658,6 +666,7 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
}
}
if (y >= 0 && y < get_ysize()) {
// Now convert our y to a coordinate within our drawing area.
int junk_x;
@ -667,17 +676,30 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) {
&junk_x, &y);
int this_y = y - height / 2;
if (y >= 0 && y <= _scale_area->allocation.height &&
(last_y < this_y || last_y > this_y + height)) {
if (last_y < this_y || last_y > this_y + height) {
gdk_draw_layout(_scale_area->window, gc, 0, this_y, layout);
last_y = this_y;
}
}
g_object_unref(layout);
g_object_unref(gc);
return last_y;
}
////////////////////////////////////////////////////////////////////
// Function: GtkStatsStripChart::toggled_callback
// Access: Private, Static
// Description: Called when the smooth check box is toggled.
////////////////////////////////////////////////////////////////////
void GtkStatsStripChart::
toggled_callback(GtkToggleButton *button, gpointer data) {
GtkStatsStripChart *self = (GtkStatsStripChart *)data;
bool active = gtk_toggle_button_get_active(button);
self->set_average_mode(active);
}
////////////////////////////////////////////////////////////////////
// Function: GtkStatsStripChart::expose_event_callback
// Access: Private, Static

View File

@ -75,6 +75,7 @@ private:
void draw_guide_labels();
int draw_guide_label(const PStatGraph::GuideBar &bar, int last_y);
static void toggled_callback(GtkToggleButton *button, gpointer data);
static gboolean expose_event_callback(GtkWidget *widget,
GdkEventExpose *event, gpointer data);
@ -83,7 +84,9 @@ private:
int _brush_origin;
string _net_value_text;
GtkWidget *_top_hbox;
GtkWidget *_smooth_check_box;
GtkWidget *_total_label;
static bool _window_class_registered;
static const char * const _window_class_name;