Exemple #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);
    }
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;
}
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;
}
Exemple #4
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;
        }
    }
}
void ScreenRecoveryUI::draw_dialog()
{
    int x, y, w, h;

   if (dialog_icon == HEADLESS) {
       return;
    }
    draw_header_icon();

    int iconHeight = gr_get_height(backgroundIcon[dialog_icon]);

    x = (gr_fb_width()/2 - (char_width*strlen(dialog_text))/2);
    if (dialog_show_log) {
        y = gr_get_height(headerIcon) + char_height;
    }
    else {
        y = (gr_fb_height()/2 + iconHeight/2);
    }

    SetColor(ERROR_TEXT);
    gr_text(x, y, dialog_text, 0);
    y += char_height+2;

    if (dialog_show_log) {
        int cx, cy;
        gr_set_font("log");
        gr_font_size(&cx, &cy);

        int row;
        for (row = 0; row < log_text_rows; ++row) {
            gr_text(4, y, text[row], 0);
            y += cy+2;
        }
        gr_set_font("menu");
    }

    if (dialog_icon == ERROR) {
        /*
         * This could be improved...
         *
         * Draw rect around text "Okay".
         * Text is centered horizontally.
         * Bottom of text is 4 lines from bottom of screen.
         * Rect width 4px
         * Rect padding 8px
         */
        w = char_width*4;
        h = char_height;
        x = gr_fb_width()/2 - w/2;
        y = gr_fb_height() - h - 4*char_height;
        SetColor(HEADER);
        gr_fill(x-(4+8), y-(4+8), x+w+(4+8), y+h+(4+8));
        SetColor(MENU_SEL_BG);
        gr_fill(x-8, y-8, x+w+8, y+h+8);
        SetColor(MENU_SEL_FG);
        gr_text(x, y, "Okay", 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) {
        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]);
        }
    }
}
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;
}
Exemple #8
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;
}
Exemple #9
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]);
        }
    }
}
Exemple #10
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]);
        }
    }
}
Exemple #11
0
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;
    }
}
Exemple #12
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++]);
    }
}
Exemple #13
0
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;
}
// 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);
    }
}
Exemple #15
0
// 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;
            }
        }
    }
}
Exemple #16
0
void Fill() {
	/*
	  Gpx.Fill(): 指定領域の塗りつぶし
	  
	   ds: 塗りつぶし surface 番号
	   dx: 領域 x 座標
	   dy: 領域 y 座標
	   dw: 領域 幅
	   dh: 領域 高さ
	   r : 塗りつぶし色 赤
	   g : 塗りつぶし色 緑
	   b : 塗りつぶし色 青
	*/
	int ds = getCaliValue();
	int dx = getCaliValue();
	int dy = getCaliValue();
	int dw = getCaliValue();
	int dh = getCaliValue();
	int r  = getCaliValue();
	int g  = getCaliValue();
	int b  = getCaliValue();
	surface_t *dst;
	
	DEBUG_COMMAND("Gpx.Fill %d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, dw, dh, r, g, b);
	
	ags_sync();
	dst = sf_get(ds);
	gr_fill(dst, dx, dy, dw, dh, r, g, b);
}
Exemple #17
0
// 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;
    }
}
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;
}
Exemple #19
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;
}
void ScreenRecoveryUI::draw_menu_item(int textrow, const char *text, int selected)
{
    if (selected) {
        SetColor(MENU_SEL_BG);
        gr_fill(0, (textrow)*char_height,
                gr_fb_width(), (textrow+3)*char_height-1);
        SetColor(MENU_SEL_FG);
        gr_text(20, (textrow+1)*char_height-1, text, 0);
        SetColor(MENU);
    }
    else {
        SetColor(MENU);
        gr_text(20, (textrow+1)*char_height-1, text, 0);
    }
    gr_color(SEPARATOR_COLOR);
    gr_fill(0, (textrow+3)*char_height-1, gr_fb_width(), (textrow+3)*char_height+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();
    } 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;
        }
    }
}
Exemple #22
0
// Exercises many of the gr_*() functions; useful for testing.
static void gr_test() {
    GRSurface** images;
    int frames;
    int result = res_create_multi_surface("icon_installing", &frames, &images);
    if (result < 0) {
        printf("create surface %d\n", result);
        gr_exit();
        return;
    }

    time_t start = time(NULL);
    int x;
    for (x = 0; x <= 1200; ++x) {
        if (x < 400) {
            gr_color(0, 0, 0, 255);
        } else {
            gr_color(0, (x-400)%128, 0, 255);
        }
        gr_clear();

        gr_color(255, 0, 0, 255);
        gr_surface frame = images[x%frames];
        gr_blit(frame, 0, 0, frame->width, frame->height, x, 0);

        gr_color(255, 0, 0, 128);
        gr_fill(400, 150, 600, 350);

        gr_color(255, 255, 255, 255);
        gr_text(500, 225, "hello, world!", 0);
        gr_color(255, 255, 0, 128);
        gr_text(300+x, 275, "pack my box with five dozen liquor jugs", 1);

        gr_color(0, 0, 255, 128);
        gr_fill(gr_draw->width - 200 - x, 300, gr_draw->width - x, 500);

        gr_draw = gr_backend->flip(gr_backend);
    }
    printf("getting end time\n");
    time_t end = time(NULL);
    printf("got end time\n");
    printf("start %ld end %ld\n", (long)start, (long)end);
    if (end > start) {
        printf("%.2f fps\n", ((double)x) / (end-start));
    }
}
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;
}
Exemple #24
0
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);
}
Exemple #25
0
int main(void)
{
    int i,j;
    
    gr_clearkey();
    printf("Press any key to start...");
    while(gr_khit()==0);

    gr_setmode(MODE_LORES_TEXT_PAGE_1);
    gr_fill(PAGE_1, BLACK);

    while(gr_khit()==0);
    
    my_test();
    j=0;
    for(i=0;i<48;i++) {
        gr_hlin(39,0,i,j,PAGE_1);
        j++;
        if (j==16) j=0;
    }

    j=0;
    for(i=0;i<40;i++) {
        gr_vlin(47,0,i,j,PAGE_1);
        j++;
        if (j==16) j=0;
    }
    gr_clearkey();
    while(gr_khit()==0);

    for (i=33;i>0;i--) {
        gr_sprite(i, 10, 6, 6, PAGE_1, sprite);
    }
    
    gr_clearkey();
    while(gr_khit()==0);
    for (i=0;i<16;i++) {
        gr_fill(0, i);
    }
    
    return 0;
}
// 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]);
        }
    }
}
Exemple #27
0
// Clear the screen and draw the currently selected background icon (if any).
// Should only be called with gUpdateMutex locked.
static void draw_background_locked(gr_surface icon)
{
    gr_color(0, 0, 0, 255);
    gr_fill(0, 0, gr_fb_width(), gr_fb_height());

    if (icon) {
        int iconWidth = gr_get_width(icon);
        int iconHeight = gr_get_height(icon);
        int iconX = (gr_fb_width() - iconWidth) / 2;
        int iconY = (gr_fb_height() - iconHeight) / 2;
        gr_blit(icon, 0, 0, iconWidth, iconHeight, iconX, iconY);
    }
}
Exemple #28
0
int GUIConsole::RenderConsole(void)
{
	AddLines();
	GUIScrollList::Render();

	// if last line is fully visible, keep tracking the last line when new lines are added
	int bottom_offset = GetDisplayRemainder() - actualItemHeight;
	bool isAtBottom = firstDisplayedItem == GetItemCount() - GetDisplayItemCount() - (bottom_offset != 0) && y_offset == bottom_offset;
	if (isAtBottom)
		scrollToEnd = true;
#if 0
	// debug - show if we are tracking the last line
	if (scrollToEnd) {
		gr_color(0,255,0,255);
		gr_fill(mRenderX+mRenderW-5, mRenderY+mRenderH-5, 5, 5);
	} else {
		gr_color(255,0,0,255);
		gr_fill(mRenderX+mRenderW-5, mRenderY+mRenderH-5, 5, 5);
	}
#endif
	return (mSlideout ? RenderSlideout() : 0);
}
Exemple #29
0
// 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) {
        gr_surface icon = installation[installingFrame];
        gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY);
    }

    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);
                }
            }
        }
    }
}
// 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]);
        }
    }
}