Example #1
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);
    }
// 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;
        }
    }
}
Example #3
0
// 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;
        }
    }
}
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with gUpdateMutex locked.
static void draw_screen_locked(void)
{
    draw_background_locked(gCurrentIcon);
    if (show_text) {
        gr_color(0, 0, 0, 160);
        gr_fill(0, 0, gr_fb_width(), gr_fb_height());

        int i = 0, j = 0;
        int k = menu_top + 1; //counter for bottom horizontal text line location
        if (show_menu) {

            //menu line item selection highlight draws
            gr_color(255, 255, 255, 255);
            gr_fill(0, (menu_top + menu_sel - menu_show_start+1) * CHAR_HEIGHT,
                    gr_fb_width(), CHAR_HEIGHT+1);

            //draw semi-static headers
            for (i = 0; i < menu_top; ++i) {
                gr_color(200, 200, 200, 200);
                draw_text_line(i, menu[i]);
                //LOGI("Semi-static headers internal counter i: %i\n", i);
            }

            //adjust counter for current position of selection and menu display starting point
            if (menu_items - menu_show_start + menu_top >= text_rows){
                j = text_rows - menu_top;
                //LOGI("j = text_rows - mneu_top and j = %i\n", j);
           } else {
                j = menu_items - menu_show_start;
                //LOGI("j = mneu_items - menu_show_start and j = %i\n", j);
           }
            //LOGI("outside draw menu items for loop and i goes until limit. limit-menu_show_start + menu_top + j = %i\n", menu_show_start + menu_top + j);
            //draw menu items dynamically based on current menu starting position, menu selection point and headers
             for (i = menu_show_start + menu_top; i < (menu_show_start + menu_top + j); ++i) {
                //LOGI("inside draw menu items for loop and i = %i\n", i);
                if (i == menu_top + menu_sel) {
                    gr_color(200, 200, 200, 200);
                    //LOGI("draw_text_line -menu_item_when_highlighted_color- at i + 1= %i\n", i+1);
                    draw_text_line(i - menu_show_start +1, menu[i]);
                } else {
                    gr_color(200, 200, 200, 200);
                    //LOGI("draw_text_line -menu_item_color- at i + 1= %i\n", i+1);
                    draw_text_line(i - menu_show_start +1, menu[i]);
                }
                //LOGI("inside draw menu items for loop and k = %i\n", k);
                k++;
            }
        }

        k++; //keep ui_print below menu items display
        gr_color(200, 200, 200, 200); //called by at least ui_print
        for (; k < text_rows; ++k) {
            draw_text_line(k, text[(k+text_top) % text_rows]);
        }
    }
}
Example #5
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]);
        }
    }
}
Example #6
0
// 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]);
        }
    }
}
Example #7
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);

    if (DialogShowing()) {
        draw_dialog();
        return;
    }

    SetColor(MENU);

    if (show_text) {

        if (currentIcon != ERASING && currentIcon != INSTALLING_UPDATE)
            draw_header_icon();

        if (currentIcon == ERASING || currentIcon == INSTALLING_UPDATE || currentIcon == VIEWING_LOG) {
            int y = currentIcon == INSTALLING_UPDATE ? gr_fb_height() / 4 : header_height + 4;

            SetColor(LOG);
            int cx, cy;
            gr_set_font("log");
            gr_font_size(&cx, &cy);
            // display from the bottom up, until we hit the top of the
            // screen or we've displayed the entire text buffer.
            int row = (text_first_row+log_text_rows-1) % log_text_rows;
            for (int ty = gr_fb_height() - cy, count = 0;
                 ty > y+2 && count < log_text_rows;
                 ty -= (cy+2), ++count) {
                gr_text(4, ty, text[row], 0);
                --row;
                if (row < 0) row = log_text_rows-1;
            }
            return;
        }

        if (show_menu) {
            gr_set_font("menu");

            int nr_items = menu_items - menu_show_start;
            if (nr_items > max_menu_rows)
                nr_items = max_menu_rows;
            for (int i = 0; i < nr_items; ++i) {
                draw_menu_item(text_first_row + 3*i, menu[menu_show_start+i],
                        ((menu_show_start+i) == menu_sel));
            }
        }
    }
}
Example #8
0
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with gUpdateMutex locked.
static void draw_screen_locked(void)
{
    draw_background_locked(gCurrentIcon);
    if (show_text) {
        /* background color */
        gr_color(0, 0, 0, 160);
        gr_fill(0, 0, gr_fb_width(), gr_fb_height());

        /* title background color */
        gr_color(51, 52, 255, 160);
        gr_fill(0, 0, gr_fb_width(), CHAR_HEIGHT);

        /* title text */
        set_gr_color(COLOR_YELLOW);
        draw_menu_text(0, menu[0]);

        int i = 1;
        if (show_menu) {
            gr_color(64, 96, 255, 160);            
            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) {
                    set_gr_color(COLOR_YELLOW);
                    draw_menu_text(i, menu[i]);
                    gr_color(64, 96, 255, 160);
                } else {
                    gr_color(120, 120, 255, 160);
                    draw_menu_text(i, menu[i]);
                    gr_color(64, 96, 255, 160);
                }
                gr_fill(0, i * CHAR_HEIGHT + CHAR_HEIGHT/2-1,
                        gr_fb_width(), 1);
            }
            gr_fill(0, i*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
                    gr_fb_width(), i*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
            ++i;
        }

        /* printed text color */
        set_gr_color(COLOR_YELLOW);

        int j = 0;
        for (; i < text_rows; ++i)
            draw_menu_text(i, text[j++]);
    }
}
char *ui_copy_image(int icon, int *width, int *height, int *bpp) {
    pthread_mutex_lock(&gUpdateMutex);
    draw_background_locked(icon);
    *width = gr_fb_width();
    *height = gr_fb_height();
    *bpp = sizeof(gr_pixel) * 8;
    int size = *width * *height * sizeof(gr_pixel);
    char *ret = malloc(size);
    if (ret == NULL) {
        LOGE("Can't allocate %d bytes for image\n", size);
    } else {
        memcpy(ret, gr_fb_data(), size);
    }
    pthread_mutex_unlock(&gUpdateMutex);
    return ret;
}
Example #10
0
static void show_slash_draw_screen_locked(const char * msg)
{
    draw_background_locked(gCurrentIcon);
   
    // background color
    gr_color(0, 0, 0, 160);
    gr_fill(0, 0, gr_fb_width(), gr_fb_height());
  
    // printed text color 
    set_gr_color(COLOR_YELLOW);
 

    if (msg[0] != '\0') {
        //gr_text_scale(1, (1)*CHAR_HEIGHT-1, msg, 2); //will use this in future
        gr_text(1, (1)*CHAR_HEIGHT-1, msg);
    }
    
}
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with gUpdateMutex locked.
static void draw_screen_locked(void)
{
    int cRv = 54;
    int cGv = 74;
    int cBv = 255;

    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;
        if (show_menu) {
            gr_color(cRv,cGv,cBv,255);
            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) {
                    gr_color(255, 255, 255, 255);
                    draw_text_line(i, menu[i]);
                    gr_color(cRv,cGv,cBv,255);
                } else {
                    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;
        }

        TEXTCOLOR

        for (; i < text_rows; ++i) {
            draw_text_line(i, text[(i+text_top) % text_rows]);
        }
    }
}
Example #12
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) {
            gr_color(64, 96, 255, 255);
            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) {
                    gr_color(255, 255, 255, 255);
                    draw_text_line(i, menu[i]);
                    gr_color(64, 96, 255, 255);
                } else {
                    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(255, 255, 0, 255);

        for (; i < text_rows; ++i) {
            draw_text_line(i, text[(i+text_top) % text_rows]);
        }
    }
}
// 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) {
        int total_rows = (gr_fb_height() - virtualkey_h) / CHAR_HEIGHT;
        int i = 0;
        int j = 0;
        int row = 0; // current row that we are drawing on
        if (show_menu) {
            int batt_level = 0;
            char batt_text[40];
            batt_level = get_batt_stats();

            /*struct tm *current;
            time_t now;
            now = time(NULL); // add 2 hours
            current = localtime(&now);
            sprintf(batt_text, "[%d%% %02D:%02D]", batt_level, current->tm_hour, current->tm_min);
            if (now == NULL)*/
            sprintf(batt_text, " [%d%%]", batt_level);

            gr_color(menuTextColor[0], menuTextColor[1], menuTextColor[2], menuTextColor[3]);
            //gr_color(0, 255, 0, 255);
            if (batt_level < 21)
                gr_color(255, 0, 0, 255);
            draw_text_line(0, batt_text, RIGHT_ALIGN);

            gr_color(menuTextColor[0], menuTextColor[1], menuTextColor[2], menuTextColor[3]);
            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], LEFT_ALIGN);
                row++;
            }

            if (menu_items - menu_show_start + menu_top >= max_menu_rows)
                j = max_menu_rows - menu_top;
            else
                j = menu_items - menu_show_start;

            gr_color(menuTextColor[0], menuTextColor[1], menuTextColor[2], menuTextColor[3]);
            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], LEFT_ALIGN);
                    gr_color(menuTextColor[0], menuTextColor[1], menuTextColor[2], menuTextColor[3]);
                } else {
                    gr_color(menuTextColor[0], menuTextColor[1], menuTextColor[2], menuTextColor[3]);
                    draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN);
                }
                row++;
                if (row >= max_menu_rows)
                    break;
            }

            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);
        int cur_row = text_row;
        int available_rows = total_rows - row - 1;
        int start_row = row + 1;
        if (available_rows < MAX_ROWS)
            cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
        else
            start_row = total_rows - MAX_ROWS;

        int r;
        for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS], LEFT_ALIGN);
        }
    }
