void TouchpadView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) { if (fXTracking) { if (point.x > fPadRect.right) fXScrollRange = fPadRect.Width(); else if (point.x < fPadRect.left) fXScrollRange = 0; else fXScrollRange = point.x - fPadRect.left; DrawSliders(); } if (fYTracking) { if (point.y > fPadRect.bottom) fYScrollRange = fPadRect.Height(); else if (point.y < fPadRect.top) fYScrollRange = 0; else fYScrollRange = point.y - fPadRect.top; DrawSliders(); } }
void TouchpadView::MouseUp(BPoint point) { if (!fXTracking && !fYTracking) return; fXTracking = false; fYTracking = false; const float kSoftScrollLimit = 0.7; int32 result = 0; if (GetRightScrollRatio() > kSoftScrollLimit || GetBottomScrollRatio() > kSoftScrollLimit) { BAlert* alert = new BAlert("ReallyChangeScrollArea", "The new scroll area is very large and may impede " "normal mouse operation. Do you really want to change" " it?", "OK", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); result = alert->Go(); } if (result == 0) { BMessage msg(SCROLL_AREA_CHANGED); Invoke(&msg); } else { if (GetRightScrollRatio() > kSoftScrollLimit) fXScrollRange = fOldXScrollRange; if (GetBottomScrollRatio() > kSoftScrollLimit) fYScrollRange = fOldYScrollRange; DrawSliders(); } }
void TLevelsSlider::TrackSliders() { BPoint newPt, oldPt; // Check to see if button is down uint32 buttons = 0; GetMouse(&newPt, &buttons, true); while(buttons) { // Idle if in same mouse location if (newPt.y != oldPt.y) { // Get old positions BRect oldLeftRect = m_LeftSliderRect; BRect oldRightRect = m_RightSliderRect; // Move both left and right slider under mouse const uint32 leftHeight = m_LeftSlider->Bounds().IntegerHeight(); const uint32 rightHeight = m_RightSlider->Bounds().IntegerHeight(); m_LeftSliderRect.top = newPt.y - leftHeight/2; m_LeftSliderRect.bottom = m_LeftSliderRect.top + leftHeight; m_RightSliderRect.top = newPt.y - leftHeight/2; m_RightSliderRect.bottom = m_RightSliderRect.top + rightHeight; // Now clip the location of the slider if out of bounds ClipSliders(); // Clean up old position BRect updateRect = oldLeftRect; updateRect.right = oldRightRect.right; Draw(updateRect); // Draw new location DrawSliders(); // Set new volume level UpdateVolumes(newPt); // Save mouse location oldPt = newPt; } // Let other events through snooze(20 * 1000); // Get new mouse location and button state GetMouse(&newPt, &buttons, true); // Clip location const BRect bounds = Bounds(); if ( newPt.y < bounds.top+kTopOffset) newPt.y = bounds.top+kTopOffset; if ( newPt.y > bounds.bottom-kBottomOffset) newPt.y = bounds.bottom-kBottomOffset; } }
void TLevelsSlider::Draw(BRect updateRect) { PushState(); // Set up clipping BRegion clipRegion, saveRegion; GetClippingRegion(&saveRegion); clipRegion.Set(updateRect); ConstrainClippingRegion( &clipRegion ); BPoint startPt, endPt; const BRect bounds = Bounds(); // Fill with background SetHighColor(kPaleGrey); FillRect(updateRect); // Create left frame SetHighColor(kDarkGrey); startPt.Set(bounds.left, bounds.bottom); endPt.Set(bounds.left, bounds.top); StrokeLine(startPt, endPt); endPt.Set(bounds.right-2, bounds.top); StrokeLine(endPt); // Create left shadow SetHighColor(kBeShadow); BRect shadowOutline = bounds; shadowOutline.InsetBy(1,1); StrokeRect(shadowOutline); startPt.Set(shadowOutline.left+1, shadowOutline.bottom); endPt.Set(shadowOutline.left+1, shadowOutline.top+1); StrokeLine(startPt, endPt); endPt.Set(shadowOutline.right, shadowOutline.top+1); StrokeLine(endPt); startPt.Set(shadowOutline.right-1, shadowOutline.top+1); endPt.Set(shadowOutline.right-1, shadowOutline.bottom-1); StrokeLine(startPt, endPt); endPt.Set(shadowOutline.left-2, shadowOutline.bottom-1); StrokeLine(endPt); // Create right hilite SetHighColor(kPaleGrey); startPt.Set(bounds.right, bounds.top); endPt.Set(bounds.right, bounds.bottom); StrokeLine(startPt, endPt); endPt.Set(bounds.left, bounds.bottom); StrokeLine(endPt); startPt.Set(bounds.right-1, bounds.top+1); endPt.Set(bounds.right-1, bounds.bottom-1); StrokeLine(startPt, endPt); endPt.Set(bounds.left, bounds.bottom-1); StrokeLine(endPt); // Create channel slot BRect slot = bounds; slot.left = (bounds.Width()/2) - 3; slot.right = (bounds.Width()/2) + 2; slot.top += 1; slot.bottom -= 3; SetHighColor(kBlack); FillRect(slot); // Draw slot hilites startPt.Set(slot.left, slot.top); endPt.Set(slot.left, slot.bottom); SetHighColor(kDarkGrey); StrokeLine(startPt, endPt); slot.top +=1; slot.left = slot.right-2; rgb_color dkGrey = {35,35,35,255}; SetHighColor(dkGrey); FillRect(slot); // Draw ticks DrawSliderTicks(); // Draw Sliders DrawSliders(); ConstrainClippingRegion( &saveRegion ); PopState(); }
void TouchpadView::Draw(BRect updateRect) { DrawSliders(); }