public override void draw(float w, float h) { // TODO: Update outside of draw. // TODO: Incorporate deltaTime. // TODO: Make smooth deltaTime variables. float headerFrac = .3f, menuFrac = 1 - headerFrac; GUIX.beginClip(new Rect(0, h * headerFrac, w, h * menuFrac)); menu.draw(w, h * menuFrac); GUIX.endClip(); // Draw BG. Rect bgRect = new Rect(0, 0, w, h * headerFrac); GUIX.beginClip(bgRect); GUIX.beginColor(Color.white); TextureUtility.drawTexture(bgRect, bg, AspectType.CROP_IN_REGION); GUIX.endColor(); GUIX.endClip(); // Draw logo. float aspect = TextureUtility.getAspectRatio(logo); float logoW = w / 3, logoH = logoW / aspect; Rect logoRegion = new Rect(w - logoW, 0, logoW, logoH); logoRegion = TextureUtility.drawTexture(logoRegion, logo, AspectType.FIT_IN_REGION); if (GUIX.didTapInsideRect(logoRegion)) { onClick(); Application.OpenURL("https://www.iusb.edu/civil-rights/"); } drawTouchRing(logoRegion); }
public void drawTouchRing(Rect rect) { if (touchRing != null) { GUIX.beginClip(rect); touchRing.draw(); GUIX.endClip(); } }
public override bool draw(float w) { float h = subMenu.getPixelHeight(w); GUIX.beginClip(new Rect(0, 0, w, h)); subMenu.draw(w, h); GUIX.endClip(); return(false); }
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); } }
public override void draw(float w, float h) { // TODO: Update outside of draw. // TODO: Incorporate deltaTime. // TODO: Make smooth deltaTime variables. //float fadeDis = menu.getHeight(w); fadeDis = w; float fadeAmount = this.fadeAmount.get(); GUIX.fillRect(new Rect(0, 0, w, h), color); if (CrhcSettings.showAnimations) { GUIX.beginOpacity(fadeAmount); } /*float fadeY, menuH; * fadeY = -fadeDis * (1 - fadeInAmount); * menuH = h - fadeY; * Rect menuRect = new Rect(0, fadeY, w, menuH);*/ float fadeX = 0, menuH; menuH = h; Rect menuRect; if (CrhcSettings.showAnimations) { if (!hasEntered || isClosing) { fadeX = fadeDis * (1 - fadeAmount); } else { fadeX = -fadeDis * (1 - fadeAmount); } } menuRect = new Rect(fadeX, 0, w, menuH); GUIX.beginClip(menuRect); menu.draw(w, menuH); GUIX.endClip(); if (CrhcSettings.showAnimations) { GUIX.endOpacity(); } }
public override bool draw(float w) { // TODO: Move panel bg to draw before and after others...?????? openFrac.update(); float openF = openFrac.get(); headRow.setColor(blendColor(closedColor, openColor, openF)); if (headRow.draw(w)) { openFrac.setTargetFraction(1 - openFrac.getTargetFraction()); if (!CrhcSettings.showAnimations) { openFrac.complete(); } } float headH = headRow.getPixelHeight(w); float padding = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS), s = .6f, arrowW = padding * s; Rect arrowRect = new Rect(padding * (1 - s) / 2, headH / 2 - arrowW / 2, arrowW, arrowW); float angle = -90 * openF; TextureUtility.drawTexture(arrowRect, arrowTexture, CrhcConstants.COLOR_GRAY_DARK, AspectType.FIT_IN_REGION, angle); float h = subMenu.getPixelHeight(w) * openF; if (h > .01) { GUIX.beginClip(new Rect(0, headRow.getPixelHeight(w), w, h)); subMenu.draw(w, h); GUIX.endClip(); } return(false); }
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); } }
public override bool draw(float w) { // Create player. float padding = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS); w -= 2 * padding; float h = getPixelHeight(w); Rect region = new Rect(0, 0, w, h), paddingRegion = new Rect(padding, 0, w, h); GUIX.beginClip(paddingRegion); if (hasWaveformTexture) { GUIX.drawTexture(region, waveformTexture); ITouch iTouch = ServiceLocator.getITouch(); if (GUIX.isTouchInsideRect(region)) { if (iTouch.checkTap()) { onClick(); togglePlayPause(); } else if (!wasHeld && iTouch.isHeld()) { if (!isScrubbing) { onClick(); isScrubbing = true; pause(); } } } wasHeld = iTouch.isHeld(); if (iTouch.isDown()) { if (isScrubbing) { float len = audioClip.getResource().length; audioSource.time = Math.Max(0, Math.Min(len * (iTouch.getTouchPosition().x - padding) / w, len)); iTouch.clearDragVector(); } } else { if (isScrubbing) { isScrubbing = false; play(); } } if (!audioSource.isPlaying && playState == PlayState.PLAYING) { stop(); } if (playState != PlayState.STOPPED) { Color color = (playState == PlayState.PLAYING) ? CrhcConstants.COLOR_RED : CrhcConstants.COLOR_BLUE_DARK; float frac = audioSource.time / audioSource.clip.length, bx = w * frac, bw = 5; GUIX.fillRect(new Rect(bx - bw / 2, 0, bw, h), color); } drawTouchRing(region); } else { if (audioClip.isLoaded() && waveformTexture == null) { AudioClip_onLoad(); } GUIX.strokeRect(region, CrhcConstants.COLOR_GRAY_DARK, 1); GUIX.fillRect(new Rect(0, 0, w * progress, h), CrhcConstants.COLOR_GRAY_DARK); } GUIX.endClip(); return(false); }
public override bool draw(float w) { float x = 0, h = getPixelHeight(w); bool alreadyClicked = false; Rect position = new Rect(0, 0, w, h + 1); GUIX.fillRect(position, color); if (doXPad) { float pad = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS); w -= 2 * pad; x += pad; } float y = 0; if (doYPadTop) { y += CrhcConstants.PADDING_V.getAs(NumberType.PIXELS); h -= CrhcConstants.PADDING_V.getAs(NumberType.PIXELS); } if (doYPadBottom) { h -= CrhcConstants.PADDING_V.getAs(NumberType.PIXELS); } IItem item; float totalPriority = 0, sw; foreach (Pair pair in items) { totalPriority += pair.priority; } foreach (Pair pair in items) { item = pair.item; sw = pair.priority / totalPriority * w; GUIX.beginClip(new Rect(x, y, sw, h)); alreadyClicked = item.draw(sw, h) || alreadyClicked; GUIX.endClip(); x += sw; } drawTouchRing(position); if (doSupercedeChildClick || !alreadyClicked) { if (GUIX.didTapInsideRect(position)) { onClick(); return(true); } else { return(false); } } else { return(false); } }