Search in sources :

Example 11 with IGuiPanel

use of betterquesting.api2.client.gui.panels.IGuiPanel in project BetterQuesting by Funwayguy.

the class CanvasScrolling method onMouseScroll.

@Override
public boolean onMouseScroll(int mx, int my, int scroll) {
    if (scroll == 0 || !transform.contains(mx, my)) {
        return false;
    }
    float zs = zoomScale.readValue();
    int tx = transform.getX();
    int ty = transform.getY();
    int smx = (int) ((mx - tx) / zs) + lsx;
    int smy = (int) ((my - ty) / zs) + lsy;
    boolean used = false;
    ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
    while (pnIter.hasPrevious()) {
        IGuiPanel entry = pnIter.previous();
        if (entry.isEnabled() && entry.onMouseScroll(smx, smy, scroll)) {
            used = true;
            break;
        }
    }
    if (!used) {
        if (zoomMode) {
            // * scrollSpeed;
            float dy = -scroll * 0.05F;
            float cs = zoomScale.readValue();
            zoomScale.writeValue(cs + dy);
            this.refreshScrollBounds();
        } else if (scrollBounds.getHeight() > 0) {
            float dy = (scroll * scrollSpeed) / (float) scrollBounds.getHeight();
            float cs = scrollY.readValue();
            if (!((dy < 0F && cs <= 0F) || (dy > 0F && cs >= 1F))) {
                scrollY.writeValue(cs + dy);
                this.updatePanelScroll();
            }
        }
    }
    return used;
}
Also used : IGuiPanel(betterquesting.api2.client.gui.panels.IGuiPanel)

Aggregations

IGuiPanel (betterquesting.api2.client.gui.panels.IGuiPanel)11 Minecraft (net.minecraft.client.Minecraft)2 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1