mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
double-clicks on labels
This commit is contained in:
parent
880feb0a01
commit
e8e9336f6a
@ -29,8 +29,9 @@ const char * const WinStatsGraph::_graph_window_class_name = "graph";
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
WinStatsGraph::
|
||||
WinStatsGraph(WinStatsMonitor *monitor) :
|
||||
_monitor(monitor)
|
||||
WinStatsGraph(WinStatsMonitor *monitor, int thread_index) :
|
||||
_monitor(monitor),
|
||||
_thread_index(thread_index)
|
||||
{
|
||||
_window = 0;
|
||||
_graph_window = 0;
|
||||
|
@ -35,7 +35,7 @@ class WinStatsMonitor;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class WinStatsGraph {
|
||||
public:
|
||||
WinStatsGraph(WinStatsMonitor *monitor);
|
||||
WinStatsGraph(WinStatsMonitor *monitor, int thread_index);
|
||||
virtual ~WinStatsGraph();
|
||||
|
||||
virtual void new_collector(int collector_index);
|
||||
@ -59,6 +59,7 @@ protected:
|
||||
Brushes _brushes;
|
||||
|
||||
WinStatsMonitor *_monitor;
|
||||
int _thread_index;
|
||||
HWND _window;
|
||||
HWND _graph_window;
|
||||
WinStatsLabelStack _label_stack;
|
||||
|
@ -33,13 +33,15 @@ const char * const WinStatsLabel::_window_class_name = "label";
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
WinStatsLabel::
|
||||
WinStatsLabel(WinStatsMonitor *monitor, int collector_index) :
|
||||
WinStatsLabel(WinStatsMonitor *monitor, int thread_index, int collector_index) :
|
||||
_monitor(monitor),
|
||||
_thread_index(thread_index),
|
||||
_collector_index(collector_index)
|
||||
{
|
||||
_window = 0;
|
||||
_text = monitor->get_client_data()->get_collector_name(_collector_index);
|
||||
_text = _monitor->get_client_data()->get_collector_name(_collector_index);
|
||||
|
||||
RGBColorf rgb = monitor->get_collector_color(_collector_index);
|
||||
RGBColorf rgb = _monitor->get_collector_color(_collector_index);
|
||||
int r = (int)(rgb[0] * 255.0f);
|
||||
int g = (int)(rgb[1] * 255.0f);
|
||||
int b = (int)(rgb[2] * 255.0f);
|
||||
@ -212,7 +214,7 @@ register_window_class(HINSTANCE application) {
|
||||
WNDCLASS wc;
|
||||
|
||||
ZeroMemory(&wc, sizeof(WNDCLASS));
|
||||
wc.style = 0;
|
||||
wc.style = CS_DBLCLKS;
|
||||
wc.lpfnWndProc = (WNDPROC)static_window_proc;
|
||||
wc.hInstance = application;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
@ -254,6 +256,10 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
LONG WinStatsLabel::
|
||||
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
switch (msg) {
|
||||
case WM_LBUTTONDBLCLK:
|
||||
_monitor->open_strip_chart(_thread_index, _collector_index);
|
||||
return 0;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
@ -34,7 +34,8 @@ class WinStatsMonitor;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class WinStatsLabel {
|
||||
public:
|
||||
WinStatsLabel(WinStatsMonitor *monitor, int collector_index);
|
||||
WinStatsLabel(WinStatsMonitor *monitor, int thread_index,
|
||||
int collector_index);
|
||||
~WinStatsLabel();
|
||||
|
||||
void setup(HWND parent_window);
|
||||
@ -53,6 +54,8 @@ private:
|
||||
static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
LONG WINAPI window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
WinStatsMonitor *_monitor;
|
||||
int _thread_index;
|
||||
int _collector_index;
|
||||
string _text;
|
||||
HWND _window;
|
||||
|
@ -181,13 +181,14 @@ clear_labels() {
|
||||
// Description: Adds a new label to the top of the stack.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void WinStatsLabelStack::
|
||||
add_label(WinStatsMonitor *monitor, int collector_index) {
|
||||
add_label(WinStatsMonitor *monitor, int thread_index, int collector_index) {
|
||||
int yp = _height;
|
||||
if (!_labels.empty()) {
|
||||
WinStatsLabel *top_label = _labels.back();
|
||||
yp = top_label->get_y() - top_label->get_height();
|
||||
}
|
||||
WinStatsLabel *label = new WinStatsLabel(monitor, collector_index);
|
||||
WinStatsLabel *label =
|
||||
new WinStatsLabel(monitor, thread_index, collector_index);
|
||||
if (_window) {
|
||||
label->setup(_window);
|
||||
label->set_pos(0, yp, _width);
|
||||
|
@ -48,7 +48,8 @@ public:
|
||||
int get_ideal_width() const;
|
||||
|
||||
void clear_labels();
|
||||
void add_label(WinStatsMonitor *monitor, int collector_index);
|
||||
void add_label(WinStatsMonitor *monitor, int thread_index,
|
||||
int collector_index);
|
||||
|
||||
private:
|
||||
void create_window(HWND parent_window);
|
||||
|
@ -103,8 +103,7 @@ initialized() {
|
||||
void WinStatsMonitor::
|
||||
got_hello() {
|
||||
create_window();
|
||||
|
||||
add_graph(new WinStatsStripChart(this, get_view(0), 0));
|
||||
open_strip_chart(0, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -246,6 +245,18 @@ get_window() const {
|
||||
return _window;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: WinStatsMonitor::open_strip_chart_
|
||||
// Access: Public
|
||||
// Description: Opens a new strip chart showing the indicated data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void WinStatsMonitor::
|
||||
open_strip_chart(int thread_index, int collector_index) {
|
||||
WinStatsStripChart *chart =
|
||||
new WinStatsStripChart(this, thread_index, collector_index);
|
||||
add_graph(chart);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: WinStatsMonitor::lookup_menu
|
||||
// Access: Public
|
||||
@ -414,10 +425,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
if (HIWORD(wparam) <= 1) {
|
||||
int menu_id = LOWORD(wparam);
|
||||
const MenuDef &menu_def = lookup_menu(menu_id);
|
||||
WinStatsStripChart *chart =
|
||||
new WinStatsStripChart(this, get_view(menu_def._thread_index),
|
||||
menu_def._collector_index);
|
||||
add_graph(chart);
|
||||
open_strip_chart(menu_def._thread_index, menu_def._collector_index);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual bool has_idle();
|
||||
|
||||
HWND get_window() const;
|
||||
void open_strip_chart(int thread_index, int collector_index);
|
||||
|
||||
const MenuDef &lookup_menu(int menu_id) const;
|
||||
int get_menu_id(const MenuDef &menu_def);
|
||||
|
@ -31,12 +31,12 @@ const char * const WinStatsStripChart::_window_class_name = "strip";
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
WinStatsStripChart::
|
||||
WinStatsStripChart(WinStatsMonitor *monitor, PStatView &view,
|
||||
WinStatsStripChart(WinStatsMonitor *monitor, int thread_index,
|
||||
int collector_index) :
|
||||
PStatStripChart(monitor, view, collector_index,
|
||||
PStatStripChart(monitor, monitor->get_view(thread_index), collector_index,
|
||||
default_strip_chart_width,
|
||||
default_strip_chart_height),
|
||||
WinStatsGraph(monitor)
|
||||
WinStatsGraph(monitor, thread_index)
|
||||
{
|
||||
_brush_origin = 0;
|
||||
|
||||
@ -117,7 +117,8 @@ 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));
|
||||
_label_stack.add_label(WinStatsGraph::_monitor, _thread_index,
|
||||
get_label_collector(i));
|
||||
}
|
||||
_labels_changed = false;
|
||||
}
|
||||
@ -266,7 +267,7 @@ create_window() {
|
||||
|
||||
_window =
|
||||
CreateWindow(_window_class_name, window_title.c_str(), window_style,
|
||||
CW_USEDEFAULT, 0,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
win_rect.right - win_rect.left,
|
||||
win_rect.bottom - win_rect.top,
|
||||
WinStatsGraph::_monitor->get_window(), NULL, application, 0);
|
||||
|
@ -36,7 +36,7 @@ class WinStatsMonitor;
|
||||
class WinStatsStripChart : public PStatStripChart, public WinStatsGraph {
|
||||
public:
|
||||
WinStatsStripChart(WinStatsMonitor *monitor,
|
||||
PStatView &view, int collector_index);
|
||||
int thread_index, int collector_index);
|
||||
virtual ~WinStatsStripChart();
|
||||
|
||||
virtual void new_collector(int collector_index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user