예제 #1
0
파일: guifile.cpp 프로젝트: sgynn/base
		Control* createScrollbar(const Loader& e, int o) {
			int min = e.attribute("min", 0);
			int max = e.attribute("max", 10);
			int value = e.attribute("value", min);
			int width = e.attribute("width", 0);
			int height= e.attribute("height", 0);
			int event = e.attribute("event", 0);
			if(width==0 && o==Scrollbar::VERTICAL) width=16;
			else if(height==0 && o==Scrollbar::HORIZONTAL) height=16;
			Scrollbar* c = new Scrollbar(o, width, height, min, max, e.style(), event);
			c->setValue(value);
			return c;
		}
void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)
{
    if (obj && obj->isAccessibilityScrollbar() && notification == AXValueChanged) {
        // Send document value changed on scrollbar value changed notification.
        Scrollbar* scrollBar = static_cast<AccessibilityScrollbar*>(obj)->scrollbar();
        if (!scrollBar || !scrollBar->parent() || !scrollBar->parent()->isFrameView())
            return;
        Document* document = static_cast<FrameView*>(scrollBar->parent())->frame()->document();
        if (document != document->topDocument())
            return;
        obj = get(document->renderer());
    }
    
    if (!obj || !obj->document() || !obj->documentFrameView() || !obj->documentFrameView()->frame() || !obj->documentFrameView()->frame()->page())
        return;

    ChromeClient* client = obj->documentFrameView()->frame()->page()->chrome()->client();
    if (!client)
        return;

    switch (notification) {
    case AXActiveDescendantChanged:
        if (!obj->document()->focusedNode() || (obj->node() != obj->document()->focusedNode()))
            break;

        // Calling handleFocusedUIElementChanged will focus the new active
        // descendant and send the AXFocusedUIElementChanged notification.
        handleFocusedUIElementChanged(0, obj->document()->focusedNode()->renderer());
        break;
    case AXAutocorrectionOccured:
    case AXCheckedStateChanged:
    case AXChildrenChanged:
    case AXFocusedUIElementChanged:
    case AXLayoutComplete:
    case AXLiveRegionChanged:
    case AXLoadComplete:
    case AXMenuListValueChanged:
    case AXRowCollapsed:
    case AXRowCountChanged:
    case AXRowExpanded:
    case AXScrolledToAnchor:
    case AXSelectedChildrenChanged:
    case AXSelectedTextChanged:
    case AXValueChanged:
    case AXInvalidStatusChanged:
        break;
    }

    client->postAccessibilityNotification(obj, notification);        
}
예제 #3
0
IntRect ScrollbarThemeSafari::trackRect(Scrollbar& scrollbar, bool painting)
{
    if (painting || !hasButtons(scrollbar))
        return scrollbar.frameRect();
    
    IntRect result;
    int thickness = scrollbarThickness(scrollbar.controlSize());
    if (scrollbar.orientation() == HorizontalScrollbar) 
        return IntRect(scrollbar.x() + cButtonLength[scrollbar.controlSize()], scrollbar.y(), scrollbar.width() - 2 * cButtonLength[scrollbar.controlSize()], thickness);
    return IntRect(scrollbar.x(), scrollbar.y() + cButtonLength[scrollbar.controlSize()], thickness, scrollbar.height() - 2 * cButtonLength[scrollbar.controlSize()]);
}
예제 #4
0
void ScrollbarThemeSafari::paintThumb(GraphicsContext& graphicsContext, Scrollbar& scrollbar, const IntRect& thumbRect)
{
    if (!SafariThemeLibrary())
        return;
    NSControlSize size = scrollbar.controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize;
    ThemeControlState state = 0;
    if (scrollbar.isScrollableAreaActive())
        state |= ActiveState;
    if (hasThumb(scrollbar))
        state |= EnabledState;
    if (scrollbar.pressedPart() == ThumbPart)
        state |= PressedState;
    paintThemePart(scrollbar.orientation() == VerticalScrollbar ? VScrollThumbPart : HScrollThumbPart, graphicsContext.platformContext(), 
                   thumbRect, size, state);
}
예제 #5
0
void GtkAdjustmentWatcher::adjustmentValueChanged(GtkAdjustment* adjustment)
{
    FrameView* frameView = core(m_webView)->mainFrame()->view();
    Scrollbar* scrollbar = (adjustment == m_horizontalAdjustment.get()) ? 
        frameView->horizontalScrollbar() : frameView->verticalScrollbar();
    if (!scrollbar)
        return;

    int newValue = static_cast<int>(gtk_adjustment_get_value(adjustment));
    if (newValue != scrollbar->value()) {
        m_handlingGtkAdjustmentChange = true;
        frameView->scrollToOffsetWithoutAnimation(scrollbar->orientation(), newValue);
        m_handlingGtkAdjustmentChange = false;
    }
}
예제 #6
0
bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
{
    Scrollbar* horizontalScrollbar = m_scrollableArea->horizontalScrollbar();
    Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar();

    // Accept the event if we have a scrollbar in that direction and can still
    // scroll any further.
    float deltaX = horizontalScrollbar ? e.deltaX() : 0;
    float deltaY = verticalScrollbar ? e.deltaY() : 0;

    bool handled = false;

#if PLATFORM(CHROMIUM) && !OS(DARWIN)
    ScrollGranularity granularity = e.hasPreciseScrollingDeltas() ? ScrollByPrecisePixel : ScrollByPixel;
#else
    ScrollGranularity granularity = ScrollByPixel;
#endif

    IntSize maxForwardScrollDelta = m_scrollableArea->maximumScrollPosition() - m_scrollableArea->scrollPosition();
    IntSize maxBackwardScrollDelta = m_scrollableArea->scrollPosition() - m_scrollableArea->minimumScrollPosition();
    if ((deltaX < 0 && maxForwardScrollDelta.width() > 0)
        || (deltaX > 0 && maxBackwardScrollDelta.width() > 0)
        || (deltaY < 0 && maxForwardScrollDelta.height() > 0)
        || (deltaY > 0 && maxBackwardScrollDelta.height() > 0)) {
        handled = true;

        if (deltaY) {
            if (e.granularity() == ScrollByPageWheelEvent) {
                bool negative = deltaY < 0;
                deltaY = max(max(static_cast<float>(m_scrollableArea->visibleHeight()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollableArea->visibleHeight() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
                if (negative)
                    deltaY = -deltaY;
            }
            scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
        }

        if (deltaX) {
            if (e.granularity() == ScrollByPageWheelEvent) {
                bool negative = deltaX < 0;
                deltaX = max(max(static_cast<float>(m_scrollableArea->visibleWidth()) * Scrollbar::minFractionToStepWhenPaging(), static_cast<float>(m_scrollableArea->visibleWidth() - Scrollbar::maxOverlapBetweenPages())), 1.0f);
                if (negative)
                    deltaX = -deltaX;
            }
            scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
        }
    }
    return handled;
}
예제 #7
0
IntRect ScrollbarThemeWin::trackRect(Scrollbar& scrollbar, bool)
{
    int thickness = scrollbarThickness();
    if (scrollbar.orientation() == HorizontalScrollbar) {
        if (scrollbar.width() < 2 * thickness)
            return IntRect();
        return IntRect(scrollbar.x() + thickness, scrollbar.y(), scrollbar.width() - 2 * thickness, thickness);
    }
    if (scrollbar.height() < 2 * thickness)
        return IntRect();
    return IntRect(scrollbar.x(), scrollbar.y() + thickness, thickness, scrollbar.height() - 2 * thickness);
}
예제 #8
0
void AsyncScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
{
    ASSERT(isMainThread());
    ASSERT(m_page);

    // If there isn't a root node yet, don't do anything. We'll be called again after creating one.
    if (!m_scrollingStateTree->rootStateNode())
        return;

    // Compute the region of the page that we can't do fast scrolling for. This currently includes
    // all scrollable areas, such as subframes, overflow divs and list boxes. We need to do this even if the
    // frame view whose layout was updated is not the main frame.
    Region nonFastScrollableRegion = computeNonFastScrollableRegion(&m_page->mainFrame(), IntPoint());

    // In the future, we may want to have the ability to set non-fast scrolling regions for more than
    // just the root node. But right now, this concept only applies to the root.
    setNonFastScrollableRegionForNode(nonFastScrollableRegion, m_scrollingStateTree->rootStateNode());

    if (!coordinatesScrollingForFrameView(frameView))
        return;

    ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(frameView->scrollLayerID()));
    if (!node)
        return;

    Scrollbar* verticalScrollbar = frameView->verticalScrollbar();
    Scrollbar* horizontalScrollbar = frameView->horizontalScrollbar();
    setScrollbarPaintersFromScrollbarsForNode(verticalScrollbar, horizontalScrollbar, node);

    node->setFrameScaleFactor(frameView->frame().frameScaleFactor());
    node->setHeaderHeight(frameView->headerHeight());
    node->setFooterHeight(frameView->footerHeight());

    node->setScrollOrigin(frameView->scrollOrigin());
    node->setViewportConstrainedObjectRect(FloatRect(FloatPoint(), frameView->visibleContentRect().size()));
    node->setTotalContentsSize(frameView->totalContentsSize());

    ScrollableAreaParameters scrollParameters;
    scrollParameters.horizontalScrollElasticity = frameView->horizontalScrollElasticity();
    scrollParameters.verticalScrollElasticity = frameView->verticalScrollElasticity();
    scrollParameters.hasEnabledHorizontalScrollbar = horizontalScrollbar && horizontalScrollbar->enabled();
    scrollParameters.hasEnabledVerticalScrollbar = verticalScrollbar && verticalScrollbar->enabled();
    scrollParameters.horizontalScrollbarMode = frameView->horizontalScrollbarMode();
    scrollParameters.verticalScrollbarMode = frameView->verticalScrollbarMode();

    node->setScrollableAreaParameters(scrollParameters);
}
예제 #9
0
bool ScrollbarThemeWin::shouldSnapBackToDragOrigin(Scrollbar& scrollbar, const PlatformMouseEvent& evt)
{
    // Find the rect within which we shouldn't snap, by expanding the track rect
    // in both dimensions.
    IntRect rect = trackRect(scrollbar);
    const bool horz = scrollbar.orientation() == HorizontalScrollbar;
    const int thickness = scrollbarThickness(scrollbar.controlSize());
    rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness);
    rect.inflateY((horz ? kOffSideMultiplier : kOffEndMultiplier) * thickness);

    // Convert the event to local coordinates.
    IntPoint mousePosition = scrollbar.convertFromContainingWindow(evt.position());
    mousePosition.move(scrollbar.x(), scrollbar.y());

    // We should snap iff the event is outside our calculated rect.
    return !rect.contains(mousePosition);
}
예제 #10
0
IntRect ScrollbarThemeSafari::forwardButtonRect(Scrollbar& scrollbar, ScrollbarPart part, bool painting)
{
    IntRect result;
    
    // Windows just has single arrows.
    if (part == ForwardButtonStartPart)
        return result;

    int thickness = scrollbarThickness(scrollbar.controlSize());
    if (scrollbar.orientation() == HorizontalScrollbar)
        result = IntRect(scrollbar.x() + scrollbar.width() - cButtonLength[scrollbar.controlSize()], scrollbar.y(), cButtonLength[scrollbar.controlSize()], thickness);
    else
        result = IntRect(scrollbar.x(), scrollbar.y() + scrollbar.height() - cButtonLength[scrollbar.controlSize()], thickness, cButtonLength[scrollbar.controlSize()]);
    if (painting)
        return buttonRepaintRect(result, scrollbar.orientation(), scrollbar.controlSize(), false);
    return result;
}
예제 #11
0
IntRect ScrollbarThemeSafari::backButtonRect(Scrollbar& scrollbar, ScrollbarPart part, bool painting)
{
    IntRect result;

    // Windows just has single arrows.
    if (part == BackButtonEndPart)
        return result;

    int thickness = scrollbarThickness(scrollbar.controlSize());
    if (scrollbar.orientation() == HorizontalScrollbar)
        result = IntRect(scrollbar.x(), scrollbar.y(), cButtonLength[scrollbar.controlSize()], thickness);
    else
        result = IntRect(scrollbar.x(), scrollbar.y(), thickness, cButtonLength[scrollbar.controlSize()]);
    if (painting)
        return buttonRepaintRect(result, scrollbar.orientation(), scrollbar.controlSize(), true);
    return result;
}
void PaintInvalidationCapableScrollableArea::willRemoveScrollbar(Scrollbar& scrollbar, ScrollbarOrientation orientation)
{
    if (!scrollbar.isCustomScrollbar()
        && !(orientation == HorizontalScrollbar ? layerForHorizontalScrollbar() : layerForVerticalScrollbar()))
        boxForScrollControlPaintInvalidation().invalidateDisplayItemClient(scrollbar);

    ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
}
예제 #13
0
  bool handleTabPadding(const EventArgs& e)
  {
    Scrollbar* sb = static_cast<Scrollbar*>(
      static_cast<const WindowEventArgs&>(e).window);

    // Check if the window exists
    Window* root = d_guiContext->getRootWindow();

    if (root->isChild("Frame/TabControl"))
    {
      static_cast<TabControl*>(root->getChild(
        "Frame/TabControl"))->setTabTextPadding(
        UDim(0, sb->getScrollPosition()));
    }

    return true;
  }
예제 #14
0
  bool handleTabHeight(const EventArgs& e)
  {
    Scrollbar* sb = static_cast<Scrollbar*>(
      static_cast<const WindowEventArgs&>(e).window);

    // Check if the window exists
    Window* root = d_guiContext->getRootWindow();

    if (root->isChild("Frame/TabControl"))
    {
      static_cast<TabControl*>(root->getChild(
        "Frame/TabControl"))->setTabHeight(
        UDim(0, sb->getScrollPosition()));
    }

    // The return value mainly sais that we handled it, not if something failed.
    return true;
  }
예제 #15
0
static void paintGripper(Scrollbar& scrollbar, HDC hdc, const IntRect& rect)
{
    if (!scrollbarTheme)
        return;  // Classic look has no gripper.
   
    int state;
    if (!scrollbar.enabled())
        state = TS_DISABLED;
    else if (scrollbar.pressedPart() == ThumbPart)
        state = TS_ACTIVE; // Thumb always stays active once pressed.
    else if (scrollbar.hoveredPart() == ThumbPart)
        state = TS_HOVER;
    else
        state = TS_NORMAL;

    RECT themeRect(rect);
    DrawThemeBackground(scrollbarTheme, hdc, scrollbar.orientation() == HorizontalScrollbar ? SP_GRIPPERHOR : SP_GRIPPERVERT, state, &themeRect, 0);
}
/************************************************************************
    Handle mouse wheel event
************************************************************************/
void ScrolledItemListBase::onMouseWheel(MouseEventArgs& e)
{
    ItemListBase::onMouseWheel(e);

    size_t count = getItemCount();
    Scrollbar* v = getVertScrollbar();

    // dont do anything if we are no using scrollbars
    // or have'nt got any items
    if (!v->isVisible(true) || !count)
    {
        return;
    }

    float pixH = d_pane->getUnclippedOuterRect().getHeight();
    float delta = (pixH/float(count)) * -e.wheelChange;
    v->setScrollPosition(v->getScrollPosition() + delta);
    ++e.handled;
}
예제 #17
0
void ScrollbarThemeSafari::paintButton(GraphicsContext& graphicsContext, Scrollbar& scrollbar, const IntRect& buttonRect, ScrollbarPart part)
{
    if (!SafariThemeLibrary())
        return;
    NSControlSize size = scrollbar.controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize;
    ThemeControlState state = 0;
    if (scrollbar.isScrollableAreaActive())
        state |= ActiveState;
    if (hasButtons(scrollbar))
        state |= EnabledState;
    if (scrollbar.pressedPart() == part)
        state |= PressedState;
    if (part == BackButtonStartPart)
        paintThemePart(scrollbar.orientation() == VerticalScrollbar ? ScrollUpArrowPart : ScrollLeftArrowPart, graphicsContext.platformContext(),
                       buttonRect, size, state);
    else if (part == ForwardButtonEndPart)
        paintThemePart(scrollbar.orientation() == VerticalScrollbar ? ScrollDownArrowPart : ScrollRightArrowPart, graphicsContext.platformContext(),
                       buttonRect, size, state);
}
예제 #18
0
void ScrollingCoordinatorChromium::scrollableAreaScrollbarLayerDidChange(ScrollableArea* scrollableArea, ScrollbarOrientation orientation)
{
#if OS(DARWIN)
    static const bool platformSupportsCoordinatedScrollbar = false;
    static const bool platformSupportsMainFrameOnly = false; // Don't care.
#elif OS(WINDOWS)
    static const bool platformSupportsCoordinatedScrollbar = true;
    static const bool platformSupportsMainFrameOnly = true;
#else
    static const bool platformSupportsCoordinatedScrollbar = true;
    static const bool platformSupportsMainFrameOnly = false;
#endif
    if (!platformSupportsCoordinatedScrollbar)
        return;

    bool isMainFrame = (scrollableArea == static_cast<ScrollableArea*>(m_page->mainFrame()->view()));
    if (!isMainFrame && platformSupportsMainFrameOnly)
        return;

    GraphicsLayer* scrollbarGraphicsLayer = orientation == HorizontalScrollbar ? horizontalScrollbarLayerForScrollableArea(scrollableArea) : verticalScrollbarLayerForScrollableArea(scrollableArea);
    if (scrollbarGraphicsLayer) {
        Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableArea->horizontalScrollbar() : scrollableArea->verticalScrollbar();
        if (scrollbar->isCustomScrollbar()) {
            detachScrollbarLayer(scrollbarGraphicsLayer);
            return;
        }

        WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, orientation);
        if (!scrollbarLayer)
            scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, createScrollbarLayer(scrollbar));

        // Root layer non-overlay scrollbars should be marked opaque to disable
        // blending.
        bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar();
        if (!scrollbarGraphicsLayer->contentsOpaque())
            scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollbar);
        scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaque());

        setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollingWebLayerForScrollableArea(scrollableArea));
    } else
        removeWebScrollbarLayer(scrollableArea, orientation);
}
예제 #19
0
void OptionsDialog::_buildFrameAudio()
{
#ifdef _SOUNDMANAGER_H_
	Scrollbar* sc;
	Checkbox* c;
	int y = 0;
	
	mFrameAudio->mSortable = false;
	
	new Label(mFrameAudio, "", rect(0,y), "Volume");
	sc = new Scrollbar(mFrameAudio, "vol", rect(95, y, 150, 20), HORIZONTAL, MAX_VOLUME, 10, 0, NULL);
		sc->SetValue( config.GetParamInt("sound", "volume") );
	y += 25;
	
	c = new Checkbox(mFrameAudio, "", rect(0,y), "Enable Voice Chat", 0);
		c->SetState( 0 );
		c->mHoverText = "Haha, you wish";
	y += 25;
#endif
}
예제 #20
0
    float FalagardScrollbar::getAdjustDirectionFromPoint(const Vector2f& pt) const
    {
        Scrollbar* w = (Scrollbar*)d_window;
        const Rectf& absrect(w->getThumb()->getUnclippedOuterRect().get());

        if ((d_vertical && (pt.d_y > absrect.bottom())) ||
            (!d_vertical && (pt.d_x > absrect.right())))
        {
            return 1;
        }
        else if ((d_vertical && (pt.d_y < absrect.top())) ||
            (!d_vertical && (pt.d_x < absrect.left())))
        {
            return -1;
        }
        else
        {
            return 0;
        }
    }
