Skip to content

Commit

Permalink
Athlete View Open Button rendering
Browse files Browse the repository at this point in the history
.. not sure why, but the border was fugly. Tidied it up.
  • Loading branch information
liversedge committed Aug 22, 2021
1 parent 33018aa commit f4a14b6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Charts/OverviewItems.cpp
Expand Up @@ -5019,19 +5019,26 @@ Button::setGeometry(double x, double y, double width, double height)
void
Button::paint(QPainter*painter, const QStyleOptionGraphicsItem *, QWidget*)
{
static const int gl_border = 2;
static const int gl_radius = 24;

// anti aliasing please- none of that sketchy lines
painter->setRenderHint(QPainter::Antialiasing);

// button background
QColor pc = GCColor::invertColor(GColor(CCARDBACKGROUND));
pc.setAlpha(128);
painter->setPen(QPen(pc));
pc.setAlpha(64);
QPen line(pc,gl_border, Qt::SolidLine);
line.setJoinStyle(Qt::RoundJoin);
painter->setPen(line);
QPointF pos=mapToParent(geom.x(), geom.y());
if (isUnderMouse()) {
QColor hover=GColor(CPLOTMARKER);
if (state==Clicked) hover.setAlpha(200);
else hover.setAlpha(100);
painter->setBrush(QBrush(hover));
} else painter->setBrush(QBrush(GColor(CCARDBACKGROUND)));
painter->drawRoundedRect(pos.x(), pos.y(), geom.width(), geom.height(), 20, 20);
painter->drawRoundedRect(pos.x()+gl_border, pos.y()+gl_border, geom.width()-(gl_border*2), geom.height()-(gl_border*2), gl_radius, gl_radius);

// text using large font clipped
if (isUnderMouse()) {
Expand Down

0 comments on commit f4a14b6

Please sign in to comment.