void Window_Base::DrawGauge(Game_Battler* actor, int cx, int cy) { FileRequestAsync* request = AsyncHandler::RequestFile("System2", Data::system.system2_name); if (!request->IsReady()) { // Gauge refreshed each frame, so we can wait via polling request->Start(); return; } BitmapRef system2 = Cache::System2(Data::system.system2_name); bool full = actor->IsGaugeFull(); int gauge_w = actor->GetGauge() / 4; // Which gauge (0 - 2) int gauge_y = 32 + 2 * 16; // Three components of the gauge Rect gauge_left(0, gauge_y, 16, 16); Rect gauge_center(16, gauge_y, 16, 16); Rect gauge_right(32, gauge_y, 16, 16); // Full or not full bar Rect gauge_bar(full ? 64 : 48, gauge_y, 16, 16); Rect dst_rect(cx + 16, cy, 25, 16); Rect bar_rect(cx + 16, cy, gauge_w, 16); contents->Blit(cx + 0, cy, *system2, gauge_left, 255); contents->Blit(cx + 16 + 25, cy, *system2, gauge_right, 255); contents->StretchBlit(dst_rect, *system2, gauge_center, 255); contents->StretchBlit(bar_rect, *system2, gauge_bar, 255); }
void axScrollBar::OnPaint() { axGC* gc = GetGC(); axRect rect0(axPoint(0, 0), GetRect().size); // gc->SetColor(axColor(1.0, 0.0, 0.0), 1.0); gc->DrawRectangle(rect0); gc->DrawRectangleColorFade(rect0, axColor(0.6, 0.6, 0.6), axColor(0.4, 0.4, 0.4)); // // // gc->DrawImageResize(_bgImg, rect0.position, rect0.size); // // gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0); // gc->DrawRectangleContour(axRect(axPoint(1, 1), rect0.size - axSize(1, 1) )); // gc->SetColor(*_currentScrollBarColor); axRect bar_rect(0, _sliderPos, GetRect().size.x, _sliderHeight); gc->DrawRectangle(bar_rect); gc->SetColor(_info.contour); gc->DrawRectangleContour(bar_rect); // // gc->SetColor(axColor(0.3, 0.3, 0.3), 1.0); // gc->DrawRectangleContour(bar_rect); // gc->SetColor(_info.contour); gc->DrawRectangleContour(rect0); }
void FreeSpaceBar::DrawBar(QPainter* p, const QRect& r) { p->setRenderHint(QPainter::Antialiasing, true); p->setRenderHint(QPainter::HighQualityAntialiasing, true); QRect bar_rect(r); bar_rect.setWidth(float(bar_rect.width()) * (float(total_ - free_) / total_)); QLinearGradient background_gradient(r.topLeft(), r.bottomLeft()); background_gradient.setColorAt(0, kColorBg1); background_gradient.setColorAt(1, kColorBg2); QLinearGradient bar_gradient(bar_rect.topLeft(), bar_rect.bottomLeft()); bar_gradient.setColorAt(0, kColorBar1); bar_gradient.setColorAt(1, kColorBar2); // Draw the background p->setPen(Qt::NoPen); p->setBrush(background_gradient); p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius); // Create a path to use for clipping the bars QPainterPath clip_path; clip_path.addRoundedRect(r, kBarBorderRadius, kBarBorderRadius); p->setClipPath(clip_path); // Draw any additional space if (additional_) { QRect additional_rect(bar_rect); additional_rect.setLeft(bar_rect.right()); additional_rect.setWidth( float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1); QLinearGradient additional_gradient(additional_rect.topLeft(), additional_rect.bottomLeft()); additional_gradient.setColorAt(0, kColorAdd1); additional_gradient.setColorAt(1, kColorAdd2); p->fillRect(additional_rect, additional_gradient); } // Draw the bar foreground p->fillRect(bar_rect, bar_gradient); // Draw a border p->setClipping(false); p->setPen(kColorBorder); p->setBrush(Qt::NoBrush); p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius); // Draw marker lines over the top every few pixels p->setOpacity(0.35); p->setRenderHint(QPainter::Antialiasing, false); p->setPen(QPen(palette().color(QPalette::Light), 1.0)); for (int x = r.left() + kMarkerSpacing; x < r.right(); x += kMarkerSpacing) { p->drawLine(x, r.top() + 2, x, r.bottom() - 2); } p->setOpacity(1.0); }
void FreeSpaceBar::paintEvent(QPaintEvent*) { // Geometry QRect bar_rect(rect()); bar_rect.setHeight(kBarHeight); QRect reflection_rect(bar_rect); reflection_rect.moveTop(reflection_rect.bottom()); QRect labels_rect(rect()); labels_rect.setTop(labels_rect.top() + kBarHeight + kLabelBoxPadding); // Draw the reflection // Create the reflected pixmap QImage reflection(reflection_rect.size(), QImage::Format_ARGB32_Premultiplied); reflection.fill(palette().color(QPalette::Background).rgba()); QPainter p(&reflection); // Set up the transformation QTransform transform; transform.scale(1.0, -1.0); transform.translate(0.0, -reflection.height()); p.setTransform(transform); // Draw the bar DrawBar(&p, QRect(QPoint(0, 0), reflection.size())); // Make it fade out towards the bottom QLinearGradient fade_gradient(reflection.rect().topLeft(), reflection.rect().bottomLeft()); fade_gradient.setColorAt(0.0, QColor(0, 0, 0, 0)); fade_gradient.setColorAt(1.0, QColor(0, 0, 0, 128)); p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(reflection.rect(), fade_gradient); p.end(); // Draw on the widget p.begin(this); DrawBar(&p, bar_rect); p.drawImage(reflection_rect, reflection); DrawText(&p, labels_rect); }
void Window_BattleStatus::DrawGauge(Game_Actor* /* actor */, int index, int cx, int cy) { BitmapRef system2 = Cache::System2(Data::system.system2_name); Battle::Ally& ally = Game_Battle::GetAlly(index); bool full = ally.IsReady(); int gauge_w = ally.gauge * 25 / Game_Battle::gauge_full; int speed = 2; // FIXME: how to determine? int gauge_y = 32 + speed * 16; Rect gauge_left(0, gauge_y, 16, 16); Rect gauge_center(16, gauge_y, 16, 16); Rect gauge_right(32, gauge_y, 16, 16); Rect gauge_bar(full ? 64 : 48, gauge_y, 16, 16); Rect dst_rect(cx+16, cy, 25, 16); Rect bar_rect(cx+16, cy, gauge_w, 16); contents->Blit(cx+0, cy, *system2, gauge_left, 255); contents->StretchBlit(dst_rect, *system2, gauge_center, 255); contents->Blit(cx+16+25, cy, *system2, gauge_right, 255); contents->StretchBlit(bar_rect, *system2, gauge_bar, 255); }