void ScrollableArea::scrollPositionChanged(const DoublePoint& position, ScrollType scrollType)
{
    TRACE_EVENT0("blink", "ScrollableArea::scrollPositionChanged");

    DoublePoint oldPosition = scrollPositionDouble();
    DoublePoint truncatedPosition = shouldUseIntegerScrollOffset() ? flooredIntPoint(position) : position;

    // Tell the derived class to scroll its contents.
    setScrollOffset(truncatedPosition, scrollType);

    Scrollbar* verticalScrollbar = this->verticalScrollbar();

    // Tell the scrollbars to update their thumb postions.
    if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
        horizontalScrollbar->offsetDidChange();
        if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar()) {
            if (!verticalScrollbar)
                horizontalScrollbar->invalidate();
            else {
                // If there is both a horizontalScrollbar and a verticalScrollbar,
                // then we must also invalidate the corner between them.
                IntRect boundsAndCorner = horizontalScrollbar->boundsRect();
                boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width());
                horizontalScrollbar->invalidateRect(boundsAndCorner);
            }
        }
    }
    if (verticalScrollbar) {
        verticalScrollbar->offsetDidChange();
        if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrollbar())
            verticalScrollbar->invalidate();
    }

    if (scrollPositionDouble() != oldPosition) {
        // FIXME: Pass in DoubleSize. crbug.com/414283.
        scrollAnimator()->notifyContentAreaScrolled(toFloatSize(scrollPositionDouble() - oldPosition));
    }

    scrollAnimator()->setCurrentPosition(toFloatPoint(position));
}
예제 #22
0
//----------------------------------------------------------------------------//
bool ScrollablePane::handleContentAreaChange(const EventArgs&)
{
    Scrollbar* vertScrollbar = getVertScrollbar();
    Scrollbar* horzScrollbar = getHorzScrollbar();
    
    // get updated extents of the content
    Rect contentArea(getScrolledContainer()->getContentArea());
    
    // calculate any change on the top and left edges.
    float xChange = contentArea.d_left - d_contentRect.d_left;
    float yChange = contentArea.d_top - d_contentRect.d_top;
    
    // store new content extents information
    d_contentRect = contentArea;
    
    configureScrollbars();
    
    // update scrollbar positions (which causes container pane to be moved as needed).
    horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition() - xChange);
    vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition() - yChange);
    
    // this call may already have been made if the scroll positions changed.  The call
    // is required here for cases where the top/left 'bias' has changed; in which
    // case the scroll position notification may or may not have been fired.
    if (xChange || yChange)
        updateContainerPosition();
    
    // fire event
    WindowEventArgs args(this);
    onContentPaneChanged(args);
    
    return true;
}
예제 #23
0
IntRect ScrollbarThemeWin::backButtonRect(Scrollbar& scrollbar, ScrollbarPart part, bool)
{
    // Windows just has single arrows.
    if (part == BackButtonEndPart)
        return IntRect();

    // Our desired rect is essentially 17x17.
    
    // Our actual rect will shrink to half the available space when
    // we have < 34 pixels left.  This allows the scrollbar
    // to scale down and function even at tiny sizes.
    int thickness = scrollbarThickness();
    if (scrollbar.orientation() == HorizontalScrollbar)
        return IntRect(scrollbar.x(), scrollbar.y(),
                       scrollbar.width() < 2 * thickness ? scrollbar.width() / 2 : thickness, thickness);
    return IntRect(scrollbar.x(), scrollbar.y(),
                   thickness, scrollbar.height() < 2 * thickness ? scrollbar.height() / 2 : thickness);
}
예제 #24
0
bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
{
    ScrollbarOrientation orientation;
    Scrollbar* scrollbar;
    if (direction == ScrollUp || direction == ScrollDown) {
        orientation = VerticalScrollbar;
        scrollbar = verticalScrollbar();
    } else {
        orientation = HorizontalScrollbar;
        scrollbar = horizontalScrollbar();
    }

    if (!scrollbar)
        return false;

    float step = 0;
    switch (granularity) {
    case ScrollByLine:
        step = scrollbar->lineStep();
        break;
    case ScrollByPage:
        step = scrollbar->pageStep();
        break;
    case ScrollByDocument:
        step = scrollbar->totalSize();
        break;
    case ScrollByPixel:
    case ScrollByPrecisePixel:
        step = scrollbar->pixelStep();
        break;
    case ScrollByPixelVelocity:
        break;
    }

    if (granularity != ScrollByPixelVelocity && (direction == ScrollUp || direction == ScrollLeft))
        multiplier = -multiplier;

    return scrollAnimator()->scroll(orientation, granularity, step, multiplier);
}
예제 #25
0
bool Layout::scrollEvent(GdkEventScroll* event)
{
	XOJ_CHECK_TYPE(Layout);

	Scrollbar* scroll;
	if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
	{
		scroll = this->scrollVertical;
	}
	else
	{
		scroll = this->scrollHorizontal;
	}

	if (scroll && gtk_widget_get_visible(scroll->getWidget()))
	{
		double delta = scroll->getWheelDelta(event->direction);
		scroll->scroll(delta);
		return true;
	}

	return false;
}
예제 #26
0
void ScrollableArea::scrollPositionChanged(const IntPoint& position)
{
#if PLATFORM(CHROMIUM)
    TRACE_EVENT0("webkit", "ScrollableArea::scrollPositionChanged");
#endif

    IntPoint oldPosition = scrollPosition();
    // Tell the derived class to scroll its contents.
    setScrollOffset(position);

    Scrollbar* verticalScrollbar = this->verticalScrollbar();

    // Tell the scrollbars to update their thumb postions.
    if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
        horizontalScrollbar->offsetDidChange();
        if (horizontalScrollbar->isOverlayScrollbar() && !hasLayerForHorizontalScrollbar()) {
            if (!verticalScrollbar)
                horizontalScrollbar->invalidate();
            else {
                // If there is both a horizontalScrollbar and a verticalScrollbar,
                // then we must also invalidate the corner between them.
                IntRect boundsAndCorner = horizontalScrollbar->boundsRect();
                boundsAndCorner.setWidth(boundsAndCorner.width() + verticalScrollbar->width());
                horizontalScrollbar->invalidateRect(boundsAndCorner);
            }
        }
    }
    if (verticalScrollbar) {
        verticalScrollbar->offsetDidChange();
        if (verticalScrollbar->isOverlayScrollbar() && !hasLayerForVerticalScrollbar())
            verticalScrollbar->invalidate();
    }

    if (scrollPosition() != oldPosition)
        scrollAnimator()->notifyContentAreaScrolled();
}
예제 #27
0
	void UpdateData()
	{
		double gl_rate = _pf_data[PFE_GAMELOOP].GetRate();
		this->rate_gameloop.SetRate(gl_rate, _pf_data[PFE_GAMELOOP].expected_rate);
		this->speed_gameloop.SetRate(gl_rate / _pf_data[PFE_GAMELOOP].expected_rate, 1.0);
		if (this->small) return; // in small mode, this is everything needed

		this->rate_drawing.SetRate(_pf_data[PFE_DRAWING].GetRate(), _pf_data[PFE_DRAWING].expected_rate);

		int new_active = 0;
		for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
			this->times_shortterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(8), MILLISECONDS_PER_TICK);
			this->times_longterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(NUM_FRAMERATE_POINTS), MILLISECONDS_PER_TICK);
			if (_pf_data[e].num_valid > 0) new_active++;
		}

		if (new_active != this->num_active) {
			this->num_active = new_active;
			Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
			sb->SetCount(this->num_active);
			sb->SetCapacity(min(this->num_displayed, this->num_active));
			this->ReInit();
		}
	}