#ifdef USE_VIRTUAL_KEY
    draw_virtualkeys_locked();
#endif
}
// 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) {
        // don't "disable" the background anymore with this...
        // gr_color(0, 0, 0, 160);
        // gr_fill(0, 0, gr_fb_width(), gr_fb_height());

        int total_rows = gr_fb_height() / CHAR_HEIGHT;
        int i = 0;
        int j = 0;
        int row = 0;            // current row that we are drawing on
        if (show_menu) {
#ifndef BOARD_TOUCH_RECOVERY
            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_menu_rows)
                j = max_menu_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++;
                if (row >= max_menu_rows)
                    break;
            }

            gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
                    gr_fb_width(), row*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
#else
            row = draw_touch_menu(menu, menu_items, menu_top, menu_sel, menu_show_start);
#endif
        }

        gr_color(NORMAL_TEXT_COLOR);
        int cur_row = text_row;
        int available_rows = total_rows - row - 1;
        int start_row = row + 1;
        if (available_rows < MAX_ROWS)
            cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
        else
            start_row = total_rows - MAX_ROWS;

        int r;
        for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS]);
        }
    }
}
Example #15
0
// 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) {
        // don't "disable" the background anymore with this...
        // gr_color(0, 0, 0, 160);
        // gr_fill(0, 0, gr_fb_width(), gr_fb_height());

        int total_rows = gr_fb_height() / CHAR_HEIGHT;
        int i = 0;
        int j = 0;
        int row = 0;            // current row that we are drawing on
        if (show_menu) {
#ifndef BOARD_TOUCH_RECOVERY
            gr_color(MENU_TEXT_COLOR);

      int batt_level = 0;
            batt_level = get_batt_stats();
            
            if(batt_level < 20) {
                gr_color(255, 0, 0, 255);
            }
            
			struct tm *current;
			time_t now;
			now = time(NULL) + (3600 * 8); // add 8 hours
			current = localtime(&now);
            
            char batt_text[40];
            sprintf(batt_text, "[%d%% %02D:%02D]", batt_level, current->tm_hour, current->tm_min);
            if (now == NULL) { // just in case
				sprintf(batt_text, "[%d%%]", batt_level);
			}

            gr_color(MENU_TEXT_COLOR);
            draw_text_line(0, batt_text, RIGHT_ALIGN);

            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]);
                draw_text_line(i, menu[i], LEFT_ALIGN);
                row++;
            }

            if (menu_items - menu_show_start + menu_top >= max_menu_rows)
                j = max_menu_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]);
                    draw_text_line(i - menu_show_start , menu[i], LEFT_ALIGN);
                    gr_color(MENU_TEXT_COLOR);
                } else {
                    gr_color(MENU_TEXT_COLOR);
//                    draw_text_line(i - menu_show_start, menu[i]);
                    draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN);
                }
                row++;
                if (row >= max_menu_rows)
                    break;
            }

            gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
                    gr_fb_width(), row*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
