2016-07-10 01:29:09 +03:00
|
|
|
/************************************************************************
|
2016-09-15 22:30:32 +03:00
|
|
|
* file name : easy_graphics_scrollbar.h
|
2016-07-10 01:29:09 +03:00
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/07/04
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* description : This file contains declaration of
|
2016-07-10 01:29:09 +03:00
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/07/04 Victor Zarubkin: Initial commit.
|
|
|
|
* :
|
|
|
|
* : *
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* license : Lightweight profiler library for c++
|
|
|
|
* : Copyright(C) 2016 Sergey Yagovtsev, Victor Zarubkin
|
|
|
|
* :
|
2016-11-13 16:39:59 +03:00
|
|
|
* :
|
|
|
|
* : Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* : you may not use this file except in compliance with the License.
|
|
|
|
* : You may obtain a copy of the License at
|
|
|
|
* :
|
|
|
|
* : http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* :
|
|
|
|
* : Unless required by applicable law or agreed to in writing, software
|
|
|
|
* : distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* : See the License for the specific language governing permissions and
|
|
|
|
* : limitations under the License.
|
|
|
|
* :
|
|
|
|
* :
|
|
|
|
* : GNU General Public License Usage
|
|
|
|
* : Alternatively, this file may be used under the terms of the GNU
|
|
|
|
* : General Public License as published by the Free Software Foundation,
|
|
|
|
* : either version 3 of the License, or (at your option) any later version.
|
2016-09-06 21:49:32 +03:00
|
|
|
* :
|
|
|
|
* : This program is distributed in the hope that it will be useful,
|
|
|
|
* : but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* : GNU General Public License for more details.
|
|
|
|
* :
|
|
|
|
* : You should have received a copy of the GNU General Public License
|
|
|
|
* : along with this program.If not, see <http://www.gnu.org/licenses/>.
|
2016-07-10 01:29:09 +03:00
|
|
|
************************************************************************/
|
|
|
|
|
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 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;
|
|
|
|
|
2016-11-19 05:39:41 +03:00
|
|
|
void dragEnterEvent(QDragEnterEvent*) override {}
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2016-09-21 22:09:04 +03:00
|
|
|
void clear();
|
|
|
|
|
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-09-06 21:49:32 +03:00
|
|
|
void onThreadActionClicked(bool);
|
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
|