예제 #28
0
void ScrollbarThemeAura::paintThumb(GraphicsContext& gc,
                                    const Scrollbar& scrollbar,
                                    const IntRect& rect) {
  if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar,
                                                  DisplayItem::kScrollbarThumb))
    return;

  DrawingRecorder recorder(gc, scrollbar, DisplayItem::kScrollbarThumb, rect);

  WebThemeEngine::State state;
  WebCanvas* canvas = gc.canvas();
  if (scrollbar.pressedPart() == ThumbPart)
    state = WebThemeEngine::StatePressed;
  else if (scrollbar.hoveredPart() == ThumbPart)
    state = WebThemeEngine::StateHover;
  else
    state = WebThemeEngine::StateNormal;

  Platform::current()->themeEngine()->paint(
      canvas, scrollbar.orientation() == HorizontalScrollbar
                  ? WebThemeEngine::PartScrollbarHorizontalThumb
                  : WebThemeEngine::PartScrollbarVerticalThumb,
      state, WebRect(rect), nullptr);
}
/************************************************************************
    Initialise
************************************************************************/
void ScrolledItemListBase::initialiseComponents()
{
    // Only process the content pane if it hasn't been done in the past
    // NOTE: This ensures that a duplicate content pane is not created. An example where
    // this would be possible would be when changing the Look'N'Feel of the widget
    // (for instance an ItemListBox), an operation which would reconstruct the child components
    // of the widget by destroying the previous ones and creating new ones with the
    // new Look'N'Feel. However, since the content pane is not defined in the
    // look and feel file and thus not associated with the look'N'Feel itself
    // but instead created here manually, the destruction would not contemplate the content
    // pane itself, so when the children would be rebuilt, a duplicate content pane
    // would be attempted (and an exception would be issued).
    if(!d_pane)
    {
        // IMPORTANT:
        // we must do this before the base class handling or we'll lose the onChildRemoved subscriber!!!
        d_pane = WindowManager::getSingletonPtr()->createWindow("ClippedContainer", d_name+ContentPaneNameSuffix);

        // set up clipping
        static_cast<ClippedContainer*>(d_pane)->setClipperWindow(this);
        addChildWindow(d_pane);
    }

    // base class handling
    ItemListBase::initialiseComponents();

    // set default pane position
    Rect r = getItemRenderArea();
    d_pane->setPosition(UVector2(cegui_absdim(r.d_left),cegui_absdim(r.d_top)));

    // init scrollbars
    Scrollbar* v = getVertScrollbar();
    Scrollbar* h = getHorzScrollbar();

    v->setAlwaysOnTop(true);
    h->setAlwaysOnTop(true);

    v->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_VScroll,this));
    h->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_HScroll,this));

    v->hide();
    h->hide();
}
예제 #30
0
void ScrollbarThemeAura::paintButton(GraphicsContext& gc,
                                     const Scrollbar& scrollbar,
                                     const IntRect& rect,
                                     ScrollbarPart part) {
  DisplayItem::Type displayItemType = buttonPartToDisplayItemType(part);
  if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar,
                                                  displayItemType))
    return;
  PartPaintingParams params =
      buttonPartPaintingParams(scrollbar, scrollbar.currentPos(), part);
  if (!params.shouldPaint)
    return;
  DrawingRecorder recorder(gc, scrollbar, displayItemType, rect);
  Platform::current()->themeEngine()->paint(
      gc.canvas(), params.part, params.state, WebRect(rect), nullptr);
}