void gfxRenderer::DrawHSlider( int state, int style, float x, float y, float width, float height, float aspect, const float& value ) { const float margin = 2.0f; float thumbSize = width * aspect; gfxDrawRectangle(x, y, width, height, GFX_STYLE_NONE); gfxDrawRectangle(x+value*width, y+margin, thumbSize, height-margin*2.0f, GFX_STYLE_SLIDER_THUMB); }
void gfxRenderer::DrawVSlider( int state, int style, float x, float y, float width, float height, float aspect, const float& value ) { // draw vertical slider const float margin = 2.0f; float thumbSize = height * aspect; gfxDrawRectangle(x, y, width, height, GFX_STYLE_NONE); gfxDrawRectangle(x+margin, y+value*height, width-margin*2, thumbSize, GFX_STYLE_SLIDER_THUMB); }
void gfxRenderer::DrawButton( int state, int style, float x, float y, float width, float height, const char* title ) { if(state & igItemStates::PRESSED) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_PRESSED); } else if(state & igItemStates::HOVER) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_HOVER); } else { gfxDrawRectangle(x, y, width, height, GFX_STYLE_NONE); } gfxPrint(x+width/2.0f, y+height/2.0f, title, GFX_STYLE_NONE); }
int drawMenuEntry(menuEntry_s* me, gfxScreen_t screen, u16 x, u16 y, bool selected) { if(!me)return 0; int i; //TODO : proper template sort of thing ? //this is all hardcoded and horrible const int totalWidth=selected?ENTRY_WIDTH_SELECTED:ENTRY_WIDTH; const int actualWidth=(selected?ENTRY_FWIDTH_SELECTED:ENTRY_FWIDTH); const int widthOffset=actualWidth-ENTRY_FWIDTH; const int actualHeight=selected?ENTRY_HEIGHT_SELECTED:ENTRY_HEIGHT; if(selected)y-=ENTRY_HEIGHT_SELECTED-ENTRY_HEIGHT; x-=ENTRY_WIDTH+widthOffset; //drop shadow if(selected) { const int sw=4; const int sx=x-sw; for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx+roundLut[i], y+i, sw, 1); gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx, y+9, sw, actualHeight-9*2); for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx+roundLut[i], y+actualHeight-1-i, sw, 1); } //main frame for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset+roundLut[i], y+i, actualWidth-roundLut[i]*2, 1); gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset, y+9, actualWidth, actualHeight-9*2); for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset+roundLut[i], y+actualHeight-1-i, actualWidth-roundLut[i]*2, 1); //icon frame u8 colorIcon[]={225, 225, 225}; for(i=0; i<5; i++)gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3+roundLut2[i], y+4+i, 56-roundLut2[i]*2, 1); gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3, y+9, 56, 46); for(i=0; i<5; i++)gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3+roundLut2[i], y+4+56-1-i, 56-roundLut2[i]*2, 1); //app specific stuff gfxDrawSprite(screen, GFX_LEFT, me->iconData, ENTRY_ICON_WIDTH, ENTRY_ICON_HEIGHT, x+7, y+8); gfxDrawTextN(screen, GFX_LEFT, &fontTitle, me->name, ENTRY_NAMELENGTH, x+38, y+66); gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description, 56, x+26, y+70); if(strlen(me->description) > 56 * 1) { gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56, 56, x+18, y+70); } else if(strlen(me->description) > 56 * 2) { gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56 * 1, 56, x+18, y+70); gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56 * 2, 56, x+10, y+70); } gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->author, ENTRY_AUTHORLENGTH, x+4, y+ENTRY_HEIGHT-getStringLength(&fontDescription, me->author)-10); return totalWidth; }
void gfxRenderer::DrawMove( int state, int style, float& x, float& y, float prevX, float prevY, float width, float height, const char* title ) { // draw button if(state & igItemStates::PRESSED) { gfxDrawRectangle(prevX, prevY, width, height, GFX_STYLE_ELEM_PRESSED); } else if(state & igItemStates::HOVER) { gfxDrawRectangle(prevX, prevY, width, height, GFX_STYLE_ELEM_HOVER); } else { gfxDrawRectangle(prevX, prevY, width, height, GFX_STYLE_NONE); } gfxPrint(prevX + width/2.0f, prevY + height/2.0f, title, GFX_STYLE_NONE); }
void gfxRenderer::DrawTextBox( int state, int style, float x, float y, float width, float height, const std::string& value, int textCharPos ) { // draw text box if(state & igItemStates::PRESSED) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_PRESSED); } else if(state & igItemStates::HOVER) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_HOVER); } else { gfxDrawRectangle(x, y, width, height, GFX_STYLE_NONE); } gfxPrint(x + width/2.0f, y + height/2.0f, value.c_str(), GFX_STYLE_NONE, state & igItemStates::TEXT_FOCUS ? textCharPos : -1); }
void drawError(gfxScreen_t screen, char* title, char* body, int offset) { int i; int numLines=countLines(body); int width=numLines*8+32; int height=300; int x=240-width-12+offset, y=4; //main frame for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x+roundLutError[i], y+i, width-roundLutError[i]*2, 1); gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x, y+9, width, height-9*2); for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x+roundLutError[i], y+height-1-i, width-roundLutError[i]*2, 1); //content gfxDrawText(screen, GFX_LEFT, &fontTitle, title, x+width-6-16, y+6); gfxDrawText(screen, GFX_LEFT, &fontDescription, body, x+width-5-16-13, y+8); }
void btnDrawSlider(button * slider) { if (!slider->visible) { return; } rgbColour * aRGB = inactiveColour(); drawButtonRectForButton(slider, aRGB->r, aRGB->g, aRGB->b); u8 rgb[3] = {0, 0, 0}; gfxDrawRectangle(slider->screen, slider->side, rgb, slider->x, (slider->y+slider->value)-(sliderIndicatorWidth/2), slider->w, sliderIndicatorWidth); rgb[0] = 255; rgb[1] = 255; rgb[2] = 255; gfxDrawRectangle(slider->screen, slider->side, rgb, slider->x+1, ((slider->y+slider->value)-(sliderIndicatorWidth/2))+1, slider->w-2, sliderIndicatorWidth-2); rgbColour * dark = darkTextColour(); MAFont *font = &MAFontRobotoRegular10; int lineHeight = font->lineHeight; if (strlen(slider->shortText1) > 0) { MADrawTextWrap(slider->screen, slider->side, slider->x + (slider->w/2) - (lineHeight/2), slider->y + 20, slider->shortText1, font, dark->r, dark->g, dark->b, 0, 0); } if (strlen(slider->shortText2) > 0) { int width = MATextWidthInPixels(slider->shortText2, font); MADrawTextWrap(slider->screen, slider->side, slider->x + (slider->w/2) - (lineHeight/2), (slider->y + slider->h) - width - 20, slider->shortText2, font, dark->r, dark->g, dark->b, 0, 0); } drawButtonRect(slider->screen, slider->side, sliderButtonX, sliderMinusButtonY, sliderButtonWidth, sliderButtonHeight, dark->r, dark->g, dark->b); drawButtonRect(slider->screen, slider->side, sliderButtonX, sliderPlusButtonY, sliderButtonWidth, sliderButtonHeight, dark->r, dark->g, dark->b); rgbColour *light = lightTextColour(); MADrawText(slider->screen, slider->side, sliderButtonX-2, sliderMinusButtonY+10, "-", &MAFontRobotoRegular16, light->r, light->g, light->b); MADrawText(slider->screen, slider->side, sliderButtonX-2, sliderPlusButtonY+10, "+", &MAFontRobotoRegular16, light->r, light->g, light->b); }
void gfxRenderer::DrawCheckbox( int state, int style, float x, float y, float width, float height, bool value ) { const float margin = 2.0f; if(state & igItemStates::PRESSED) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_PRESSED); } else if(state & igItemStates::HOVER) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_HOVER); } else { gfxDrawRectangle(x, y, width, height, GFX_STYLE_NONE); } if(value) { gfxDrawRectangle(x+margin, y+margin, width-margin*2, height-margin*2, GFX_STYLE_CHECKBOX); } }
void drawButtonRect(gfxScreen_t screen, gfx3dSide_t side, int x, int y, int w, int h, int r, int g, int b) { u8 corner[9*9*4]; MAGFXImageWithRGBAndAlphaMask(r, g, b, (u8*)buttoncornertopleft_bin, corner, 9, 9); gfxDrawSpriteAlphaBlend(screen, side, corner, 9, 9, x+(w-9), y); MAGFXImageWithRGBAndAlphaMask(r, g, b, (u8*)buttoncornertopright_bin, corner, 9, 9); gfxDrawSpriteAlphaBlend(screen, side, corner, 9, 9, x+(w-9), y+h-9); MAGFXImageWithRGBAndAlphaMask(r, g, b, (u8*)buttoncornerbottomleft_bin, corner, 9, 9); gfxDrawSpriteAlphaBlend(screen, side, corner, 9, 9, x, y); MAGFXImageWithRGBAndAlphaMask(r, g, b, (u8*)buttoncornerbottomright_bin, corner, 9, 9); gfxDrawSpriteAlphaBlend(screen, side, corner, 9, 9, x, y+h-9); u8 rgb[3] = {r, g, b}; gfxDrawRectangle(screen, side, rgb, x, y+9, w, h-18); gfxDrawRectangle(screen, side, rgb, x+9, y, w-18, h); }
void gfxPrint(int x, int y, const char* str, int style, int pipePos, int pipe2Pos, int halign) { const int charSize = 16; const int pipeSize = 12; sf::Text text(str, *gFont, charSize); sf::FloatRect r = text.getLocalBounds(); sf::Vector2f pos = sf::Vector2f(x - (r.left+r.width)/2.0f, y - text.getCharacterSize()/2.0f); pos = sf::Vector2f((int)pos.x, (int)pos.y); text.setPosition(pos - sf::Vector2f(r.width/2.0f*halign,0)); text.setColor(textColor); if(pipePos != -1) { float p1 = text.findCharacterPos(pipePos).x; float p2 = text.findCharacterPos(pipe2Pos).x; gfxDrawRectangle(p1, pos.y-pipeSize/2, p2-p1, pipeSize*2, GFX_STYLE_ELEM_HOVER, false); } sf::Vector2f p = text.getPosition(); text.setPosition((int)p.x, (int)p.y); gWindow->draw(text); if(pipePos >= 0 && pipePos == pipe2Pos) { std::string curr = str; curr = curr.substr(0, pipePos); sf::Text currText(curr+".", *gFont, charSize); sf::Text _Text("|", *gFont, charSize); sf::Text dotText(".", *gFont, charSize); _Text.setColor(sf::Color(0, 0, 255)); float xDiff = currText.getLocalBounds().width - dotText.getLocalBounds().width; _Text.setPosition(sf::Vector2f(pos.x + xDiff, pos.y)); //gWindow->draw(_Text); gfxDrawRectangle(pos.x + xDiff-2, pos.y-pipeSize/2, 2, pipeSize*2, GFX_STYLE_ELEM_PRESSED); } }
void igRenderer::DrawTextBox( int state, int style, float x, float y, float width, float height, const std::string& value, int textCharPos, int textCharPos2) { // draw text box if(state & igItemStates::PRESSED) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_PRESSED); } else if(state & igItemStates::HOVER) { gfxDrawRectangle(x, y, width, height, GFX_STYLE_ELEM_HOVER); } else { gfxDrawRectangle(x, y, width, height, GFX_STYLE_TEXTBOX_BG); } int pipePos = state & igItemStates::TEXT_FOCUS ? textCharPos : -1; int pipe2Pos = state & igItemStates::TEXT_FOCUS ? textCharPos2 : -1; if(time % 500 >= 250 && textCharPos == textCharPos2) pipePos = -1; if(pipePos > pipe2Pos) std::swap(pipePos, pipe2Pos); gfxPrint(x + width/2.0f, y + height/2.0f, value.c_str(), GFX_STYLE_NONE, pipePos, pipe2Pos); }
void drawScrollBar(menu_s* m) { if(!m)return; int scrollBarTotalSize=m->scrollBarSize+3*2; int i; // background scrollbar thing //35,308 - 200,7 u8 colorBg[]={132, 224, 255}; for(i=0; i<3; i++)gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, colorBg, 38-i, 308+roundLut3[i], 1, 7-2*roundLut3[i]); gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, colorBg, 38, 308, 194, 7); for(i=0; i<3; i++)gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, colorBg, 232+i, 308+roundLut3[i], 1, 7-2*roundLut3[i]); // actual scrollbar u8 color[]={255, 255, 255}; for(i=0; i<3; i++)gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, color, 200-scrollBarTotalSize-m->scrollBarPos+38-i, 308+roundLut3[i], 1, 7-2*roundLut3[i]); gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, color, 200-scrollBarTotalSize-m->scrollBarPos+38, 308, m->currentScrollBarSize, 7); for(i=0; i<3; i++)gfxDrawRectangle(GFX_BOTTOM, GFX_LEFT, color, 200-scrollBarTotalSize-m->scrollBarPos+38+m->currentScrollBarSize+i, 308+roundLut3[i], 1, 7-2*roundLut3[i]); }
void igRenderer::DrawSeparator( float x, float y, float width, float height ) { gfxDrawRectangle(x+5, y, width - 10, height, GFX_STYLE_NONE); }
void igRenderer::DrawScrollArea(int style, float x, float y, float width, float height) { gfxDrawRectangle(x, y, width, height, style, false); }