mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
1a869833d8
Catch mouse move events and move the legend accordingly. Currently, this is the only item that can be dragged and therefore there is no need of doing some kind of fancy interface. Simply keep a pointer to the legend if it is dragged. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
36 lines
761 B
C++
36 lines
761 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 "chartitem.h"
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <QFont>
|
|
|
|
class QFontMetrics;
|
|
|
|
class Legend : public ChartRectItem {
|
|
public:
|
|
Legend(StatsView &view, const std::vector<QString> &names);
|
|
void resize(); // called when the chart size changes.
|
|
private:
|
|
// Each entry is a text besides a rectangle showing the color
|
|
struct Entry {
|
|
QString name;
|
|
QBrush rectBrush;
|
|
QPointF pos;
|
|
double width;
|
|
Entry(const QString &name, int idx, int numBins, const QFontMetrics &fm);
|
|
};
|
|
int displayedItems;
|
|
double width;
|
|
double height;
|
|
QFont font;
|
|
int fontHeight;
|
|
std::vector<Entry> entries;
|
|
void hide();
|
|
};
|
|
|
|
#endif
|