Ejemplo n.º 1
0
    public void click()
    {
        Rect    rect = GUIX.getClipRect();
        Vector2 pos  = ServiceLocator.getITouch().getTouchPosition();

        x = pos.x - rect.x;
        y = pos.y - rect.y;

        number.setFraction(0);
    }
Ejemplo n.º 2
0
    public override void draw(float w, float h)
    {
        // TODO: Fix offscreen issues.

        float y = 0;

        // If any of heights different, recalculate all.
        bool didChange = false;

        for (int i = 0, len = rows.Count; i < len; i++)
        {
            IRow  row = rows[i];
            float height = rowHeights[i], calcHeight = row.getPixelHeight(w);

            if (height != calcHeight)
            {
                rowHeights[i] = height;
                didChange     = true;
            }
        }

        if (didChange)
        {
            invalidateHeight();
        }

        float menuH = getPixelHeight(w);

        GUIX.fillRect(new Rect(0, 0, w, menuH), color);

        Rect  clipRect = GUIX.getClipRect();
        float cY = clipRect.y, cH = clipRect.height;

        float sH = AppRunner.getScreenHeight();

        foreach (IRow row in rows)
        {
            if (AppRunner.doHandleOffscreen && cY + y > sH)
            {
                return;
            }

            h = row.getPixelHeight(w);

            if (!AppRunner.doHandleOffscreen || cY + y + h > 0)
            {
                GUIX.beginClip(new Rect(0, y, w, h + 1));
                row.draw(w);
                GUIX.endClip();
            }

            y += row.getPixelHeight(w);
        }
    }
Ejemplo n.º 3
0
    public override void draw(float w, float h)
    {
        // TODO: Pass w/h in via draw, or constructor??
        // might not work right?

        Rect clipRect = GUIX.getClipRect();

        h = Math.Min(h, clipRect.height);

        float menuH = menu.getPixelHeight(w), scrollY;
        float heightDiff = menuH - h;

        ITouch iTouch = ServiceLocator.getITouch();

        GUIX.fillRect(new Rect(0, 0, w, h), color);

        if (heightDiff > 0)
        {
            // Scroll menu.
            if (!float.IsInfinity(prevHeightDiff))
            {
                if (heightDiff != prevHeightDiff)
                {
                    scrollFrac = -prevScrollY / heightDiff;
                }
            }

            scrollFrac = Math.Max(0, Math.Min(scrollFrac, 1));
            scrollY    = -scrollFrac * heightDiff;
        }
        else
        {
            scrollY = 0;
        }

        prevHeightDiff = heightDiff;
        prevScrollY    = scrollY;

        Vector2 scrollPosition = new Vector2(0, scrollY);

        GUIX.beginClip(new Rect(0, 0, w, h), scrollPosition);
        menu.draw(w, h);
        GUIX.endClip();

        // Draw scrollbar.
        if (heightDiff > 0)
        {
            float PADDING = 8, scrollBarWidth = CrhcConstants.PADDING_H.getAs(general.number.NumberType.PIXELS) - PADDING * 2;
            float scrollRegion    = h - 4 * PADDING - 2 * scrollBarWidth;
            float scrollBarHeight = h / menuH * scrollRegion;

            if (CrhcSettings.showScrollbar)
            {
                GUIX.beginClip(new Rect(w - PADDING - scrollBarWidth, 0, scrollBarWidth, h));

                GUIX.beginOpacity(.5f);
                TextureUtility.drawTexture(new Rect(0, PADDING, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, 90);

                float hh = scrollRegion - scrollBarHeight;
                GUIX.fillRect(new Rect(0, 2 * PADDING + scrollBarWidth + hh * scrollFrac, scrollBarWidth, scrollBarHeight));
                TextureUtility.drawTexture(new Rect(0, h - PADDING - scrollBarWidth, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, -90);
                GUIX.endOpacity();
                GUIX.endClip();
            }

            scrollFrac -= (iTouch.getDragVector().y / heightDiff);
        }
    }