Example #1
0
void ScrollBar::setMajorAxisScrollBarPosition(const Pnt2f& Pos)
{

    UInt16 MajorAxis, MinorAxis;
    if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
    {
        MajorAxis = 1;
    }
    else
    {
        MajorAxis = 0;
    }
    MinorAxis = (MajorAxis+1)%2;

    //Calculate the Value Based on the Bar Position
    //Int32 ScrollValue( static_cast<Real32>(Pos - editScrollField()->getPosition()[MajorAxis])/static_cast<Real32>(editScrollField()->getSize()[MajorAxis]) * (getMaximum() - getMinimum()) + getMinimum());
    Int32 ScrollValue(calculateValueFromPosition(Pos));
    if(ScrollValue < getMinimum())
    {
        ScrollValue = getMinimum();
    }
    else if(ScrollValue + getExtent() > getMaximum())
    {
        ScrollValue = getMaximum() - getExtent();
    }
    getRangeModel()->setValue(ScrollValue);
}
Example #2
0
void
CPitchBendEditor::ZoomChanged(
	int32 diff)
{
	BRect r(Frame());
	float scroll = (ScrollValue(B_VERTICAL) + (r.bottom - r.top) / 2) / pixelsPerValue;

	verticalZoom += diff;
	if (verticalZoom > 12)
		verticalZoom = 12;
	else if (verticalZoom < 4)
		verticalZoom = 4;

	Hide();
	CalcZoom();
	SetScrollRange(scrollRange.x, scrollValue.x, stripLogicalHeight,
				   (scroll * pixelsPerValue) - (r.bottom - r.top) / 2);
	Show();
}