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
|
|
|
|
************************************************************************/
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
#ifndef EASY__GRAPHICS_SCROLLBAR__H
|
|
|
|
#define EASY__GRAPHICS_SCROLLBAR__H
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QGraphicsView>
|
2016-07-31 13:13:48 +03:00
|
|
|
#include <QGraphicsRectItem>
|
2016-08-03 23:00:04 +03:00
|
|
|
#include <QAction>
|
2016-08-23 22:44:59 +03:00
|
|
|
#include <QPolygonF>
|
2016-08-03 00:06:36 +03:00
|
|
|
#include "common_types.h"
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
class EasyGraphicsSliderItem : public QGraphicsRectItem
|
2016-07-10 01:29:09 +03:00
|
|
|
{
|
2016-08-03 23:00:04 +03:00
|
|
|
typedef QGraphicsRectItem Parent;
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyGraphicsSliderItem This;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-08-23 22:44:59 +03:00
|
|
|
QPolygonF m_indicator;
|
2016-07-31 13:13:48 +03:00
|
|
|
qreal m_halfwidth;
|
2016-08-23 22:44:59 +03:00
|
|
|
bool m_bMain;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-08-19 00:35:05 +03:00
|
|
|
explicit EasyGraphicsSliderItem(bool _main);
|
2016-08-18 23:26:41 +03:00
|
|
|
virtual ~EasyGraphicsSliderItem();
|
2016-07-10 01:29:09 +03:00
|
|
|
|
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);
|
2016-08-06 14:50:31 +03:00
|
|
|
void setColor(const QColor& _color);
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyGraphicsSliderItem.
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
class EasyMinimapItem : public QGraphicsItem
|
2016-08-03 00:06:36 +03:00
|
|
|
{
|
|
|
|
typedef QGraphicsItem Parent;
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyMinimapItem This;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
QRectF m_boundingRect;
|
|
|
|
qreal m_maxDuration;
|
2016-08-04 22:38:45 +03:00
|
|
|
qreal m_minDuration;
|
2016-08-30 22:51:18 +03:00
|
|
|
const ::profiler_gui::EasyItems* m_pSource;
|
2016-08-03 23:00:04 +03:00
|
|
|
::profiler::thread_id_t m_threadId;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
EasyMinimapItem();
|
|
|
|
virtual ~EasyMinimapItem();
|
2016-08-03 00:06:36 +03:00
|
|
|
|
|
|
|
// Public virtual methods
|
|
|
|
|
|
|
|
QRectF boundingRect() const override;
|
|
|
|
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget = nullptr) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
::profiler::thread_id_t threadId() const;
|
|
|
|
|
2016-08-03 00:06:36 +03:00
|
|
|
void setBoundingRect(const QRectF& _rect);
|
2016-08-23 22:44:59 +03:00
|
|
|
void setBoundingRect(qreal x, qreal y, qreal w, qreal h);
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2016-08-30 22:51:18 +03:00
|
|
|
void setSource(::profiler::thread_id_t _thread_id, const ::profiler_gui::EasyItems* _items);
|
2016-08-03 23:00:04 +03:00
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyMinimapItem.
|
2016-08-03 23:00:04 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
class EasyIdAction : public QAction
|
2016-08-03 23:00:04 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
typedef QAction Parent;
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyIdAction This;
|
2016-08-03 23:00:04 +03:00
|
|
|
|
|
|
|
::profiler::thread_id_t m_id;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
EasyIdAction(const QString& _label, ::profiler::thread_id_t _id) : Parent(_label, nullptr), m_id(_id)
|
2016-08-03 23:00:04 +03:00
|
|
|
{
|
|
|
|
connect(this, &Parent::triggered, this, &This::onToggle);
|
|
|
|
}
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
EasyIdAction(const char* _label, ::profiler::thread_id_t _id) : Parent(_label, nullptr), m_id(_id)
|
2016-08-03 23:00:04 +03:00
|
|
|
{
|
|
|
|
connect(this, &Parent::triggered, this, &This::onToggle);
|
|
|
|
}
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
virtual ~EasyIdAction()
|
2016-08-03 23:00:04 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void onToggle(bool)
|
|
|
|
{
|
|
|
|
emit clicked(m_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void clicked(::profiler::thread_id_t _id);
|
|
|
|
};
|
2016-08-03 00:06:36 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
class EasyGraphicsScrollbar : public QGraphicsView
|
2016-07-10 01:29:09 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
typedef QGraphicsView Parent;
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyGraphicsScrollbar This;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
qreal m_minimumValue;
|
|
|
|
qreal m_maximumValue;
|
|
|
|
qreal m_value;
|
|
|
|
qreal m_windowScale;
|
|
|
|
QPoint m_mousePressPos;
|
|
|
|
Qt::MouseButtons m_mouseButtons;
|
2016-08-18 23:26:41 +03:00
|
|
|
EasyGraphicsSliderItem* m_slider;
|
|
|
|
EasyGraphicsSliderItem* m_chronometerIndicator;
|
|
|
|
EasyMinimapItem* m_minimap;
|
2016-08-03 23:00:04 +03:00
|
|
|
bool m_bScrolling;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-08-19 00:35:05 +03:00
|
|
|
explicit EasyGraphicsScrollbar(QWidget* _parent = nullptr);
|
2016-08-18 23:26:41 +03:00
|
|
|
virtual ~EasyGraphicsScrollbar();
|
2016-08-03 23:00:04 +03:00
|
|
|
|
|
|
|
// Public virtual methods
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void mousePressEvent(QMouseEvent* _event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent* _event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* _event) override;
|
2016-08-21 16:48:42 +03:00
|
|
|
void wheelEvent(QWheelEvent* _event) override;
|
2016-07-31 13:13:48 +03:00
|
|
|
void resizeEvent(QResizeEvent* _event) override;
|
2016-08-03 23:00:04 +03:00
|
|
|
void contextMenuEvent(QContextMenuEvent* _event) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
2016-07-31 13:13:48 +03:00
|
|
|
|
|
|
|
qreal getWindowScale() const;
|
2016-08-03 23:00:04 +03:00
|
|
|
::profiler::thread_id_t minimapThread() const;
|
2016-07-31 13:13:48 +03:00
|
|
|
|
|
|
|
qreal minimum() const;
|
|
|
|
qreal maximum() const;
|
|
|
|
qreal range() const;
|
|
|
|
qreal value() const;
|
2016-08-08 22:17:56 +03:00
|
|
|
qreal sliderWidth() const;
|
|
|
|
qreal sliderHalfWidth() 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();
|
|
|
|
|
2016-08-30 22:51:18 +03:00
|
|
|
void setMinimapFrom(::profiler::thread_id_t _thread_id, const::profiler_gui::EasyItems* _items);
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2016-08-30 22:51:18 +03:00
|
|
|
inline void setMinimapFrom(::profiler::thread_id_t _thread_id, const ::profiler_gui::EasyItems& _items)
|
2016-08-03 00:06:36 +03:00
|
|
|
{
|
2016-08-03 23:00:04 +03:00
|
|
|
setMinimapFrom(_thread_id, &_items);
|
2016-08-03 00:06:36 +03:00
|
|
|
}
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2016-07-31 13:13:48 +03:00
|
|
|
void rangeChanged();
|
|
|
|
void valueChanged(qreal _value);
|
2016-08-21 16:48:42 +03:00
|
|
|
void wheeled(qreal _mouseX, int _wheelDelta);
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
private slots:
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void onThreadActionClicked(::profiler::thread_id_t _id);
|
2016-07-31 13:13:48 +03:00
|
|
|
void onWindowWidthChange(qreal _width);
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyGraphicsScrollbar.
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
#endif // EASY__GRAPHICS_SCROLLBAR__H
|