Example usage for com.vaadin.client WidgetUtil getNativeScrollbarSize

List of usage examples for com.vaadin.client WidgetUtil getNativeScrollbarSize

Introduction

In this page you can find the example usage for com.vaadin.client WidgetUtil getNativeScrollbarSize.

Prototype

public static int getNativeScrollbarSize() 

Source Link

Usage

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VLayoutDragDropMouseHandler.java

License:Apache License

private boolean isEventOnScrollBar(NativeEvent event) {
    Element element = Element.as(event.getEventTarget());
    ;/*  w  w w . j av a  2 s  .c o  m*/

    if (WidgetUtil.mayHaveScrollBars(element)) {

        final int nativeScrollbarSize = WidgetUtil.getNativeScrollbarSize();

        int x = WidgetUtil.getTouchOrMouseClientX(event) - element.getAbsoluteLeft();
        int y = WidgetUtil.getTouchOrMouseClientY(event) - element.getAbsoluteTop();

        // Hopefully we have horizontal scroll.
        final int scrollWidth = element.getScrollWidth();
        final int clientWidth = element.getClientWidth();
        if (scrollWidth > clientWidth && clientWidth - nativeScrollbarSize < x) {
            return true;
        }

        // Hopefully we have vertical scroll.
        final int scrollHeight = element.getScrollHeight();
        final int clientHeight = element.getClientHeight();
        if (scrollHeight > clientHeight && clientHeight - nativeScrollbarSize < y) {
            return true;
        }

    }

    return false;
}

From source file:org.tltv.gantt.client.GanttConnector.java

License:Apache License

void updateDelegateTargetHeight() {
    if (delegateScrollTableTarget == null) {
        return;//from  w w w . java2 s  .c o  m
    }

    int headerHeight = 0;
    if (delegateScrollTableTarget.tHead != null) {
        // update table header height to match the Gantt widget's header
        // height
        int border = WidgetUtil.measureVerticalBorder(delegateScrollTableTarget.tHead.getElement());
        headerHeight = getWidget().getTimelineHeight();

        delegateScrollTableTarget.tHead.setHeight(Math.max(0, headerHeight - border) + "px");
    }

    int border = WidgetUtil.measureVerticalBorder(delegateScrollPanelTarget.getElement());
    // Adjust table's scroll container height to match the Gantt widget's
    // scroll container height.
    int newTableScrollContainerHeight = getWidget().getScrollContainerHeight();
    boolean tableHorScrollbarVisible = border >= WidgetUtil.getNativeScrollbarSize();
    if (getWidget().isContentOverflowingHorizontally()) {
        getWidget().hideHorizontalScrollbarSpacer();
        if (tableHorScrollbarVisible) {
            newTableScrollContainerHeight += WidgetUtil.getNativeScrollbarSize();
        }
    } else {
        if (tableHorScrollbarVisible) {
            getWidget().showHorizontalScrollbarSpacer();
        } else {
            getWidget().hideHorizontalScrollbarSpacer();
        }
    }

    delegateScrollPanelTarget.setHeight(Math.max(0, newTableScrollContainerHeight) + "px");

    getLayoutManager().setNeedsMeasure((ComponentConnector) getState().verticalScrollDelegateTarget);
}