#else
            row = draw_touch_menu(menu, menu_items, menu_top, menu_sel, menu_show_start);
#endif
        }

        gr_color(NORMAL_TEXT_COLOR);
        int cur_row = text_row;
        int available_rows = total_rows - row - 1;
        int start_row = row + 1;
        if (available_rows < MAX_ROWS)
            cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
        else
            start_row = total_rows - MAX_ROWS;

        int r;
        for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
//            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS]);
            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS], LEFT_ALIGN);
        }
    }
}
// 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 total_rows = gr_fb_height() / CHAR_HEIGHT;
        int i = 0;
        int j = 0;
        int offset = 0;         // offset of separating bar under menus
        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_menu_rows)
                j = max_menu_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++;
                if (row >= max_menu_rows)
                    break;
            }

            if (menu_items <= max_menu_rows)
                offset = 1;

            gr_fill(0, (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
                    gr_fb_width(), (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
        }

        gr_color(NORMAL_TEXT_COLOR);
        int cur_row = text_row;
        int available_rows = total_rows - row - 1;
        int start_row = row + 1;
        if (available_rows < MAX_ROWS)
            cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
        else
            start_row = total_rows - MAX_ROWS;

        int r;
        for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS]);
        }
    }
}
// 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;

	//In this case MENU_SELECT icon has maximum possible height.
	int menu_max_height = gr_get_height(gMenuIcon[MENU_SELECT]);
	struct { int x; int y; } MENU_ICON[] = {
		{  gr_fb_width() - menu_max_height, 7*gr_fb_height()/8 },
		{  gr_fb_width() - menu_max_height,	5*gr_fb_height()/8 },
		{  gr_fb_width() - menu_max_height,	3*gr_fb_height()/8 },
		{  gr_fb_width() - menu_max_height,	1*gr_fb_height()/8 }, 
	};

    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) {

			draw_icon_locked(gMenuIcon[MENU_BACK], MENU_ICON[MENU_BACK].x, MENU_ICON[MENU_BACK].y );
			draw_icon_locked(gMenuIcon[MENU_DOWN], MENU_ICON[MENU_DOWN].x, MENU_ICON[MENU_DOWN].y);
			draw_icon_locked(gMenuIcon[MENU_UP], MENU_ICON[MENU_UP].x, MENU_ICON[MENU_UP].y );
			draw_icon_locked(gMenuIcon[MENU_SELECT], MENU_ICON[MENU_SELECT].x, MENU_ICON[MENU_SELECT].y );
            gr_color(MENU_TEXT_COLOR);
            gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT,
                    gr_fb_width()-menu_max_height*2, (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()-menu_max_height*2, 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]);
        }
    }
}
Example #18
0
// 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) {
        // don't "disable" the background anymore with this...
        // gr_color(0, 0, 0, 160);
        // gr_fill(0, 0, gr_fb_width(), gr_fb_height());

	gr_surface surface = gVirtualKeys;
        int total_rows = (gr_fb_height() / CHAR_HEIGHT) - (gr_get_height(surface) / CHAR_HEIGHT) - 1;
        int i = 0;
        int j = 0;
        int offset = 0;         // offset of separating bar under menus
        int row = 0;            // current row that we are drawing on
	if (show_menu) {
            gr_color(MENU_TEXT_COLOR);
            int batt_level = 0;
            batt_level = get_batt_stats();
            if (batt_level < 21) {
                gr_color(255, 0, 0, 255);
            }
            char batt_text[40];
            sprintf(batt_text, "[%d%%]", batt_level);
            draw_text_line(0, batt_text, RIGHT_ALIGN);

            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], LEFT_ALIGN);
                row++;
            }

            if (menu_items - menu_show_start + menu_top >= max_menu_rows)
                j = max_menu_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], LEFT_ALIGN);
                    gr_color(MENU_TEXT_COLOR);
                } else {
                    gr_color(MENU_TEXT_COLOR);
                    draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN);
                }
                row++;
                if (row >= max_menu_rows)
                    break;
            }

            if (menu_items <= max_menu_rows)
                offset = 0;

            gr_fill(0, (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
                    gr_fb_width(), (row-offset)*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
        }

        gr_color(NORMAL_TEXT_COLOR);
        int cur_row = text_row;
        int available_rows = total_rows - row - 1;
        int start_row = row + 1;
        if (available_rows < MAX_ROWS)
            cur_row = (cur_row + (MAX_ROWS - available_rows)) % MAX_ROWS;
        else
            start_row = total_rows - MAX_ROWS;

        int r;
        for (r = 0; r < (available_rows < MAX_ROWS ? available_rows : MAX_ROWS); r++) {
            draw_text_line(start_row + r, text[(cur_row + r) % MAX_ROWS], LEFT_ALIGN);
        }
    }
    draw_virtualkeys_locked(); //added to draw the virtual keys
}
Example #19
0
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with gUpdateMutex locked.
void draw_screen_locked(void)
{
	if (!ui_has_initialized) return;
#ifdef BUILD_IN_LANDSCAPE
		//In this case MENU_SELECT icon has maximum possible height.
		int menu_max_height = gr_get_height(gMenuIcon[MENU_SELECT]);
		struct { int x; int y; } MENU_ICON[] = {
			{  gr_fb_width() - menu_max_height, 7*gr_fb_height()/8 },
			{  gr_fb_width() - menu_max_height,	5*gr_fb_height()/8 },
			{  gr_fb_width() - menu_max_height,	3*gr_fb_height()/8 },
			{  gr_fb_width() - menu_max_height,	1*gr_fb_height()/8 }, 
#else
//ToDo: Following structure should be global
		struct { int x; int y; int xL; int xR; } MENU_ICON[] = {
			{  get_menu_icon_info(MENU_BACK,MENU_ICON_X),	get_menu_icon_info(MENU_BACK,MENU_ICON_Y), get_menu_icon_info(MENU_BACK,MENU_ICON_XL), get_menu_icon_info(MENU_BACK,MENU_ICON_XR) },
			{  get_menu_icon_info(MENU_DOWN,MENU_ICON_X),	get_menu_icon_info(MENU_DOWN,MENU_ICON_Y), get_menu_icon_info(MENU_DOWN,MENU_ICON_XL), get_menu_icon_info(MENU_DOWN,MENU_ICON_XR) },
			{  get_menu_icon_info(MENU_UP,MENU_ICON_X),	get_menu_icon_info(MENU_UP,MENU_ICON_Y), get_menu_icon_info(MENU_UP,MENU_ICON_XL), get_menu_icon_info(MENU_UP,MENU_ICON_XR) },
			{  get_menu_icon_info(MENU_SELECT,MENU_ICON_X),	get_menu_icon_info(MENU_SELECT,MENU_ICON_Y), get_menu_icon_info(MENU_SELECT,MENU_ICON_XL), get_menu_icon_info(MENU_SELECT,MENU_ICON_XR) },
#endif
		};

    		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 total_rows = gr_fb_height() / CHAR_HEIGHT+1;
        		int i = 0;
        		int j = 0;
        		int row = 0;            // current row that we are drawing on
        		if (show_menu) {
				draw_icon_locked(gMenuIcon[MENU_BACK], MENU_ICON[MENU_BACK].x, MENU_ICON[MENU_BACK].y );
				draw_icon_locked(gMenuIcon[MENU_DOWN], MENU_ICON[MENU_DOWN].x, MENU_ICON[MENU_DOWN].y);
				draw_icon_locked(gMenuIcon[MENU_UP], MENU_ICON[MENU_UP].x, MENU_ICON[MENU_UP].y );
				draw_icon_locked(gMenuIcon[MENU_SELECT], MENU_ICON[MENU_SELECT].x, MENU_ICON[MENU_SELECT].y ); 
				            // Setup our text colors
            			    gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255);
				gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255);

            		gr_fill(0, (menu_top + menu_sel - menu_show_start) * CHAR_HEIGHT,
#ifdef BUILD_IN_LANDSCAPE
					gr_fb_width()-menu_max_height*2, (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1);
#else
					gr_fb_width(), (menu_top + menu_sel - menu_show_start + 1)*CHAR_HEIGHT+1);
#endif


            			gr_color(HEADER_TEXT_COLOR);
            			for (i = 0; i < menu_top; ++i) {
					draw_text_line(i, menu[i], LEFT_ALIGN);
                			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(UICOLOR0, UICOLOR1, UICOLOR2, 255);
            			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], LEFT_ALIGN);
                    				gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255);
                		} else {
                    			gr_color(UICOLOR0, UICOLOR1, UICOLOR2, 255);
                    			draw_text_line(i - menu_show_start, menu[i], LEFT_ALIGN);
                		}
                		row++;
                		if (row >= max_menu_rows)
		                    break;
            		}
            		gr_fill(0, row*CHAR_HEIGHT+CHAR_HEIGHT/2-1,
#ifdef BUILD_IN_LANDSCAPE
				gr_fb_width()-menu_max_height*2, row*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
#else
				gr_fb_width(), row*CHAR_HEIGHT+CHAR_HEIGHT/2+1);
#endif
        	}

        	gr_color(NORMAL_TEXT_COLOR);
        	for (; row < text_rows; ++row) {
        		draw_text_line(row + 1, text[(row+text_top) % text_rows], LEFT_ALIGN);
        	}
    	}
}