ShowImage: Style fixes related to scrolling

This commit is contained in:
John Scipione
2014-03-07 19:11:41 -05:00
parent b9f48ef8f6
commit 5b6c94c591
+27 -21
View File
@@ -1340,36 +1340,41 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
void void
ShowImageView::_MouseWheelChanged(BMessage* msg) ShowImageView::_MouseWheelChanged(BMessage* message)
{ {
// The BeOS driver does not currently support // The BeOS driver does not currently support
// X wheel scrolling, therefore, dx is zero. // X wheel scrolling, therefore, deltaX is zero.
// |dy| is the number of notches scrolled up or down. // |deltaY| is the number of notches scrolled up or down.
// When the wheel is scrolled down (towards the user) dy > 0 // When the wheel is scrolled down (towards the user) deltaY > 0
// When the wheel is scrolled up (away from the user) dy < 0 // When the wheel is scrolled up (away from the user) deltaY < 0
const float kscrollBy = 40; const float kscrollBy = 40;
float dy, dx; float deltaY;
float x, y; float deltaX;
x = 0; y = 0; float x = 0;
if (msg->FindFloat("be:wheel_delta_x", &dx) == B_OK) float y = 0;
x = dx * kscrollBy;
if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK)
y = dy * kscrollBy;
if ((modifiers() & B_SHIFT_KEY) != 0) if (message->FindFloat("be:wheel_delta_x", &deltaX) == B_OK)
x = deltaX * kscrollBy;
if (message->FindFloat("be:wheel_delta_y", &deltaY) == B_OK)
y = deltaY * kscrollBy;
if ((modifiers() & B_SHIFT_KEY) != 0) {
// scroll up and down
_ScrollRestrictedBy(x, y); _ScrollRestrictedBy(x, y);
else if ((modifiers() & B_COMMAND_KEY) != 0) } else if ((modifiers() & B_COMMAND_KEY) != 0) {
// scroll left and right
_ScrollRestrictedBy(y, x); _ScrollRestrictedBy(y, x);
else { } else {
// Zoom in spot // zoom at location
BPoint where; BPoint where;
uint32 buttons; uint32 buttons;
GetMouse(&where, &buttons); GetMouse(&where, &buttons);
if (fStickyZoomCountDown <= 0) { if (fStickyZoomCountDown <= 0) {
if (dy < 0) if (deltaY < 0)
ZoomIn(where); ZoomIn(where);
else if (dy > 0) else if (deltaY > 0)
ZoomOut(where); ZoomOut(where);
if (fZoom == 1.0) if (fZoom == 1.0)
@@ -1415,6 +1420,7 @@ ShowImageView::MessageReceived(BMessage* message)
case B_COPY_TARGET: case B_COPY_TARGET:
_HandleDrop(message); _HandleDrop(message);
break; break;
case B_MOUSE_WHEEL_CHANGED: case B_MOUSE_WHEEL_CHANGED:
_MouseWheelChanged(message); _MouseWheelChanged(message);
break; break;
@@ -1782,13 +1788,13 @@ ShowImageView::_SetIcon(bool clear, icon_size which)
uchar* dest = (uchar*)icon.Bits(); uchar* dest = (uchar*)icon.Bits();
const int32 srcBPR = thumbnail->BytesPerRow(); const int32 srcBPR = thumbnail->BytesPerRow();
const int32 destBPR = icon.BytesPerRow(); const int32 destBPR = icon.BytesPerRow();
const int32 dx = (int32)rect.left; const int32 deltaX = (int32)rect.left;
const int32 dy = (int32)rect.top; const int32 deltaY = (int32)rect.top;
for (int32 y = 0; y <= rect.IntegerHeight(); y++) { for (int32 y = 0; y <= rect.IntegerHeight(); y++) {
for (int32 x = 0; x <= rect.IntegerWidth(); x++) { for (int32 x = 0; x <= rect.IntegerWidth(); x++) {
const uchar* s = src + y * srcBPR + x; const uchar* s = src + y * srcBPR + x;
uchar* d = dest + (y + dy) * destBPR + (x + dx); uchar* d = dest + (y + deltaY) * destBPR + (x + deltaX);
*d = *s; *d = *s;
} }
} }