2016-07-10 01:29:09 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : graphics_scrollbar.h
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/07/04
|
|
|
|
* copyright : (c) 2016 Victor Zarubkin
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : .
|
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/07/04 Victor Zarubkin: Initial commit.
|
|
|
|
* :
|
|
|
|
* : *
|
|
|
|
* ----------------- :
|
|
|
|
* license : TODO: add license text
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef EASY_PROFILER__GRAPHICS_SCROLLBAR__H
|
|
|
|
#define EASY_PROFILER__GRAPHICS_SCROLLBAR__H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsScene>
|
2016-07-31 13:13:48 +03:00
|
|
|
#include <QGraphicsRectItem>
|
2016-08-03 00:06:36 +03:00
|
|
|
#include "common_types.h"
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
class GraphicsHorizontalSlider : public QGraphicsRectItem
|
2016-07-10 01:29:09 +03:00
|
|
|
{
|
2016-07-31 13:13:48 +03:00
|
|
|
typedef QGraphicsRectItem Parent;
|
2016-07-10 01:29:09 +03:00
|
|
|
typedef GraphicsHorizontalSlider This;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
qreal m_halfwidth;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
GraphicsHorizontalSlider();
|
|
|
|
virtual ~GraphicsHorizontalSlider();
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget = nullptr) override;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
qreal width() const;
|
|
|
|
qreal halfwidth() const;
|
|
|
|
|
|
|
|
void setWidth(qreal _width);
|
|
|
|
void setHalfwidth(qreal _halfwidth);
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
void setColor(QRgb _color);
|
|
|
|
|
|
|
|
}; // END of class GraphicsHorizontalSlider.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-03 00:06:36 +03:00
|
|
|
class MinimapItem : public QGraphicsItem
|
|
|
|
{
|
|
|
|
typedef QGraphicsItem Parent;
|
|
|
|
typedef MinimapItem This;
|
|
|
|
|
|
|
|
QRectF m_boundingRect;
|
|
|
|
qreal m_maxDuration;
|
|
|
|
const ProfItems* m_pSource;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MinimapItem();
|
|
|
|
virtual ~MinimapItem();
|
|
|
|
|
|
|
|
// Public virtual methods
|
|
|
|
|
|
|
|
QRectF boundingRect() const override;
|
|
|
|
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget = nullptr) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
|
|
|
|
|
|
|
void setBoundingRect(const QRectF& _rect);
|
|
|
|
|
|
|
|
void setSource(const ProfItems* _items);
|
|
|
|
|
|
|
|
}; // END of class MinimapItem.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-10 01:29:09 +03:00
|
|
|
class GraphicsHorizontalScrollbar : public QGraphicsView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
typedef QGraphicsView Parent;
|
|
|
|
typedef GraphicsHorizontalScrollbar This;
|
|
|
|
|
2016-08-03 00:06:36 +03:00
|
|
|
qreal m_minimumValue;
|
|
|
|
qreal m_maximumValue;
|
|
|
|
qreal m_value;
|
|
|
|
qreal m_windowScale;
|
|
|
|
QPoint m_mousePressPos;
|
|
|
|
Qt::MouseButtons m_mouseButtons;
|
|
|
|
GraphicsHorizontalSlider* m_slider;
|
|
|
|
GraphicsHorizontalSlider* m_chronometerIndicator;
|
|
|
|
MinimapItem* m_minimap;
|
|
|
|
bool m_bScrolling;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
GraphicsHorizontalScrollbar(QWidget* _parent = nullptr);
|
|
|
|
virtual ~GraphicsHorizontalScrollbar();
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void mousePressEvent(QMouseEvent* _event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent* _event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* _event) override;
|
|
|
|
void resizeEvent(QResizeEvent* _event) override;
|
|
|
|
|
|
|
|
qreal getWindowScale() const;
|
|
|
|
|
|
|
|
qreal minimum() const;
|
|
|
|
qreal maximum() const;
|
|
|
|
qreal range() const;
|
|
|
|
qreal value() const;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void setValue(qreal _value);
|
|
|
|
void setRange(qreal _minValue, qreal _maxValue);
|
|
|
|
void setSliderWidth(qreal _width);
|
2016-08-03 00:06:36 +03:00
|
|
|
void setChronoPos(qreal _left, qreal _right);
|
|
|
|
void showChrono();
|
|
|
|
void hideChrono();
|
|
|
|
|
|
|
|
void setMinimapFrom(const ProfItems* _items);
|
|
|
|
|
|
|
|
inline void setMinimapFrom(const ProfItems& _items)
|
|
|
|
{
|
|
|
|
setMinimapFrom(&_items);
|
|
|
|
}
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void rangeChanged();
|
|
|
|
void valueChanged(qreal _value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void onWindowWidthChange(qreal _width);
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
}; // END of class GraphicsHorizontalScrollbar.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif // EASY_PROFILER__GRAPHICS_SCROLLBAR__H
|