MCPcopy Create free account
hub / github.com/ccMSC/ckb / paintEvent

Method paintEvent

src/ckb/keywidget.cpp:70–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void KeyWidget::paintEvent(QPaintEvent*){
71 const QColor bgColor(68, 64, 64);
72 const QColor keyColor(112, 110, 110);
73 const QColor sniperColor(130, 90, 90);
74 const QColor thumbColor(34, 32, 32);
75 const QColor transparentColor(0, 0, 0, 0);
76 const QColor highlightColor(136, 176, 240);
77 const QColor highlightAnimColor(136, 200, 240);
78 const QColor animColor(112, 200, 110);
79
80 // Determine which keys to highlight
81 QBitArray highlight;
82 switch(mouseDownMode){
83 case SET:
84 highlight = newSelection;
85 break;
86 case ADD:
87 highlight = selection | newSelection;
88 break;
89 case SUBTRACT:
90 highlight = selection & ~newSelection;
91 break;
92 case TOGGLE:
93 highlight = selection ^ newSelection;
94 break;
95 default:
96 highlight = selection;
97 }
98
99 QPainter painter(this);
100#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
101 int ratio = painter.device()->devicePixelRatio();
102#else
103 int ratio = 1;
104#endif
105 int wWidth = width(), wHeight = height();
106 KeyMap::Model model = keyMap.model();
107 KeyMap::Layout layout = keyMap.layout();
108 float scale, offX, offY;
109 drawInfo(scale, offX, offY, ratio);
110 // Draw background
111 painter.setPen(Qt::NoPen);
112 painter.setRenderHint(QPainter::Antialiasing, true);
113
114 if(keyMap.isMouse()){
115 // Draw mouse overlays
116 const QImage* overlay = 0;
117 float xpos = 0.f, ypos = 0.f;
118 if(model == KeyMap::M65){
119 if(!m65Overlay)
120 m65Overlay = new QImage(":/img/overlay_m65.png");
121 overlay = m65Overlay;
122 xpos = 2.f;
123 ypos = -2.f;
124 } else if(model == KeyMap::SABRE){
125 if(!sabOverlay)
126 sabOverlay = new QImage(":/img/overlay_sabre.png");
127 overlay = sabOverlay;

Callers

nothing calls this directly

Calls 15

heightEnum · 0.85
monoRgbFunction · 0.85
KeyActionClass · 0.85
widthMethod · 0.80
heightMethod · 0.80
colorForNameMethod · 0.80
keyMethod · 0.80
isProgramMethod · 0.80
isSpecialMethod · 0.80
isMediaMethod · 0.80
modelMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected