Messages window: Scroll with wheel

This commit is contained in:
Ilari Liusvaara 2013-11-26 19:14:33 +02:00
parent c367bf1f9b
commit 29197e124d
2 changed files with 18 additions and 0 deletions

View file

@ -25,6 +25,7 @@ public:
uint64_t line_current;
size_t line_separation;
bool mouse_held;
int scroll_acc;
};
wxwin_messages();
~wxwin_messages();

View file

@ -23,11 +23,28 @@ wxwin_messages::panel::panel(wxwin_messages* _parent, unsigned lines)
this->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(wxwin_messages::panel::on_mouse), NULL, this);
this->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(wxwin_messages::panel::on_mouse), NULL, this);
this->Connect(wxEVT_MOTION, wxMouseEventHandler(wxwin_messages::panel::on_mouse), NULL, this);
this->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(wxwin_messages::panel::on_mouse), NULL, this);
SetMinSize(wxSize(6 * s.x, 5 * s.y));
}
void wxwin_messages::panel::on_mouse(wxMouseEvent& e)
{
//Handle mouse wheels first.
if(e.GetWheelRotation() && e.GetWheelDelta()) {
int unit = e.GetWheelDelta();
scroll_acc += e.GetWheelRotation();
while(scroll_acc <= -unit) {
umutex_class h(platform::msgbuf_lock());
platform::msgbuf.scroll_down_line();
scroll_acc += unit;
}
while(scroll_acc >= e.GetWheelDelta()) {
umutex_class h(platform::msgbuf_lock());
platform::msgbuf.scroll_up_line();
scroll_acc -= unit;
}
}
uint64_t gfirst;
{
umutex_class h(platform::msgbuf_lock());