| 23 | QColor PatternRect::highlighted_outline{252, 148, 77}; |
| 24 | |
| 25 | static void addText(QGraphicsScene &scene, int col, int row, |
| 26 | QGraphicsSimpleTextItem *text_item, |
| 27 | Align alignment = Align::CENTER) |
| 28 | { |
| 29 | int item_width = text_item->boundingRect().width(); |
| 30 | int item_height = text_item->boundingRect().height(); |
| 31 | |
| 32 | // center the item vertically at y |
| 33 | int y_offset = item_height / 2; |
| 34 | int x_offset = 0; |
| 35 | |
| 36 | switch (alignment) |
| 37 | { |
| 38 | case Align::CENTER: |
| 39 | x_offset = (COLUMN_WIDTH - item_width) / 2; |
| 40 | break; |
| 41 | case Align::RIGHT: |
| 42 | x_offset = COLUMN_WIDTH - item_width; |
| 43 | break; |
| 44 | } |
| 45 | |
| 46 | int x = col * COLUMN_WIDTH + x_offset; |
| 47 | int y = row * ROW_HEIGHT + y_offset; |
| 48 | |
| 49 | text_item->setPos(x, y - y_offset); |
| 50 | scene.addItem(text_item); |
| 51 | } |
| 52 | |
| 53 | static std::shared_ptr<PatternRect> addRect(HistogramScene &hist_scene, int row, int val) |
| 54 | { |
no test coverage detected