void Button::Draw(UIContext &dc) { Style style = dc.theme->buttonStyle; if (HasFocus()) style = dc.theme->buttonFocusedStyle; if (down_) style = dc.theme->buttonDownStyle; if (!IsEnabled()) style = dc.theme->buttonDisabledStyle; // dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor); dc.FillRect(style.background, bounds_); float tw, th; dc.MeasureText(dc.theme->uiFont, text_.c_str(), &tw, &th); if (tw > bounds_.w || imageID_ != -1) { dc.PushScissor(bounds_); } dc.SetFontStyle(dc.theme->uiFont); if (imageID_ != -1 && text_.empty()) { dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER); } else if (!text_.empty()) { dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), style.fgColor, ALIGN_CENTER); if (imageID_ != -1) { const AtlasImage &img = dc.Draw()->GetAtlas()->images[imageID_]; dc.Draw()->DrawImage(imageID_, bounds_.centerX() - tw / 2 - 5 - img.w/2, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER); } } if (tw > bounds_.w || imageID_ != -1) { dc.PopScissor(); } }
void OnScreenMessagesView::Draw(UIContext &dc) { // First, clean out old messages. osm.Lock(); osm.Clean(); // Get height float w, h; dc.Draw()->MeasureText(UBUNTU24, "Wg", &w, &h); float y = 10.0f; // Then draw them all. const std::list<OnScreenMessages::Message> &messages = osm.Messages(); for (auto iter = messages.begin(); iter != messages.end(); ++iter) { float alpha = (iter->endTime - time_now_d()) * 4.0f; if (alpha > 1.0) alpha = 1.0f; if (alpha < 0.0) alpha = 0.0f; // Messages that are wider than the screen are left-aligned instead of centered. float tw, th; dc.Draw()->MeasureText(UBUNTU24, iter->text.c_str(), &tw, &th); float x = bounds_.centerX(); int align = ALIGN_TOP | ALIGN_HCENTER; if (tw > bounds_.w) { align = ALIGN_TOP | ALIGN_LEFT; x = 2; } dc.Draw()->DrawTextShadow(UBUNTU24, iter->text.c_str(), x, y, colorAlpha(iter->color, alpha), align); y += h; } osm.Unlock(); }
void InfoItem::Draw(UIContext &dc) { Item::Draw(dc); int paddingX = 8; dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER); dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_RIGHT); // dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y + 2, dc.theme->itemDownStyle.bgColor); }
void Choice::Draw(UIContext &dc) { if (!IsSticky()) { ClickableItem::Draw(dc); } else { Style style = dc.theme->itemStyle; if (down_) { style = dc.theme->itemDownStyle; } if (HasFocus()) { style = dc.theme->itemFocusedStyle; } dc.FillRect(style.background, bounds_); } Style style = dc.theme->itemStyle; if (!IsEnabled()) style = dc.theme->itemDisabledStyle; if (atlasImage_ != -1) { dc.Draw()->DrawImage(atlasImage_, bounds_.centerX(), bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); } else { int paddingX = 12; dc.SetFontStyle(dc.theme->uiFont); dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); } if (selected_) { dc.Draw()->DrawImage(dc.theme->checkOn, bounds_.x2() - 40, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); } }
void CheckBox::Draw(UIContext &dc) { ClickableItem::Draw(dc); int paddingX = 8; int paddingY = 8; int image = *toggle_ ? dc.theme->checkOn : dc.theme->checkOff; dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER); dc.Draw()->DrawImage(image, bounds_.x2() - 4, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER); }
void Choice::Draw(UIContext &dc) { ClickableItem::Draw(dc); int paddingX = 8; dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER); if (selected_) { dc.Draw()->DrawImage(dc.theme->checkOn, bounds_.x2() - 40, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER); } // dc.draw->DrawText(dc.theme->uiFontSmaller, text_.c_str(), paddingX, paddingY, 0xFFFFFFFF, ALIGN_TOPLEFT); }
void MultiTouchButton::Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; float scale = scale_; if (IsDown()) { scale *= 2.0f; opacity *= 1.15f; } uint32_t colorBg = colorAlpha(0xc0b080, opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); dc.Draw()->DrawImageRotated(bgImg_, bounds_.centerX(), bounds_.centerY(), scale, angle_ * (M_PI * 2 / 360.0f), colorBg, flipImageH_); dc.Draw()->DrawImageRotated(img_, bounds_.centerX(), bounds_.centerY(), scale, angle_ * (M_PI * 2 / 360.0f), color); }
void Choice::Draw(UIContext &dc) { if (!IsSticky()) { ClickableItem::Draw(dc); } else { Style style = dc.theme->itemStyle; if (highlighted_) { style = dc.theme->itemHighlightedStyle; } if (down_) { style = dc.theme->itemDownStyle; } if (HasFocus()) { style = dc.theme->itemFocusedStyle; } dc.FillRect(style.background, bounds_); } Style style = dc.theme->itemStyle; if (!IsEnabled()) { style = dc.theme->itemDisabledStyle; } if (atlasImage_ != -1) { dc.Draw()->DrawImage(atlasImage_, bounds_.centerX(), bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); } else { dc.SetFontStyle(dc.theme->uiFont); const int paddingX = 12; const float availWidth = bounds_.w - paddingX * 2 - textPadding_.horiz(); float scale = CalculateTextScale(dc, availWidth); dc.SetFontScale(scale, scale); if (centered_) { dc.DrawTextRect(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT); } else { if (iconImage_ != -1) { dc.Draw()->DrawImage(iconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), 0.5f, style.fgColor, ALIGN_CENTER); } Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h); dc.DrawTextRect(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT); } dc.SetFontScale(1.0f, 1.0f); } if (selected_) { dc.Draw()->DrawImage(dc.theme->checkOn, bounds_.x2() - 40, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_CENTER); } }
void PSPStick::Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(0xc0b080, opacity); uint32_t color = colorAlpha(0x808080, opacity); float stickX = bounds_.centerX(); float stickY = bounds_.centerY(); float dx, dy; __CtrlPeekAnalog(stick_, &dx, &dy); dc.Draw()->DrawImage(bgImg_, stickX, stickY, 1.0f * scale_, colorBg, ALIGN_CENTER); dc.Draw()->DrawImage(stickImageIndex_, stickX + dx * stick_size_ * scale_, stickY - dy * stick_size_ * scale_, 1.0f * scale_, colorBg, ALIGN_CENTER); }
void DrawGameBackground(UIContext &dc, const std::string &gamePath) { std::shared_ptr<GameInfo> ginfo; if (gamePath.size()) ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath, GAMEINFO_WANTBG); dc.Flush(); bool hasPic = false; double loadTime; if (ginfo && ginfo->pic1.texture) { dc.GetDrawContext()->BindTexture(0, ginfo->pic1.texture->GetTexture()); loadTime = ginfo->pic1.timeLoaded; hasPic = true; } else if (ginfo && ginfo->pic0.texture) { dc.GetDrawContext()->BindTexture(0, ginfo->pic0.texture->GetTexture()); loadTime = ginfo->pic0.timeLoaded; hasPic = true; } if (hasPic) { uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3)) & 0xFFc0c0c0; dc.Draw()->DrawTexRect(dc.GetBounds(), 0,0,1,1, color); dc.Flush(); dc.RebindTexture(); } else { ::DrawBackground(dc, 1.0f); dc.RebindTexture(); dc.Flush(); } }
void AsyncImageFileView::Draw(UIContext &dc) { if (!texture_ && !textureFailed_ && !filename_.empty()) { texture_ = dc.GetThin3DContext()->CreateTextureFromFile(filename_.c_str(), DETECT); if (!texture_) textureFailed_ = true; } if (HasFocus()) { dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3)); } // TODO: involve sizemode if (texture_) { dc.Flush(); dc.GetThin3DContext()->SetTexture(0, texture_); dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); dc.Flush(); dc.RebindTexture(); if (!text_.empty()) { dc.DrawText(text_.c_str(), bounds_.centerX()+1, bounds_.centerY()+1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); } } else { if (!filename_.empty()) { // draw a black rectangle to represent the missing screenshot. dc.FillRect(UI::Drawable(0xFF000000), GetBounds()); } else { // draw a dark gray rectangle to represent no save state. dc.FillRect(UI::Drawable(0x50202020), GetBounds()); } if (!text_.empty()) { dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII); } } }
void PopupHeader::Draw(UIContext &dc) { const float paddingHorizontal = 12; const float availableWidth = bounds_.w - paddingHorizontal * 2; float tw, th; dc.SetFontStyle(dc.theme->uiFont); dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text_.c_str(), &tw, &th, 0); float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f; float tx = paddingHorizontal; if (availableWidth < tw) { float overageRatio = 1.5f * availableWidth * 1.0f / tw; tx -= (1.0f + sin(time_now_d() * overageRatio)) * sineWidth; Bounds tb = bounds_; tb.x = bounds_.x + paddingHorizontal; tb.w = bounds_.w - paddingHorizontal * 2; dc.PushScissor(tb); } dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->popupTitle.fgColor, ALIGN_LEFT | ALIGN_VCENTER); dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitle.fgColor); if (availableWidth < tw) { dc.PopScissor(); } }
void DrawGameBackground(UIContext &dc, const std::string &gamePath) { GameInfo *ginfo = g_gameInfoCache->GetInfo(dc.GetThin3DContext(), gamePath, GAMEINFO_WANTBG); dc.Flush(); if (ginfo) { bool hasPic = false; double loadTime; if (ginfo->pic1Texture) { dc.GetThin3DContext()->SetTexture(0, ginfo->pic1Texture); loadTime = ginfo->timePic1WasLoaded; hasPic = true; } else if (ginfo->pic0Texture) { dc.GetThin3DContext()->SetTexture(0, ginfo->pic0Texture); loadTime = ginfo->timePic0WasLoaded; hasPic = true; } if (hasPic) { uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3)) & 0xFFc0c0c0; dc.Draw()->DrawTexRect(dc.GetBounds(), 0,0,1,1, color); dc.Flush(); dc.RebindTexture(); } else { ::DrawBackground(dc, 1.0f); dc.RebindTexture(); dc.Flush(); } } }
void GameSettingsScreen::DrawBackground(UIContext &dc) { GameInfo *ginfo = g_gameInfoCache.GetInfo(gamePath_, true); dc.Flush(); dc.RebindTexture(); ::DrawBackground(1.0f); dc.Flush(); if (ginfo && ginfo->pic1Texture) { ginfo->pic1Texture->Bind(0); uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 3)) & 0xFFc0c0c0; dc.Draw()->DrawTexRect(0,0,dp_xres, dp_yres, 0,0,1,1,color); dc.Flush(); dc.RebindTexture(); } /* if (ginfo && ginfo->pic0Texture) { ginfo->pic0Texture->Bind(0); // Pic0 is drawn in the bottom right corner, overlaying pic1. float sizeX = dp_xres / 480 * ginfo->pic0Texture->Width(); float sizeY = dp_yres / 272 * ginfo->pic0Texture->Height(); uint32_t color = whiteAlpha(ease((time_now_d() - ginfo->timePic1WasLoaded) * 2)) & 0xFFc0c0c0; ui_draw2d.DrawTexRect(dp_xres - sizeX, dp_yres - sizeY, dp_xres, dp_yres, 0,0,1,1,color); ui_draw2d.Flush(); dc.RebindTexture(); }*/ }
void ProgressBar::Draw(UIContext &dc) { char temp[32]; sprintf(temp, "%i%%", (int)(progress_ * 100.0f)); dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x + bounds_.w * progress_, bounds_.y2(), 0xc0c0c0c0); dc.SetFontStyle(dc.theme->uiFont); dc.DrawTextRect(temp, bounds_, 0xFFFFFFFF, ALIGN_CENTER); }
void HttpImageFileView::Draw(UIContext &dc) { using namespace Draw; if (!texture_ && !textureFailed_ && !path_.empty() && !download_) { download_ = downloader_->StartDownloadWithCallback(path_, "", std::bind(&HttpImageFileView::DownloadCompletedCallback, this, std::placeholders::_1)); download_->SetHidden(true); } if (!textureData_.empty()) { texture_ = CreateTextureFromFileData(dc.GetDrawContext(), (const uint8_t *)(textureData_.data()), (int)textureData_.size(), DETECT); if (!texture_) textureFailed_ = true; textureData_.clear(); download_.reset(); } if (HasFocus()) { dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3)); } // TODO: involve sizemode if (texture_) { dc.Flush(); dc.GetDrawContext()->BindTexture(0, texture_->GetTexture()); dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); dc.Flush(); dc.RebindTexture(); } else { // draw a black rectangle to represent the missing image. dc.FillRect(UI::Drawable(0xFF000000), GetBounds()); } }
void GetContentDimensions(const UIContext &dc, float &w, float &h) const{ const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_DIR]; w = 2 * DpadRadius_ + image.w * scale_; h = 2 * DpadRadius_ + image.h * scale_; //w += 2 * DpadRadius_; //h += 2 * DpadRadius_; };
void GetContentDimensions(const UIContext &dc, float &w, float &h) const{ const AtlasImage &image = dc.Draw()->GetAtlas()->images[roundId_]; w = 2 * actionButtonSpacing_ + image.w * scale_; h = 2 * actionButtonSpacing_ + image.h * scale_; //w += 2 * actionButtonSpacing_; //h += 2 * actionButtonSpacing_; };
void Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(GetButtonColor(), opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); int centerX = bounds_.centerX(); int centerY = bounds_.centerY(); float spacing = spacing_ * baseActionButtonSpacing; if (circleVisible_) { dc.Draw()->DrawImageRotated(roundId_, centerX + spacing, centerY, scale_, 0, colorBg, false); dc.Draw()->DrawImageRotated(circleId_, centerX + spacing, centerY, scale_, 0, color, false); } if (crossVisible_) { dc.Draw()->DrawImageRotated(roundId_, centerX, centerY + spacing, scale_, 0, colorBg, false); dc.Draw()->DrawImageRotated(crossId_, centerX, centerY + spacing, scale_, 0, color, false); } if (triangleVisible_) { dc.Draw()->DrawImageRotated(roundId_, centerX, centerY - spacing, scale_, 0, colorBg, false); dc.Draw()->DrawImageRotated(triangleId_, centerX, centerY - spacing, scale_, 0, color, false); } if (squareVisible_) { dc.Draw()->DrawImageRotated(roundId_, centerX - spacing, centerY, scale_, 0, colorBg, false); dc.Draw()->DrawImageRotated(squareId_, centerX - spacing, centerY, scale_, 0, color, false); } };
void Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(0xc0b080, opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); static const float xoff[4] = {1, 0, -1, 0}; static const float yoff[4] = {0, 1, 0, -1}; for (int i = 0; i < 4; i++) { float x = bounds_.centerX() + xoff[i] * D_pad_Radius * spacing_; float y = bounds_.centerY() + yoff[i] * D_pad_Radius * spacing_; float angle = i * M_PI / 2; dc.Draw()->DrawImageRotated(I_DIR, x, y, scale_, angle + PI, colorBg, false); dc.Draw()->DrawImageRotated(I_ARROW, x, y, scale_, angle + PI, color); } }
void ImageFileView::Draw(UIContext &dc) { // TODO: involve sizemode if (texture_) { dc.Flush(); texture_->Bind(0); dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); dc.Flush(); dc.RebindTexture(); } }
void Button::Draw(UIContext &dc) { Style style = dc.theme->buttonStyle; if (HasFocus()) style = dc.theme->buttonFocusedStyle; if (down_) style = dc.theme->buttonDownStyle; if (!enabled_) style = dc.theme->buttonDisabledStyle; // dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor); dc.FillRect(style.background, bounds_); dc.Draw()->DrawText(dc.theme->uiFont, text_.c_str(), bounds_.centerX(), bounds_.centerY(), style.fgColor, ALIGN_CENTER); }
void Thin3DTextureView::Draw(UIContext &dc) { // TODO: involve sizemode if (texture_) { dc.Flush(); dc.GetThin3DContext()->SetTexture(0, texture_); dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_); dc.Flush(); dc.RebindTexture(); } }
void SliderFloat::Draw(UIContext &dc) { bool focus = HasFocus(); float knobX = (*value_ - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_); dc.FillRect(Drawable(focus ? dc.theme->popupTitle.fgColor : 0xFFFFFFFF), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); dc.FillRect(Drawable(0xFF808080), Bounds(knobX, bounds_.centerY() - 2, (bounds_.x + bounds_.w - paddingRight_ - knobX), 4)); dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, 0xFFFFFFFF, ALIGN_CENTER); char temp[64]; sprintf(temp, "%0.2f", *value_); dc.SetFontStyle(dc.theme->uiFont); dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER); }
void PSPCross::Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(0xc0b080, opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); static const float xoff[4] = {1, 0, -1, 0}; static const float yoff[4] = {0, 1, 0, -1}; static const int dir[4] = {CTRL_RIGHT, CTRL_DOWN, CTRL_LEFT, CTRL_UP}; int buttons = __CtrlPeekButtons(); for (int i = 0; i < 4; i++) { float x = bounds_.centerX() + xoff[i] * radius_; float y = bounds_.centerY() + yoff[i] * radius_; float angle = i * M_PI / 2; float imgScale = (buttons & dir[i]) ? scale_ * 2 : scale_; dc.Draw()->DrawImageRotated(arrowIndex_, x, y, imgScale, angle + PI, colorBg, false); if (overlayIndex_ != -1) dc.Draw()->DrawImageRotated(overlayIndex_, x, y, imgScale, angle + PI, color); } }
void Choice::GetContentDimensions(const UIContext &dc, float &w, float &h) const { if (atlasImage_ != -1) { const AtlasImage &img = dc.Draw()->GetAtlas()->images[atlasImage_]; w = img.w; h = img.h; } else { dc.MeasureText(dc.theme->uiFont, text_.c_str(), &w, &h); } w += 24; h += 16; }
void MultiTouchButton::Draw(UIContext &dc) { float opacity = g_Config.iTouchButtonOpacity / 100.0f; float scale = scale_; if (IsDown()) { scale *= 2.0f; opacity *= 1.15f; } uint32_t colorBg = colorAlpha(GetButtonColor(), opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); dc.Draw()->DrawImageRotated(bgImg_, bounds_.centerX(), bounds_.centerY(), scale, angle_ * (M_PI * 2 / 360.0f), colorBg, flipImageH_); int y = bounds_.centerY(); // Hack round the fact that the center of the rectangular picture the triangle is contained in // is not at the "weight center" of the triangle. if (img_ == I_TRIANGLE) y -= 2.8f * scale; dc.Draw()->DrawImageRotated(img_, bounds_.centerX(), y, scale, angle_ * (M_PI * 2 / 360.0f), color); }
void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const { if (imageID_ != -1) { const AtlasImage *img = &dc.Draw()->GetAtlas()->images[imageID_]; w = img->w; h = img->h; } else { dc.MeasureText(dc.theme->uiFont, text_.c_str(), &w, &h); } // Add some internal padding to not look totally ugly w += 16; h += 8; }
void CheckBox::Draw(UIContext &dc) { ClickableItem::Draw(dc); int paddingX = 12; int image = *toggle_ ? dc.theme->checkOn : dc.theme->checkOff; Style style = dc.theme->itemStyle; if (!IsEnabled()) style = dc.theme->itemDisabledStyle; dc.SetFontStyle(dc.theme->uiFont); dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); dc.Draw()->DrawImage(image, bounds_.x2() - paddingX, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER); }
void Draw(UIContext &dc) override { float opacity = g_Config.iTouchButtonOpacity / 100.0f; uint32_t colorBg = colorAlpha(GetButtonColor(), opacity); uint32_t color = colorAlpha(0xFFFFFF, opacity); static const float xoff[4] = {1, 0, -1, 0}; static const float yoff[4] = {0, 1, 0, -1}; int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR; for (int i = 0; i < 4; i++) { float r = D_pad_Radius * spacing_; float x = bounds_.centerX() + xoff[i] * r; float y = bounds_.centerY() + yoff[i] * r; float x2 = bounds_.centerX() + xoff[i] * (r + 10.f * scale_); float y2 = bounds_.centerY() + yoff[i] * (r + 10.f * scale_); float angle = i * M_PI / 2; dc.Draw()->DrawImageRotated(dirImage, x, y, scale_, angle + PI, colorBg, false); dc.Draw()->DrawImageRotated(I_ARROW, x2, y2, scale_, angle + PI, color); } }