menus and non-scroll-mode

This commit is contained in:
David Rose 2004-01-10 00:35:45 +00:00
parent e25ab93820
commit 880feb0a01
12 changed files with 158 additions and 19 deletions

View File

@ -324,6 +324,12 @@ add_collector(PStatCollectorDef *def) {
_collectors[def->_index]._def = def;
update_toplevel_collectors();
// If we already had the _is_level flag set, it should be
// immediately applied to all ancestors.
if (_collectors[def->_index]._is_level) {
set_collector_has_level(def->_parent_index, true);
}
}
////////////////////////////////////////////////////////////////////

View File

@ -641,7 +641,11 @@ draw_pixels(int first_pixel, int last_pixel) {
float time = pixel_to_timestamp(x);
frame_number = thread_data->get_frame_number_at_time(time, frame_number);
int w = 1;
while (x + w <= last_pixel &&
int stop_pixel = last_pixel;
if (!_scroll_mode) {
stop_pixel = min(stop_pixel, _cursor_pixel);
}
while (x + w < stop_pixel &&
thread_data->get_frame_number_at_time(pixel_to_timestamp(x + w), frame_number) == frame_number) {
w++;
}
@ -653,5 +657,6 @@ draw_pixels(int first_pixel, int last_pixel) {
x += w;
}
}
end_draw(first_pixel, last_pixel);
}

View File

@ -17,7 +17,7 @@
winStatsLabel.cxx winStatsLabel.h \
winStatsLabelStack.cxx winStatsLabelStack.h \
winStatsServer.cxx winStatsServer.h \
winStatsMonitor.cxx winStatsMonitor.h \
winStatsMonitor.cxx winStatsMonitor.h winStatsMonitor.I \
winStatsStripChart.cxx winStatsStripChart.h
#define WIN_SYS_LIBS Imm32.lib winmm.lib kernel32.lib oldnames.lib user32.lib gdi32.lib

View File

