forked from qt-creator/qt-creator
QML Observer: Build together on runtime with debugging tools
Moved qmljsdebugger to a dir under qml/, made qmlobserver compile without creator dependencies and made it compile with debugging helpers. Reviewed-by: hjk
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#ifndef BOUNDINGRECTHIGHLIGHTER_H
|
||||
#define BOUNDINGRECTHIGHLIGHTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include "layeritem.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
|
||||
QT_FORWARD_DECLARE_CLASS(QPainter);
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget);
|
||||
QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem);
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer);
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewObserver;
|
||||
class BoundingBox;
|
||||
|
||||
class BoundingRectHighlighter : public LayerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingRectHighlighter(QDeclarativeViewObserver *view);
|
||||
~BoundingRectHighlighter();
|
||||
void clear();
|
||||
void highlight(QList<QGraphicsObject*> items);
|
||||
void highlight(QGraphicsObject* item);
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
void animTimeout();
|
||||
void itemDestroyed(QObject *);
|
||||
|
||||
private:
|
||||
BoundingBox *boxFor(QGraphicsObject *item) const;
|
||||
void highlightAll(bool animate);
|
||||
BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight);
|
||||
void removeBoundingBox(BoundingBox *box);
|
||||
void freeBoundingBox(BoundingBox *box);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingRectHighlighter);
|
||||
|
||||
QDeclarativeViewObserver *m_view;
|
||||
QList<BoundingBox* > m_boxes;
|
||||
QList<BoundingBox* > m_freeBoxes;
|
||||
QTimer *m_animTimer;
|
||||
qreal m_animScale;
|
||||
int m_animFrame;
|
||||
|
||||
};
|
||||
|
||||
class BoundingBox : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, QObject *parent = 0);
|
||||
~BoundingBox();
|
||||
QWeakPointer<QGraphicsObject> highlightedObject;
|
||||
QGraphicsPolygonItem *highlightPolygon;
|
||||
QGraphicsPolygonItem *highlightPolygonEdge;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingBox);
|
||||
|
||||
};
|
||||
|
||||
class BoundingBoxPolygonItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
explicit BoundingBoxPolygonItem(QGraphicsItem *item);
|
||||
int type() const;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // BOUNDINGRECTHIGHLIGHTER_H
|
||||
Reference in New Issue
Block a user