diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 311b84442b..3fd794d503 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -509,7 +509,7 @@ public: //////////////////////////////////////////////////////////////////// // Function: PStatStripChart::update_labels -// Access: Protected +// Access: Protected, Virtual // Description: Resets the list of labels. //////////////////////////////////////////////////////////////////// void PStatStripChart:: diff --git a/pandatool/src/pstatserver/pStatStripChart.h b/pandatool/src/pstatserver/pStatStripChart.h index fe39aed73a..af27c86326 100644 --- a/pandatool/src/pstatserver/pStatStripChart.h +++ b/pandatool/src/pstatserver/pStatStripChart.h @@ -89,7 +89,7 @@ protected: void changed_size(int xsize, int ysize); void force_redraw(); void force_reset(); - void update_labels(); + virtual void update_labels(); virtual void normal_guide_bars(); virtual void clear_region(); diff --git a/pandatool/src/win-stats/Sources.pp b/pandatool/src/win-stats/Sources.pp index 1994a482dd..3726b6ddca 100644 --- a/pandatool/src/win-stats/Sources.pp +++ b/pandatool/src/win-stats/Sources.pp @@ -13,6 +13,8 @@ #define SOURCES \ winStats.cxx \ winStatsGraph.cxx winStatsGraph.h \ + winStatsLabel.cxx winStatsLabel.h \ + winStatsLabelStack.cxx winStatsLabelStack.h \ winStatsServer.cxx winStatsServer.h \ winStatsMonitor.cxx winStatsMonitor.h \ winStatsStripChart.cxx winStatsStripChart.h diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index f412bb296d..e8ac53904f 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -18,6 +18,7 @@ #include "winStatsGraph.h" #include "winStatsMonitor.h" +#include "winStatsLabelStack.h" //////////////////////////////////////////////////////////////////// // Function: WinStatsGraph::Constructor @@ -33,7 +34,7 @@ WinStatsGraph(WinStatsMonitor *monitor) : _bitmap_dc = 0; _bitmap_xsize = 0; _bitmap_ysize = 0; - _left_margin = 64; + _left_margin = 96; _right_margin = 32; _top_margin = 16; _bottom_margin = 8; @@ -136,6 +137,34 @@ release_bitmap() { } } +//////////////////////////////////////////////////////////////////// +// Function: WinStatsGraph::setup_label_stack +// Access: Protected +// Description: Sets up the label stack on the left edge of the +// frame. +//////////////////////////////////////////////////////////////////// +void WinStatsGraph:: +setup_label_stack() { + _label_stack.setup(_window, 8, 8, _left_margin - 16, _top_margin + _bitmap_ysize + _bottom_margin - 16); + /* + if (_label_stack()->get_ideal_width() > _label_stack->get_width()) { + _left_margin = _label_stack->get_ideal_width() + 16; + move_label_stack(); + } + */ +} + +//////////////////////////////////////////////////////////////////// +// Function: WinStatsGraph::move_label_stack +// Access: Protected +// Description: Repositions the label stack if its coordinates or +// size have changed. +//////////////////////////////////////////////////////////////////// +void WinStatsGraph:: +move_label_stack() { + _label_stack.set_pos(8, 8, _left_margin - 16, _top_margin + _bitmap_ysize + _bottom_margin - 16); +} + //////////////////////////////////////////////////////////////////// // Function: WinStatsGraph::get_collector_brush // Access: Protected diff --git a/pandatool/src/win-stats/winStatsGraph.h b/pandatool/src/win-stats/winStatsGraph.h index 2e43b1a76c..df71d14f1d 100644 --- a/pandatool/src/win-stats/winStatsGraph.h +++ b/pandatool/src/win-stats/winStatsGraph.h @@ -20,6 +20,7 @@ #define WINSTATSGRAPH_H #include "pandatoolbase.h" +#include "winStatsLabelStack.h" #include "pmap.h" #include @@ -45,6 +46,8 @@ protected: void setup_bitmap(int xsize, int ysize); void release_bitmap(); + void setup_label_stack(); + void move_label_stack(); HBRUSH get_collector_brush(int collector_index); void draw_graph(HDC hdc); @@ -56,6 +59,7 @@ protected: WinStatsMonitor *_monitor; HWND _window; + WinStatsLabelStack _label_stack; HBITMAP _bitmap; HDC _bitmap_dc; diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index 639fc5db8f..c3c2527f09 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -249,7 +249,8 @@ create_window() { register_window_class(application); _window_title = get_client_progname() + " on " + get_client_hostname(); - DWORD window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + DWORD window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | + WS_CLIPSIBLINGS | WS_VISIBLE; _window = CreateWindow(_window_class_name, _window_title.c_str(), window_style, diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 1105c8a2af..f11795ea14 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -88,6 +88,22 @@ new_data(int thread_index, int frame_number) { update(); } +//////////////////////////////////////////////////////////////////// +// Function: WinStatsStripChart::update_labels +// Access: Protected, Virtual +// Description: Resets the list of labels. +//////////////////////////////////////////////////////////////////// +void WinStatsStripChart:: +update_labels() { + PStatStripChart::update_labels(); + + _label_stack.clear_labels(); + for (int i = 0; i < get_num_labels(); i++) { + _label_stack.add_label(WinStatsGraph::_monitor, get_label_collector(i)); + } + _labels_changed = false; +} + //////////////////////////////////////////////////////////////////// // Function: WinStatsStripChart::clear_region // Access: Protected, Virtual @@ -218,7 +234,7 @@ create_window() { register_window_class(application); string window_title = get_title_text(); - DWORD window_style = WS_CHILD | WS_OVERLAPPEDWINDOW; + DWORD window_style = WS_CHILD | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_VISIBLE; RECT win_rect = { 0, 0, @@ -241,7 +257,7 @@ create_window() { } SetWindowLongPtr(_window, 0, (LONG_PTR)this); - ShowWindow(_window, SW_SHOWNORMAL); + setup_label_stack(); } //////////////////////////////////////////////////////////////////// @@ -315,6 +331,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { HIWORD(lparam) - (_top_margin + _bottom_margin)); setup_bitmap(get_xsize(), get_ysize()); force_redraw(); + move_label_stack(); InvalidateRect(hwnd, NULL, FALSE); break; diff --git a/pandatool/src/win-stats/winStatsStripChart.h b/pandatool/src/win-stats/winStatsStripChart.h index e86e0b8cb2..27cf427727 100644 --- a/pandatool/src/win-stats/winStatsStripChart.h +++ b/pandatool/src/win-stats/winStatsStripChart.h @@ -43,6 +43,8 @@ public: virtual void new_data(int thread_index, int frame_number); protected: + virtual void update_labels(); + virtual void clear_region(); virtual void copy_region(int start_x, int end_x, int dest_x); virtual void draw_slice(int x, int frame_number);