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