@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////
#include "winStatsChartMenu.h"
#include "pStatMonitor.h"
#include "winStatsMonitor.h"
////////////////////////////////////////////////////////////////////
// Function: WinStatsChartMenu::Constructor
@ -25,7 +25,7 @@
// Description:
////////////////////////////////////////////////////////////////////
WinStatsChartMenu::
WinStatsChartMenu(PStatMonitor *monitor, int thread_index) :
WinStatsChartMenu(WinStatsMonitor *monitor, int thread_index) :
_monitor(monitor),
_thread_index(thread_index)
{
@ -153,25 +153,29 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level) {
const PStatClientData *client_data = _monitor->get_client_data();
string collector_name = client_data->get_collector_name(collector);
WinStatsMonitor::MenuDef menu_def(_thread_index, collector);
int menu_id = _monitor->get_menu_id(menu_def);
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_FTYPE;
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID;
mii.fType = MFT_STRING;
mii.wID = menu_id;
mii.dwTypeData = (char *)collector_name.c_str();
InsertMenuItem(parent_menu, GetMenuItemCount(parent_menu), TRUE, &mii);
int num_children = view_level->get_num_children();
if (num_children != 0) {
// If the collector has any children, add a menu entry to go
if (num_children > 1) {
// If the collector has more than one child, add a menu entry to go
// directly to each of its children.
HMENU submenu = CreatePopupMenu();
string submenu_name = collector_name + " components";
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU;
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU;
mii.fType = MFT_STRING;
mii.hSubMenu = submenu;
mii.hSubMenu = submenu;
mii.dwTypeData = (char *)submenu_name.c_str();
InsertMenuItem(parent_menu, GetMenuItemCount(parent_menu), TRUE, &mii);

View File

@ -23,7 +23,7 @@
#include <windows.h>
class PStatMonitor;
class WinStatsMonitor;
class PStatView;
class PStatViewLevel;
@ -34,7 +34,7 @@ class PStatViewLevel;
////////////////////////////////////////////////////////////////////
class WinStatsChartMenu {
public:
WinStatsChartMenu(PStatMonitor *monitor, int thread_index);
WinStatsChartMenu(WinStatsMonitor *monitor, int thread_index);
~WinStatsChartMenu();
HMENU get_menu_handle();
@ -46,7 +46,7 @@ public:
private:
void add_view(HMENU parent_menu, const PStatViewLevel *view_level);
PStatMonitor *_monitor;
WinStatsMonitor *_monitor;
int _thread_index;
int _last_level_index;

View File

@ -262,6 +262,10 @@ setup_bitmap(int xsize, int ysize) {
_bitmap_dc = CreateCompatibleDC(hdc);
_bitmap = CreateCompatibleBitmap(hdc, _bitmap_xsize, _bitmap_ysize);
SelectObject(_bitmap_dc, _bitmap);
RECT rect = { 0, 0, _bitmap_xsize, _bitmap_ysize };
FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
ReleaseDC(_window, hdc);
}
@ -320,7 +324,7 @@ create_graph_window() {
register_graph_window_class(application);
string window_title = "graph";
DWORD window_style = WS_CHILD;
DWORD window_style = WS_CHILD | WS_CLIPSIBLINGS;
_graph_window =
CreateWindow(_graph_window_class_name, window_title.c_str(), window_style,

View File

@ -186,7 +186,7 @@ create_window(HWND parent_window) {
register_window_class(application);
_window =
CreateWindow(_window_class_name, _text.c_str(), WS_CHILD,
CreateWindow(_window_class_name, _text.c_str(), WS_CHILD | WS_CLIPSIBLINGS,
0, 0, 0, 0,
parent_window, NULL, application, 0);
if (!_window) {

View File

@ -18,6 +18,7 @@
#include "winStatsLabelStack.h"
#include "winStatsLabel.h"
#include "notify.h"
bool WinStatsLabelStack::_window_class_registered = false;
const char * const WinStatsLabelStack::_window_class_name = "stack";
@ -211,7 +212,7 @@ create_window(HWND parent_window) {
register_window_class(application);
_window =
CreateWindow(_window_class_name, "label stack", WS_CHILD | WS_CLIPCHILDREN,
CreateWindow(_window_class_name, "label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, 0, 0,
parent_window, NULL, application, 0);
if (!_window) {

View File

@ -0,0 +1,43 @@
// Filename: winStatsMonitor.I
// Created by: drose (09Jan04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: WinStatsMonitor::MenuDef::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
WinStatsMonitor::MenuDef::
MenuDef(int thread_index, int collector_index) :
_thread_index(thread_index),
_collector_index(collector_index)
{
}
////////////////////////////////////////////////////////////////////
// Function: WinStatsMonitor::MenuDef::operator <
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
bool WinStatsMonitor::MenuDef::
operator < (const MenuDef &other) const {
if (_thread_index != other._thread_index) {
return _thread_index < other._thread_index;
}
return _collector_index < other._collector_index;
}

View File

@ -168,6 +168,7 @@ new_thread(int thread_index) {
WinStatsChartMenu *chart_menu = new WinStatsChartMenu(this, thread_index);
chart_menu->add_to_menu_bar(_menu_bar);
_chart_menus.push_back(chart_menu);
DrawMenuBar(_window);
}
////////////////////////////////////////////////////////////////////
@ -245,6 +246,45 @@ get_window() const {
return _window;
}
////////////////////////////////////////////////////////////////////
// Function: WinStatsMonitor::lookup_menu
// Access: Public
// Description: Returns the MenuDef properties associated with the
// indicated menu ID. This specifies what we expect to
// do when the given menu has been selected.
////////////////////////////////////////////////////////////////////
const WinStatsMonitor::MenuDef &WinStatsMonitor::
lookup_menu(int menu_id) const {
static MenuDef invalid(0, 0);
nassertr(menu_id >= 0 && menu_id < (int)_menu_by_id.size(), invalid);
return _menu_by_id[menu_id];
}
////////////////////////////////////////////////////////////////////
// Function: WinStatsMonitor::get_menu_id
// Access: Public
// Description: Returns the menu ID that is reserved for the
// indicated MenuDef properties. If this is the first
// time these particular properties have been requested,
// a new menu ID is returned; otherwise, the existing
// menu ID is returned.
////////////////////////////////////////////////////////////////////
int WinStatsMonitor::
get_menu_id(const MenuDef &menu_def) {
MenuByDef::iterator mi;
mi = _menu_by_def.find(menu_def);
if (mi != _menu_by_def.end()) {
return (*mi).second;
}
// Slot a new id.
int menu_id = (int)_menu_by_id.size();
_menu_by_id.push_back(menu_def);
_menu_by_def[menu_def] = menu_id;
return menu_id;
}
////////////////////////////////////////////////////////////////////
// Function: WinStatsMonitor::add_graph
// Access: Private
@ -306,6 +346,7 @@ create_window() {
SetWindowLongPtr(_window, 0, (LONG_PTR)this);
ShowWindow(_window, SW_SHOWNORMAL);
ShowWindow(_window, SW_SHOWNORMAL);
}
////////////////////////////////////////////////////////////////////
@ -369,6 +410,18 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
close();
break;
case WM_COMMAND:
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);
return 0;
}
break;
default:
break;
}

View File

@ -25,6 +25,8 @@
#include "pStatMonitor.h"
#include "pointerTo.h"
#include "pset.h"
#include "pvector.h"
#include "pmap.h"
#include <windows.h>
@ -37,6 +39,15 @@ class WinStatsChartMenu;
////////////////////////////////////////////////////////////////////
class WinStatsMonitor : public PStatMonitor {
public:
class MenuDef {
public:
INLINE MenuDef(int thread_index, int collector_index);
INLINE bool operator < (const MenuDef &other) const;
int _thread_index;
int _collector_index;
};
WinStatsMonitor();
virtual ~WinStatsMonitor();
@ -54,6 +65,9 @@ public:
virtual bool has_idle();
HWND get_window() const;
const MenuDef &lookup_menu(int menu_id) const;
int get_menu_id(const MenuDef &menu_def);
private:
void add_graph(WinStatsGraph *graph);
@ -71,6 +85,11 @@ private:
typedef pvector<WinStatsChartMenu *> ChartMenus;
ChartMenus _chart_menus;
typedef pvector<MenuDef> MenuById;
typedef pmap<MenuDef, int> MenuByDef;
MenuById _menu_by_id;
MenuByDef _menu_by_def;
HWND _window;
HMENU _menu_bar;
string _window_title;
@ -81,4 +100,6 @@ private:
friend class WinStatsGraph;
};
#include "winStatsMonitor.I"
#endif

View File

@ -38,7 +38,6 @@ WinStatsStripChart(WinStatsMonitor *monitor, PStatView &view,
default_strip_chart_height),
WinStatsGraph(monitor)
{
cerr << "Constructing strip chart " << (void *)this << "\n";
_brush_origin = 0;
create_window();
@ -52,7 +51,6 @@ WinStatsStripChart(WinStatsMonitor *monitor, PStatView &view,
////////////////////////////////////////////////////////////////////
WinStatsStripChart::
~WinStatsStripChart() {
cerr << "Destructing strip chart " << (void *)this << "\n";
}
////////////////////////////////////////////////////////////////////
@ -235,7 +233,7 @@ draw_cursor(int x) {
void WinStatsStripChart::
end_draw(int from_x, int to_x) {
RECT rect = {
from_x, 0, to_x, get_ysize()
from_x, 0, to_x + 1, get_ysize()
};
InvalidateRect(_graph_window, &rect, FALSE);
}
@ -255,7 +253,7 @@ create_window() {
register_window_class(application);
string window_title = get_title_text();
DWORD window_style = WS_CHILD | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_VISIBLE;
DWORD window_style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_VISIBLE;
RECT win_rect = {
0, 0,
@ -279,6 +277,10 @@ create_window() {
SetWindowLongPtr(_window, 0, (LONG_PTR)this);
setup_label_stack();
// Ensure that the window is on top of the stack.
SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
////////////////////////////////////////////////////////////////////