コード例 #1
0
void FilmstripSlider::paint(Graphics& g)
{
	if (filmStripImage.isValid())
	{
		int value = (int) ((getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames - 1));

		int imageHeight; 
		int imageWidth;
        
		if (getTextBoxPosition() == TextBoxBelow)
        {
			imageWidth = getWidth() - getTextBoxHeight();
			imageHeight = getHeight() - getTextBoxHeight();
		}
		else
        {
			imageWidth = getWidth();
			imageHeight = getHeight();
		}
		
		if(isHorizontal)
        {
			g.drawImage(filmStripImage, (getWidth() - imageWidth) * 0.5, 0, imageWidth, imageHeight,
						value * frameWidth, 0, frameWidth, frameHeight);
        }
		else
        {
			g.drawImage(filmStripImage, 0, 0, imageWidth, imageHeight,
						0, value * frameHeight, frameWidth, frameHeight);
        }
	}
}
コード例 #2
0
void MoveAwayForFineAdjustmentSlider::resized()
{
    Slider::resized();
    
    
    // Code copied from Slider::resized (const Rectangle<int>& localBounds, LookAndFeel& lf)
    
    // TextBox height
    const int tbh = jmax (0, jmin (getTextBoxHeight(), getHeight()));
    
    // if (textBoxPos == TextBoxBelow)
    sliderRect.setBounds (0, 0, getWidth(), getHeight() - tbh);
    
    const int indent = getLookAndFeel().getSliderThumbRadius (*this);
    
    // if (isVertical())
    sliderRegionStart = sliderRect.getY() + indent;
    sliderRegionSize = jmax (1, sliderRect.getHeight() - indent * 2);
    
    sliderRect.setBounds (sliderRect.getX(), sliderRegionStart,
                          sliderRect.getWidth(), sliderRegionSize);
}