void ChannelViewport::paintOverChildren( Graphics& g )
{
	juce::Rectangle<int> shadow(getLocalBounds());

	shadow.setHeight(jmin(10, getViewPositionY() - 2));  // clamps shadow pos

	if (shadow.getHeight() > 0)
	{
		shadow.setWidth(getMaximumVisibleWidth());

		ColourGradient grad(Colours::black.withAlpha(0.6f), (float)shadow.getX(), (float)shadow.getY(),
			Colours::transparentBlack, (float)shadow.getX(), (float)shadow.getBottom(), false);
		g.setGradientFill(grad);
		g.fillRect(shadow);
	}
}
Esempio n. 2
0
    void updateVisibleArea (const bool makeSureItUpdatesContent)
    {
        hasUpdated = false;

        const int newX = getViewedComponent()->getX();
        int newY = getViewedComponent()->getY();
        const int newW = jmax (owner.minimumRowWidth, getMaximumVisibleWidth());
        const int newH = owner.totalItems * owner.getRowHeight();

        if (newY + newH < getMaximumVisibleHeight() && newH > getMaximumVisibleHeight())
            newY = getMaximumVisibleHeight() - newH;

        getViewedComponent()->setBounds (newX, newY, newW, newH);

        if (makeSureItUpdatesContent && ! hasUpdated)
            updateContents();
    }
//==============================================================================
void Viewport::updateVisibleRegion()
{
    if (contentComp != 0)
    {
        const int newVX = -contentComp->getX();
        const int newVY = -contentComp->getY();

        if (newVX == 0 && newVY == 0
            && contentComp->getWidth() <= getWidth()
            && contentComp->getHeight() <= getHeight())
        {
            horizontalScrollBar->setVisible (false);
            verticalScrollBar->setVisible (false);
        }

        horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth());
        horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth());
        horizontalScrollBar->setSingleStepSize (singleStepX);

        if (! (contentComp->getWidth() > 0 && showHScrollbar && getHeight() > getScrollBarThickness()))
            horizontalScrollBar->setVisible (false);

        verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight());
        verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight());
        verticalScrollBar->setSingleStepSize (singleStepY);

        if (! (contentComp->getHeight() > 0 && showVScrollbar && getWidth() > getScrollBarThickness()))
            verticalScrollBar->setVisible (false);

        if (verticalScrollBar->isVisible())
        {
            horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth());
            verticalScrollBar->setCurrentRange (newVY, getMaximumVisibleHeight());

            verticalScrollBar
                ->setBounds (getMaximumVisibleWidth(), 0,
                             getScrollBarThickness(), getMaximumVisibleHeight());
        }

        if (horizontalScrollBar->isVisible())
        {
            horizontalScrollBar->setCurrentRange (newVX, getMaximumVisibleWidth());

            horizontalScrollBar
                ->setBounds (0, getMaximumVisibleHeight(),
                             getMaximumVisibleWidth(), getScrollBarThickness());
        }

        contentHolder->setSize (getMaximumVisibleWidth(),
                                getMaximumVisibleHeight());

        const int newVW = jmin (contentComp->getRight(),  getMaximumVisibleWidth());
        const int newVH = jmin (contentComp->getBottom(), getMaximumVisibleHeight());

        if (newVX != lastVX
             || newVY != lastVY
             || newVW != lastVW
             || newVH != lastVH)
        {
            lastVX = newVX;
            lastVY = newVY;
            lastVW = newVW;
            lastVH = newVH;

            visibleAreaChanged (newVX, newVY, newVW, newVH);

            for (int i = viewportListeners.size(); --i >= 0;)
            {
                ((ViewportListener*) viewportListeners.getUnchecked (i))
                    ->visibleAreaChanged (this, newVX, newVY, newVW, newVH);
            }
        }

        horizontalScrollBar->handleUpdateNowIfNeeded();
        verticalScrollBar->handleUpdateNowIfNeeded();
    }
    else
    {
        horizontalScrollBar->setVisible (false);
        verticalScrollBar->setVisible (false);
    }
}