Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSelectionActionsPanelButton Class Reference

Custom widget for selection actions panel buttons, to prevent them being drawn over the pop-up palette. More...

#include <kis_selection_actions_panel_button.h>

+ Inheritance diagram for KisSelectionActionsPanelButton:

Public Member Functions

void draw (QPainter &painter)
 
 KisSelectionActionsPanelButton (const QString &iconName, const QString &tooltip, int size, QWidget *parent)
 
 ~KisSelectionActionsPanelButton ()
 

Protected Member Functions

void paintEvent (QPaintEvent *e) override
 

Detailed Description

Custom widget for selection actions panel buttons, to prevent them being drawn over the pop-up palette.

Definition at line 13 of file kis_selection_actions_panel_button.h.

Constructor & Destructor Documentation

◆ KisSelectionActionsPanelButton()

KisSelectionActionsPanelButton::KisSelectionActionsPanelButton ( const QString & iconName,
const QString & tooltip,
int size,
QWidget * parent )

Definition at line 16 of file kis_selection_actions_panel_button.cpp.

17 : QAbstractButton(parent)
18{
19 setIcon(KisIconUtils::loadIcon(iconName));
20 setFixedSize(size, size);
21 setToolTip(tooltip);
22 setCursor(Qt::PointingHandCursor);
23 setIconSize(QSize(size - ICON_SIZE_OFFSET, size - ICON_SIZE_OFFSET));
24}
static constexpr int ICON_SIZE_OFFSET
QIcon loadIcon(const QString &name)

References ICON_SIZE_OFFSET, and KisIconUtils::loadIcon().

◆ ~KisSelectionActionsPanelButton()

KisSelectionActionsPanelButton::~KisSelectionActionsPanelButton ( )

Definition at line 26 of file kis_selection_actions_panel_button.cpp.

27{
28
29}

Member Function Documentation

◆ draw()

void KisSelectionActionsPanelButton::draw ( QPainter & painter)

Definition at line 31 of file kis_selection_actions_panel_button.cpp.

32{
33 QRect rect = geometry();
34 //Draw an outline when the button is pressed
35 if(this->isDown()) {
36 QColor bgColor = qApp->palette().window().color();
37 //Invert the background color
38 bgColor.setRed(255 - bgColor.red());
39 bgColor.setGreen(255 - bgColor.green());
40 bgColor.setBlue(255 - bgColor.blue());
41
42 QPainterPath path;
43 path.addRoundedRect(rect, 3, 3);
44 QPen pen = bgColor;
45 pen.setWidth(2);
46
47 painter.setPen(pen);
48 painter.drawPath(path) ;
49 }
50
51 QPixmap map = this->icon().pixmap(iconSize());
52 painter.drawPixmap(rect.x() + ICON_SIZE_OFFSET / 2.0 , rect.y() + ICON_SIZE_OFFSET / 2.0, map);
53}
int iconSize(qreal width, qreal height)

References ICON_SIZE_OFFSET, and iconSize().

◆ paintEvent()

void KisSelectionActionsPanelButton::paintEvent ( QPaintEvent * e)
overrideprotected

Definition at line 57 of file kis_selection_actions_panel_button.cpp.

58{
59 Q_UNUSED(e);
60}

The documentation for this class was generated from the following files: