int GUIButton::Render(void) { if (!isConditionTrue()) { mRendered = false; return 0; } int ret = 0; if (mButtonImg) ret = mButtonImg->Render(); if (ret < 0) return ret; if (hasFill) { gr_color(mFillColor.red, mFillColor.green, mFillColor.blue, mFillColor.alpha); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); } if (mButtonIcon && mButtonIcon->GetResource()) gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY); if (mButtonLabel) { int w, h; mButtonLabel->GetCurrentBounds(w, h); if (w != mTextW) { mTextW = w; } ret = mButtonLabel->Render(); if (ret < 0) return ret; } if (renderHighlight && hasHighlightColor) { gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); } mRendered = true; return ret; }
// Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked() { pagesIdentical = false; gr_color(0, 0, 0, 255); gr_clear(); if (currentIcon != NONE) { if (max_stage != -1) { int stage_height = gr_get_height(stageMarkerEmpty); int stage_width = gr_get_width(stageMarkerEmpty); int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; int y = gr_fb_height() - stage_height; for (int i = 0; i < max_stage; ++i) { GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty; gr_blit(stage_surface, 0, 0, stage_width, stage_height, x, y); x += stage_width; } } GRSurface* text_surface = GetCurrentText(); int text_x = (gr_fb_width() - gr_get_width(text_surface)) / 2; int text_y = GetTextBaseline(); gr_color(255, 255, 255, 255); gr_texticon(text_x, text_y, text_surface); } }
static int tp_test_show(TestCase* thiz) { DECLES_PRIV(priv, thiz); int i = 0; int x; int y; int width; int height; int max_points = SPRD_WIDTH_POINTS * 2 + SPRD_HEIGHT_POINTS * 2 - 4; ui_screen_clean(); gr_color(0, 255, 0, 255); ui_draw_title(UI_TITLE_START_Y, TP_TEST_CASE); for (i = 0; i < max_points; i++) { if (priv->tsinfo.point[i].pressed == 1) continue; x = priv->tsinfo.point[i].x; y = priv->tsinfo.point[i].y; width = priv->tsinfo.point[i].x + SPRD_BLOCK_WIDTH; height = priv->tsinfo.point[i].y + SPRD_BLOCK_WIDTH; gr_color(64, 96, 255, 255); gr_fill(x, y, width, height); } gr_flip(); return 0; }
static int textview_redraw(struct textview *tv) { int rc = 0; char buf[512]; //char *ptr; const char *string; int row, len; int x, y, s; int line; unsigned char r,g,b,a; pthread_mutex_lock(&gUpdateMutex); draw_background_locked(gCurrentIcon); /* background color */ gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); /* title text */ if (tv->m_title) { /* title background color */ gr_color(51, 52, 255, 160); gr_fill(0, 0, gr_fb_width(), 2 * CHAR_HEIGHT); set_gr_color(tv->m_title->color); gr_text(0, 1 * ((CHAR_HEIGHT >> 1) + CHAR_HEIGHT) - 1, tv->m_title->string); }
// Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; gr_color(0, 0, 0, 255); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); if (icon) { gr_surface surface = backgroundIcon[icon]; gr_surface text_surface = backgroundText[icon]; int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); int textWidth = gr_get_width(text_surface); int textHeight = gr_get_height(text_surface); int iconX = (gr_fb_width() - iconWidth) / 2; int iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2; int textX = (gr_fb_width() - textWidth) / 2; int textY = ((gr_fb_height() - (iconHeight+textHeight+40)) / 2) + iconHeight + 40; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); if (icon == INSTALLING_UPDATE || icon == ERASING) { draw_install_overlay_locked(installingFrame); } gr_color(255, 255, 255, 255); gr_texticon(textX, textY, text_surface); } }
static int wifi_test_run(TestCase* thiz) { DECLES_PRIV(priv, thiz); pthread_t t; pthread_create(&t, NULL, wifi_test_thread_run, (void*)thiz); ui_screen_clean(); gr_color(255, 255, 255, 255); ui_draw_title(UI_TITLE_START_Y, WIFI_TEST_CASE); gr_color(255, 0, 0, 255); ui_draw_title(gr_fb_height()/2, WIFI_WAIT_PROMPT); gr_flip(); sleep(1); pthread_mutex_lock(&wifi_lock); gr_color(0, 0, 0, 255); ui_draw_title(gr_fb_height()/2, WIFI_WAIT_PROMPT); thiz->passed = priv->passed; ui_quit_with_prompt(thiz->name, thiz->passed); pthread_mutex_unlock(&wifi_lock); return 0; }
int GUIKeyboard::Render(void) { if (!isConditionTrue()) { mRendered = false; return 0; } Layout& lay = layouts[currentLayout - 1]; if (lay.keyboardImg && lay.keyboardImg->GetResource()) gr_blit(lay.keyboardImg->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY); // Draw highlight for capslock if (hasCapsHighlight && lay.is_caps && CapsLockOn) { gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha); for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) { for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) { if ((int)lay.keys[indexy][indexx].key == KEYBOARD_LAYOUT && (int)lay.keys[indexy][indexx].layout == lay.revert_layout) { int boxheight, boxwidth, x; if (indexy == 0) boxheight = lay.row_end_y[indexy]; else boxheight = lay.row_end_y[indexy] - lay.row_end_y[indexy - 1]; if (indexx == 0) { x = mRenderX; boxwidth = lay.keys[indexy][indexx].end_x; } else { x = mRenderX + lay.keys[indexy][indexx - 1].end_x; boxwidth = lay.keys[indexy][indexx].end_x - lay.keys[indexy][indexx - 1].end_x; } gr_fill(x, mRenderY + lay.row_end_y[indexy - 1], boxwidth, boxheight); } } } } if (hasHighlight && highlightRenderCount != 0) { int boxheight, boxwidth, x; if (rowY == 0) boxheight = lay.row_end_y[rowY]; else boxheight = lay.row_end_y[rowY] - lay.row_end_y[rowY - 1]; if (colX == 0) { x = mRenderX; boxwidth = lay.keys[rowY][colX].end_x; } else { x = mRenderX + lay.keys[rowY][colX - 1].end_x; boxwidth = lay.keys[rowY][colX].end_x - lay.keys[rowY][colX - 1].end_x; } gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); gr_fill(x, mRenderY + lay.row_end_y[rowY - 1], boxwidth, boxheight); if (highlightRenderCount > 0) highlightRenderCount--; } else mRendered = true; return 0; }
int GUIFileSelector::Render(void) { // First step, fill background gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); // Next, render the background resource (if it exists) if (mBackground && mBackground->GetResource()) { mBackgroundX = mRenderX + ((mRenderW - mBackgroundW) / 2); mBackgroundY = mRenderY + ((mRenderH - mBackgroundH) / 2); gr_blit(mBackground->GetResource(), 0, 0, mBackgroundW, mBackgroundH, mBackgroundX, mBackgroundY); } // Now, we need the lines (icon + text) gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha); // This tells us how many lines we can actually render int lines = mRenderH / (mLineHeight + mLineSpacing); int line; int folderSize = mShowFolders ? mFolderList.size() : 0; int fileSize = mShowFiles ? mFileList.size() : 0; if (folderSize + fileSize < lines) lines = folderSize + fileSize; void* fontResource = NULL; if (mFont) fontResource = mFont->GetResource(); int yPos = mRenderY + (mLineSpacing / 2); for (line = 0; line < lines; line++) { Resource* icon; std::string label; if (line + mStart < folderSize) { icon = mFolderIcon; label = mFolderList.at(line + mStart).fileName; } else { icon = mFileIcon; label = mFileList.at((line + mStart) - folderSize).fileName; } if (icon && icon->GetResource()) { gr_blit(icon->GetResource(), 0, 0, mIconWidth, mIconHeight, mRenderX, yPos); } gr_textEx(mRenderX + mIconWidth + 5, yPos, label.c_str(), fontResource); // Move the yPos yPos += mLineHeight + mLineSpacing; } mUpdate = 0; return 0; }
static int menu_update_screen(Menu* thiz) { size_t i = 0; int visible_items = 0; char** p = thiz->title; // clean screen gr_color(0, 0, 0, 255); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); // draw title gr_color(64, 96, 255, 255); while (*p != NULL) { menu_draw_text_line((int)i, *p, NULL); i++; p++; } i++; // draw top line gr_fill(0, thiz->title_rows * CHAR_HEIGHT - CHAR_HEIGHT / 2 - 1, gr_fb_width(), thiz->title_rows * CHAR_HEIGHT - CHAR_HEIGHT / 2 + 1); if (thiz->title_rows + thiz->count + 1 > thiz->max_rows) { visible_items = thiz->max_rows - thiz->title_rows - 1; } else { visible_items = thiz->count; } gr_fill(0, (thiz->title_rows + thiz->menu_sel - thiz->top_menu) * CHAR_HEIGHT, gr_fb_width(), (thiz->title_rows + thiz->menu_sel - thiz->top_menu + 1) * CHAR_HEIGHT + 1); for (i = thiz->title_rows; i < thiz->title_rows + visible_items; i++) { if (i == thiz->title_rows + thiz->menu_sel - thiz->top_menu) { gr_color(255, 255, 255, 255); } else { gr_color(64, 96, 255, 255); } thiz->items[i - thiz->title_rows + thiz->top_menu].drawer(i, thiz->items[i - thiz->title_rows + thiz->top_menu].item, thiz->items[i - thiz->title_rows + thiz->top_menu].item_ctx); } gr_color(64, 96, 255, 255); // draw bottom line gr_fill(0, i * CHAR_HEIGHT + CHAR_HEIGHT / 2 - 1, gr_fb_width(), i * CHAR_HEIGHT + CHAR_HEIGHT / 2 + 1); gr_flip(); return 0; }
int GUISliderValue::Render(void) { if (!isConditionTrue()) { mRendered = false; return 0; } if(mLabel) { int w, h; mLabel->GetCurrentBounds(w, h); if (w != mLabelW) { mLabelW = w; int textX = mRenderX + (mRenderW/2 - mLabelW/2); mLabel->SetRenderPos(textX, mRenderY); } int res = mLabel->Render(); if(res < 0) return res; } // line gr_color(mLineColor.red, mLineColor.green, mLineColor.blue, mLineColor.alpha); gr_fill(mLineX, mLineY, lineW, mLineH); // slider uint32_t sliderX = (mValuePct*lineW)/100 + mLineX; sliderX -= mSliderW/2; gr_color(mSliderColor.red, mSliderColor.green, mSliderColor.blue, mSliderColor.alpha); gr_fill(sliderX, mSliderY, mSliderW, mSliderH); void *fontResource = NULL; if(mFont) fontResource = mFont->GetResource(); gr_color(mTextColor.red, mTextColor.green, mTextColor.blue, mTextColor.alpha); if(mShowRange) { int rangeY = (mLineY - mLineH/2) - mFontHeight/2; gr_textEx(mRenderX + mPadding/2, rangeY, mMinStr.c_str(), fontResource); gr_textEx(mLineX + lineW + mPadding/2, rangeY, mMaxStr.c_str(), fontResource); } if(mValueStr && mShowCurr) { sprintf(mValueStr, "%d", mValue); int textW = measureText(mValueStr); gr_textEx(mRenderX + (mRenderW/2 - textW/2), mSliderY+mSliderH, mValueStr, fontResource); } mRendered = true; return 0; }
// Redraw everything on the screen. Does not flip pages. // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { draw_background_locked(currentIcon); draw_progress_locked(); if (show_text) { gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); int i = 0; if (show_menu) { #ifndef VENDOR_EDIT //[email protected], 2012/06/11, Modify for recovery font color gr_color(64, 96, 255, 255); #else /* VENDOR_EDIT */ gr_color(41, 198, 255, 255); #endif /* VENDOR_EDIT */ gr_fill(0, (menu_top+menu_sel) * CHAR_HEIGHT, gr_fb_width(), (menu_top+menu_sel+1)*CHAR_HEIGHT+1); for (; i < menu_top + menu_items; ++i) { if (i == menu_top + menu_sel) { #ifndef VENDOR_EDIT //[email protected], 2012/06/11, Modify for recovery font color gr_color(255, 140, 0, 255); draw_text_line(i, menu[i]); gr_color(64, 96, 255, 255); #else /* VENDOR_EDIT */ gr_color(255, 255, 255, 255); draw_focus_text_line(i, menu[i]); gr_color(255, 255, 60, 255); #endif /* VENDOR_EDIT */ } else { #ifndef VENDOR_EDIT //[email protected], 2012/06/11, Modify for recovery font color gr_color(255, 140, 0, 255); #else /* VENDOR_EDIT */ gr_color(255, 230, 120, 255); #endif /* VENDOR_EDIT */ draw_text_line(i, menu[i]); } } gr_fill(0, i*CHAR_HEIGHT+CHAR_HEIGHT/2-1, gr_fb_width(), i*CHAR_HEIGHT+CHAR_HEIGHT/2+1); ++i; } gr_color(240, 255, 240, 255); //wschen 2012-07-11 for (; i < text_rows; ++i) { draw_text_line(i, text[(i+text_top) % text_rows]); } } }
void ScreenRecoveryUI::SetColor(UIElement e) { switch (e) { case INFO: gr_color(249, 194, 0, 255); break; case HEADER: gr_color(247, 0, 6, 255); break; case MENU: case MENU_SEL_BG: gr_color(0, 106, 157, 255); break; case MENU_SEL_BG_ACTIVE: gr_color(0, 156, 100, 255); break; case MENU_SEL_FG: gr_color(255, 255, 255, 255); break; case LOG: gr_color(196, 196, 196, 255); break; case TEXT_FILL: gr_color(0, 0, 0, 160); break; default: gr_color(255, 255, 255, 255); break; } }
void ScreenRecoveryUI::SetColor(UIElement e) { switch (e) { case HEADER: gr_color(111,111,111,255); break; case TOP: gr_color(208, 208, 208, 255); break; case MENU: case MENU_SEL_FG: gr_color(0, 177, 229, 255); break; case MENU_SEL_BG: gr_color(106, 103, 102, 255); break; case LOG: gr_color(76, 76, 76, 128); break; case TEXT_FILL: gr_color(0, 0, 0, 255); break; case ERROR_TEXT: gr_color(255, 0, 0, 255); break; default: gr_color(255, 255, 255, 255); break; } }
// Clear the screen and draw the currently selected background icon (if any). // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_background_locked(Icon icon) { pagesIdentical = false; gr_color(0, 0, 0, 255); gr_clear(); if (icon) { gr_surface surface = backgroundIcon[icon]; if (icon == INSTALLING_UPDATE || icon == ERASING) { surface = installation[installingFrame]; } gr_surface text_surface = backgroundText[icon]; int iconWidth = gr_get_width(surface); int iconHeight = gr_get_height(surface); int textWidth = gr_get_width(text_surface); int textHeight = gr_get_height(text_surface); int stageHeight = gr_get_height(stageMarkerEmpty); int sh = (max_stage >= 0) ? stageHeight : 0; iconX = (gr_fb_width() - iconWidth) / 2; iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2; // MStar Android Patch Begin // Add textHeight + 40 + sh may cause iconY value be negative number if (iconY < 0) { iconY = 0; } // MStar Android Patch End int textX = (gr_fb_width() - textWidth) / 2; int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40; gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY); if (stageHeight > 0) { int sw = gr_get_width(stageMarkerEmpty); int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2; int y = iconY + iconHeight + 20; for (int i = 0; i < max_stage; ++i) { gr_blit((i < stage) ? stageMarkerFill : stageMarkerEmpty, 0, 0, sw, stageHeight, x, y); x += sw; } } gr_color(255, 255, 255, 255); gr_texticon(textX, textY, text_surface); } }
static void* fm_test_show_thread(void* ctx) { TestCase* thiz = (TestCase*)ctx; DECLES_PRIV(priv, thiz); int start_y = gr_fb_height() / 4; gr_color(0, 255, 0, 255); ui_draw_title(UI_TITLE_START_Y, FM_TEST_CASE); while(priv->thread_run == 1) { if(priv->headset_in == 0) { gr_color(0, 0, 0, 255); ui_draw_title(start_y, SPRD_HEADSETIN); gr_color(255, 0, 0, 255); ui_draw_title(start_y, SPRD_HEADSETDOUT); } else { gr_color(0, 0, 0, 255); ui_draw_title(start_y, SPRD_HEADSETDOUT); gr_color(0, 255, 0, 255); ui_draw_title(start_y, SPRD_HEADSETIN); } if (priv->fm_status == FMTEST_PLAY_ERR) { gr_color(0, 0, 0, 255); ui_draw_title(start_y+CHAR_HEIGHT, SPRD_FM_OK); ui_draw_title(start_y+2*CHAR_HEIGHT, "set tune 87.5MHz"); gr_color(255, 0, 0, 255); ui_draw_title(start_y+CHAR_HEIGHT, SPRD_FM_ERROR); } else if (priv->fm_status == FMTEST_PLAY) { gr_color(0, 0, 0, 255); ui_draw_title(start_y+CHAR_HEIGHT, SPRD_FM_ERROR); gr_color(0, 255, 0, 255); ui_draw_title(start_y+CHAR_HEIGHT, SPRD_FM_OK); ui_draw_title(start_y+2*CHAR_HEIGHT, "set tune 87.5MHz"); } else if (priv->fm_status == FMTEST_STOP) { gr_color(0, 0, 0, 255); ui_draw_title(start_y+CHAR_HEIGHT, SPRD_FM_OK); ui_draw_title(start_y+2*CHAR_HEIGHT, "set tune 87.5MHz"); } gr_flip(); usleep(200000); } return NULL; }
int input_buttons() { int final_code = 0; int start_draw = 0; int end_draw = 0; gr_surface surface = gVirtualKeys; int keywidth = gr_get_width(surface) / 4; int keyoffset = (gr_fb_width() - gr_get_width(surface)) / 2; if (touch_x < (keywidth + keyoffset + 1)) { //down button final_code = KEY_DOWN; start_draw = keyoffset; end_draw = keywidth + keyoffset; } else if (touch_x < ((keywidth * 2) + keyoffset + 1)) { //up button final_code = KEY_UP; start_draw = keywidth + keyoffset + 1; end_draw = (keywidth * 2) + keyoffset; } else if (touch_x < ((keywidth * 3) + keyoffset + 1)) { //back button final_code = KEY_BACK; start_draw = (keywidth * 2) + keyoffset + 1; end_draw = (keywidth * 3) + keyoffset; } else if (touch_x < ((keywidth * 4) + keyoffset + 1)) { //enter key final_code = KEY_ENTER; start_draw = (keywidth * 3) + keyoffset + 1; end_draw = (keywidth * 4) + keyoffset; } if (touch_y > (gr_fb_height() - gr_get_height(surface)) && touch_x > 0) { pthread_mutex_lock(&gUpdateMutex); gr_color(0, 0, 0, 255); // clear old touch points gr_fill(0, gr_fb_height()-gr_get_height(surface)-2, start_draw-1, gr_fb_height()-gr_get_height(surface)); gr_fill(end_draw+1, gr_fb_height()-gr_get_height(surface)-2, gr_fb_width(), gr_fb_height()-gr_get_height(surface)); gr_color(MENU_TEXT_COLOR); gr_fill(start_draw, gr_fb_height()-gr_get_height(surface)-2, end_draw, gr_fb_height()-gr_get_height(surface)); gr_flip(); pthread_mutex_unlock(&gUpdateMutex); } if (in_touch == 1) { return final_code; } else { return 0; } }
int GUIText::Render(void) { if (!isConditionTrue()) return 0; void* fontResource = NULL; string displayValue; if (mFont) fontResource = mFont->GetResource(); mLastValue = parseText(); displayValue = mLastValue; if (charSkip) displayValue.erase(0, charSkip); mVarChanged = 0; int x = mRenderX, y = mRenderY; int width = gr_measureEx(displayValue.c_str(), fontResource); if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT) { if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY) x -= (width / 2); else x -= width; } if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT) { if (mPlacement == CENTER) y -= (mFontHeight / 2); else if (mPlacement == BOTTOM_LEFT || mPlacement == BOTTOM_RIGHT) y -= mFontHeight; } if (hasHighlightColor && isHighlighted) gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); else gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha); if (maxWidth) gr_textExW(x, y, displayValue.c_str(), fontResource, maxWidth + x); else gr_textEx(x, y, displayValue.c_str(), fontResource); return 0; }
int GUIKeyboard::Render(void) { if (!isConditionTrue()) { mRendered = false; return 0; } int ret = 0; if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource()) gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY); if (hasHighlight && highlightRenderCount != 0) { int boxheight, boxwidth, x; if (rowY == 0) boxheight = row_heights[currentLayout - 1][rowY]; else boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1]; if (colX == 0) { x = mRenderX; boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x; } else { x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x; boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x; } gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight); if (highlightRenderCount > 0) highlightRenderCount--; } else mRendered = true; return ret; }
// Draw the progress bar (if any) on the screen. Does not flip pages. // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_progress_locked() { if (currentIcon == ERROR) return; if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { draw_install_overlay_locked(installingFrame); } if (progressBarType != EMPTY) { int iconHeight = gr_get_height(backgroundIcon[INSTALLING_UPDATE]); int width = gr_get_width(progressBarEmpty); int height = gr_get_height(progressBarEmpty); int dx = (gr_fb_width() - width)/2; #if 0 //wschen 2012-07-11 int dy = (3*gr_fb_height() + iconHeight - 2*height)/4; #else int dy = (gr_fb_height() - 8 * height)/4; #endif // Erase behind the progress bar (in case this was a progress-only update) gr_color(0, 0, 0, 255); gr_fill(dx, dy, width, height); if (progressBarType == DETERMINATE) { float p = progressScopeStart + progress * progressScopeSize; int pos = (int) (p * width); if (rtl_locale) { // Fill the progress bar from right to left. if (pos > 0) { gr_blit(progressBarFill, width-pos, 0, pos, height, dx+width-pos, dy); } if (pos < width-1) { gr_blit(progressBarEmpty, 0, 0, width-pos, height, dx, dy); } } else { // Fill the progress bar from left to right. if (pos > 0) { gr_blit(progressBarFill, 0, 0, pos, height, dx, dy); } if (pos < width-1) { gr_blit(progressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); } } } if (progressBarType == INDETERMINATE) { static int frame = 0; gr_blit(progressBarIndeterminate[frame], 0, 0, width, height, dx, dy); // in RTL locales, we run the animation backwards, which // makes the spinner spin the other way. if (rtl_locale) { frame = (frame + indeterminate_frames - 1) % indeterminate_frames; } else { frame = (frame + 1) % indeterminate_frames; } } } }
// Draw the progress bar (if any) on the screen. Does not flip pages. // Should only be called with gUpdateMutex locked. static void draw_progress_locked() { if (gProgressBarType == PROGRESSBAR_TYPE_NONE) return; int iconHeight = gr_get_height(gBackgroundIcon[BACKGROUND_ICON_INSTALLING]); int width = gr_get_width(gProgressBarEmpty); int height = gr_get_height(gProgressBarEmpty); int dx = (gr_fb_width() - width)/2; int dy = (3*gr_fb_height() + iconHeight - 2*height)/4; // Erase behind the progress bar (in case this was a progress-only update) gr_color(0, 0, 0, 255); gr_fill(dx, dy, width, height); if (gProgressBarType == PROGRESSBAR_TYPE_NORMAL) { float progress = gProgressScopeStart + gProgress * gProgressScopeSize; int pos = (int) (progress * width); if (pos > 0) { gr_blit(gProgressBarFill, 0, 0, pos, height, dx, dy); } if (pos < width-1) { gr_blit(gProgressBarEmpty, pos, 0, width-pos, height, dx+pos, dy); } } if (gProgressBarType == PROGRESSBAR_TYPE_INDETERMINATE) { static int frame = 0; gr_blit(gProgressBarIndeterminate[frame], 0, 0, width, height, dx, dy); frame = (frame + 1) % PROGRESSBAR_INDETERMINATE_STATES; } }
static void menu_draw_text_line(int row, const char* t, void* ctx) { if (t[0] != '\0') { gr_text(0, (row+1)*CHAR_HEIGHT-1, t); gr_color(64, 96, 255, 255); } }
static int version_test_run(TestCase* thiz) { DECLES_PRIV(priv, thiz); char display_id[64]; char tmpbuf[64]; char* buf; int res; priv->start_y = 50; ui_screen_clean(); gr_color(255, 255, 255, 255); ui_draw_title(UI_TITLE_START_Y, VERSION_TEST_CASE); gr_color(0, 255, 0, 255); // get display id memset(display_id, 0, sizeof(display_id)); property_get(PROP_DISPLAY_ID, display_id, ""); LOGE("%s: %s\n", __FUNCTION__, display_id); buf = (char*)malloc(strlen(display_id) + 10); memset(buf, 0, strlen(display_id) + 10); sprintf(buf, "%s %s", "Version:", display_id); version_test_output_multi_line(thiz, buf); free(buf); // output custom id memset(tmpbuf, 0, sizeof(tmpbuf)); property_get(PROP_CUSTOMER_ID, tmpbuf, ""); buf = (char*)malloc(strlen(tmpbuf) + 15); memset(buf, 0, strlen(tmpbuf) + 15); sprintf(buf, "%s %s", "Customer ID:", tmpbuf); version_test_output_multi_line(thiz, buf); free(buf); version_test_input_devices(thiz); gr_flip(); res = ui_draw_handle_softkey(thiz->name); thiz->passed = res; LOGE("%s: vesion test passed is %d", __func__, thiz->passed); return 0; }
void GUIConsole::RenderItem(size_t itemindex, int yPos, bool selected) { // Set the color for the font if (rConsoleColor[itemindex] == "normal") { gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha); } else { COLOR FontColor; std::string color = rConsoleColor[itemindex]; ConvertStrToColor(color, &FontColor); FontColor.alpha = 255; gr_color(FontColor.red, FontColor.green, FontColor.blue, FontColor.alpha); } // render text const char* text = rConsole[itemindex].c_str(); gr_textEx(mRenderX, yPos, text, mFont->GetResource()); }
// Redraw everything on the screen. Does not flip pages. // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { if (!show_text) { draw_background_locked(currentIcon); draw_progress_locked(); } else { gr_color(0, 0, 0, 255); gr_clear(); int y = 0; if (show_menu) { char recovery_fingerprint[PROPERTY_VALUE_MAX]; property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, ""); SetColor(INFO); DrawTextLine(&y, "Android Recovery", true); for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) { DrawTextLine(&y, chunk.c_str(), false); } DrawTextLines(&y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP); SetColor(HEADER); DrawTextLines(&y, menu_headers_); SetColor(MENU); DrawHorizontalRule(&y); y += 4; for (int i = 0; i < menu_items; ++i) { if (i == menu_sel) { // Draw the highlight bar. SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG); gr_fill(0, y - 2, gr_fb_width(), y + char_height + 2); // Bold white text for the selected item. SetColor(MENU_SEL_FG); gr_text(4, y, menu_[i], true); SetColor(MENU); } else { gr_text(4, y, menu_[i], false); } y += char_height + 4; } DrawHorizontalRule(&y); } // display from the bottom up, until we hit the top of the // screen, the bottom of the menu, or we've displayed the // entire text buffer. SetColor(LOG); int row = (text_top_ + text_rows_ - 1) % text_rows_; size_t count = 0; for (int ty = gr_fb_height() - char_height; ty >= y && count < text_rows_; ty -= char_height, ++count) { gr_text(0, ty, text_[row], false); --row; if (row < 0) row = text_rows_ - 1; } } }
// Redraw everything on the screen. Does not flip pages. // Should only be called with updateMutex locked. void ScreenRecoveryUI::draw_screen_locked() { if (!show_text) { draw_background_locked(currentIcon); draw_progress_locked(); // MStar Android Patch Begin draw_top_title_locked(); draw_tip_title_locked(currentTip); draw_exit_recovery_tip_title_locked(currentExitRecoveryTip); // MStar Android Patch End } else { gr_color(0, 0, 0, 255); gr_clear(); int y = 0; int i = 0; if (show_menu) { SetColor(HEADER); for (; i < menu_top + menu_items; ++i) { if (i == menu_top) SetColor(MENU); if (i == menu_top + menu_sel) { // draw the highlight bar SetColor(MENU_SEL_BG); gr_fill(0, y-2, gr_fb_width(), y+char_height+2); // white text of selected item SetColor(MENU_SEL_FG); if (menu[i][0]) gr_text(4, y, menu[i], 1); SetColor(MENU); } else { if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top); } y += char_height+4; } SetColor(MENU); y += 4; gr_fill(0, y, gr_fb_width(), y+2); y += 4; ++i; } SetColor(LOG); // display from the bottom up, until we hit the top of the // screen, the bottom of the menu, or we've displayed the // entire text buffer. int ty; int row = (text_top+text_rows-1) % text_rows; for (int ty = gr_fb_height() - char_height, count = 0; ty > y+2 && count < text_rows; ty -= char_height, ++count) { gr_text(4, ty, text[row], 0); --row; if (row < 0) row = text_rows-1; } } }
int GUIConsole::RenderConsole(void) { void* fontResource = NULL; if (mFont) fontResource = mFont->GetResource(); // We fill the background gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255); gr_fill(mConsoleX, mConsoleY, mConsoleW, mConsoleH); gr_color(mScrollColor.red, mScrollColor.green, mScrollColor.blue, mScrollColor.alpha); gr_fill(mConsoleX + (mConsoleW * 9 / 10), mConsoleY, (mConsoleW / 10), mConsoleH); // Render the lines gr_color(mForegroundColor.red, mForegroundColor.green, mForegroundColor.blue, mForegroundColor.alpha); // Don't try to continue to render without data mLastCount = gConsole.size(); if (mLastCount == 0) return (mSlideout ? RenderSlideout() : 0); // Find the start point int start; int curLine = mCurrentLine; // Thread-safing (Another thread updates this value) if (curLine == -1) { start = mLastCount - mMaxRows; } else { if (curLine > (int) mLastCount) curLine = (int) mLastCount; if ((int) mMaxRows > curLine) curLine = (int) mMaxRows; start = curLine - mMaxRows; } unsigned int line; for (line = 0; line < mMaxRows; line++) { if ((start + (int) line) >= 0 && (start + (int) line) < (int) mLastCount) { gr_textExW(mConsoleX, mStartY + (line * mFontHeight), gConsole[start + line].c_str(), fontResource, mConsoleW + mConsoleX); } } return (mSlideout ? RenderSlideout() : 0); }
int GUIButton::Render(void) { if (!isConditionTrue()) { mRendered = false; return 0; } int ret = 0; if (mButtonImg) ret = mButtonImg->Render(); if (ret < 0) return ret; if (hasFill) { gr_color(mFillColor.red, mFillColor.green, mFillColor.blue, mFillColor.alpha); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); } if (mButtonIcon && mButtonIcon->GetResource()) gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY); if (mButtonLabel) { int w, h; mButtonLabel->GetCurrentBounds(w, h); if (w != mTextW) { mTextW = w; if (TextPlacement == CENTER_X_ONLY) { mTextX = ((mRenderW - mRenderX) / 2); } else if (mTextW > mRenderW) { // As a special case, we'll allow large text which automatically moves it to the right. mTextX = mRenderW + mRenderX + 5; mRenderW += mTextW + 5; } else { mTextX = mRenderX + ((mRenderW - mTextW) / 2); } mButtonLabel->SetRenderPos(mTextX, mTextY); } ret = mButtonLabel->Render(); if (ret < 0) return ret; } if (renderHighlight && hasHighlightColor) { gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); } mRendered = true; return ret; }
// Redraw everything on the screen. Does not flip pages. // Should only be called with gUpdateMutex locked. static void draw_screen_locked(void) { if (!ui_has_initialized) return; draw_background_locked(gCurrentIcon); draw_progress_locked(); if (show_text) { gr_color(0, 0, 0, 160); gr_fill(0, 0, gr_fb_width(), gr_fb_height()); int i = 0; int j = 0; int row = 0; // current row that we are drawing on if (show_menu) { gr_color(MENU_TEXT_COLOR); gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT, gr_fb_width(), (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1); gr_color(HEADER_TEXT_COLOR); for (i = 0; i < menu_top; ++i) { draw_text_line(i, menu[i]); row++; } if (menu_items - menu_show_start + menu_top >= MAX_ROWS) j = MAX_ROWS - menu_top; else j = menu_items - menu_show_start; gr_color(MENU_TEXT_COLOR); for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) { if (i == menu_top + menu_sel) { gr_color(255, 255, 255, 255); draw_text_line(i - menu_show_start , menu[i]); gr_color(MENU_TEXT_COLOR); } else { gr_color(MENU_TEXT_COLOR); draw_text_line(i - menu_show_start, menu[i]); } row++; } gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1, gr_fb_width(), row*CHAR_HEIGHT+CHAR_HEIGHT/2+1); } gr_color(NORMAL_TEXT_COLOR); for (; row < text_rows; ++row) { draw_text_line(row, text[(row+text_top) % text_rows]); } } }
static int bluetooth_test_run(TestCase* thiz) { int hci_sock; int attempt; ui_screen_clean(); gr_color(255, 255, 255, 255); ui_draw_title(UI_TITLE_START_Y, BLUETOOTH_TEST_CASE); gr_color(64, 96, 255, 255); ui_draw_title(gr_fb_height()/2, BT_PROMPT); gr_flip(); system("hciconfig hci0 down"); usleep(10000); for (attempt = 500; attempt > 0; attempt--) { hci_sock = create_hci_socket(); if (hci_sock < 0) { attempt = 0; break; } if (!ioctl(hci_sock, HCIDEVUP, 0)) { break; } close(hci_sock); usleep(10000); } gr_color(0, 0, 0, 255); ui_draw_title(gr_fb_height()/2, BT_PROMPT); system("hciconfig hci0 down"); usleep(10000); thiz->passed = (attempt == 0) ? 0 : 1; ui_quit_with_prompt(thiz->name, thiz->passed); return 0; }
void ui_rainbow_mode() { static int colors[] = { 255, 0, 0, // red 255, 127, 0, // orange 255, 255, 0, // yellow 0, 255, 0, // green 60, 80, 255, // blue 143, 0, 255 }; // violet gr_color(colors[cur_rainbow_color], colors[cur_rainbow_color+1], colors[cur_rainbow_color+2], 255); cur_rainbow_color += 3; if (cur_rainbow_color >= sizeof(colors)/sizeof(colors[0])) cur_rainbow_color = 0; }