mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
9beec46e22
Dirk says rounded corners look better. This now looks a bit extreme to me and probably the border size should be increased. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
37 lines
899 B
C++
37 lines
899 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
// A legend box, which is shown on the chart.
|
|
#ifndef STATS_LEGEND_H
|
|
#define STATS_LEGEND_H
|
|
|
|
#include "backend-shared/roundrectitem.h"
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class QGraphicsSceneMouseEvent;
|
|
|
|
class Legend : public RoundRectItem {
|
|
public:
|
|
Legend(QGraphicsWidget *chart, const std::vector<QString> &names);
|
|
void hover(QPointF pos);
|
|
void resize(); // called when the chart size changes.
|
|
private:
|
|
// Each entry is a text besides a rectangle showing the color
|
|
struct Entry {
|
|
std::unique_ptr<QGraphicsRectItem> rect;
|
|
std::unique_ptr<QGraphicsSimpleTextItem> text;
|
|
QPointF pos;
|
|
double width;
|
|
Entry(const QString &name, int idx, int numBins, QGraphicsItem *parent);
|
|
};
|
|
QGraphicsWidget *chart;
|
|
int displayedItems;
|
|
double width;
|
|
double height;
|
|
int fontHeight;
|
|
std::vector<Entry> entries;
|
|
void updatePosition();
|
|
void hide();
|
|
};
|
|
|
|
#endif
|