Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9550ea1fdc | ||
|
|
cad473c097 | ||
|
|
89264d97bb | ||
|
|
096291a6c4 | ||
|
|
1fcb241189 | ||
|
|
996b33b1fb | ||
|
|
fea26bfc60 | ||
|
|
6a3717b8c1 |
@@ -38,6 +38,8 @@ ViewFactory* ComponentFactory::getViewFactory() const
|
||||
std::shared_ptr<Component> ComponentFactory::createCodeComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<CodeView> view = m_viewFactory->createCodeView(viewLayout);
|
||||
view->createOverlay();
|
||||
|
||||
std::shared_ptr<CodeController> controller = std::make_shared<CodeController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
@@ -53,6 +55,8 @@ std::shared_ptr<Component> ComponentFactory::createFeatureComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createGraphComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<View> view = m_viewFactory->createGraphView(viewLayout);
|
||||
view->createOverlay();
|
||||
|
||||
std::shared_ptr<GraphController> controller = std::make_shared<GraphController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
|
||||
@@ -25,12 +25,13 @@ CodeController::~CodeController()
|
||||
{
|
||||
}
|
||||
|
||||
const uint CodeController::s_lineRadius = 2;
|
||||
|
||||
void CodeController::handleMessage(MessageActivateAll* message)
|
||||
{
|
||||
TRACE("code all");
|
||||
|
||||
CodeView* view = getView();
|
||||
view->showOverlay();
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
@@ -82,7 +83,6 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
|
||||
snippets.insert(snippets.begin(), statsSnippet);
|
||||
|
||||
CodeView* view = getView();
|
||||
view->clear();
|
||||
view->setErrorInfos(errors);
|
||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||
@@ -101,6 +101,7 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
||||
TRACE("code activate");
|
||||
|
||||
CodeView* view = getView();
|
||||
view->showOverlay();
|
||||
|
||||
if (!message->keepContent())
|
||||
{
|
||||
@@ -168,6 +169,7 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
case MessageChangeFileView::FILE_SNIPPETS:
|
||||
if (message->needsData)
|
||||
{
|
||||
view->showOverlay();
|
||||
view->addCodeSnippets(getSnippetsForFile(
|
||||
m_collection->getTokenLocationFileByPath(message->filePath), !message->showErrors), false);
|
||||
}
|
||||
@@ -177,6 +179,8 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
case MessageChangeFileView::FILE_MAXIMIZED:
|
||||
if (message->needsData)
|
||||
{
|
||||
view->showOverlay();
|
||||
|
||||
CodeSnippetParams params;
|
||||
params.startLineNumber = 1;
|
||||
params.refCount = -1;
|
||||
@@ -246,11 +250,13 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
TRACE("code errors");
|
||||
|
||||
CodeView* view = getView();
|
||||
view->showOverlay();
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
CodeView* view = getView();
|
||||
view->clear();
|
||||
view->setErrorInfos(errors);
|
||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||
@@ -263,6 +269,7 @@ void CodeController::handleMessage(MessageSearchFullText* message)
|
||||
TRACE("code fulltext");
|
||||
|
||||
CodeView* view = getView();
|
||||
view->showOverlay();
|
||||
view->clear();
|
||||
|
||||
m_collection = m_storageAccess->getFullTextSearchLocations(message->searchTerm, message->caseSensitive);
|
||||
|
||||
@@ -46,8 +46,6 @@ public:
|
||||
~CodeController();
|
||||
|
||||
private:
|
||||
static const uint s_lineRadius;
|
||||
|
||||
virtual void handleMessage(MessageActivateAll* message);
|
||||
virtual void handleMessage(MessageActivateLocalSymbols* message);
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
|
||||
@@ -26,6 +26,8 @@ void GraphController::handleMessage(MessageActivateAll* message)
|
||||
{
|
||||
TRACE("graph all");
|
||||
|
||||
getView()->showOverlay();
|
||||
|
||||
m_activeNodeIds.clear();
|
||||
m_activeEdgeIds.clear();
|
||||
|
||||
@@ -43,6 +45,8 @@ void GraphController::handleMessage(MessageActivateTokens* message)
|
||||
{
|
||||
TRACE("graph activate");
|
||||
|
||||
getView()->showOverlay();
|
||||
|
||||
if (message->isEdge || message->keepContent())
|
||||
{
|
||||
m_activeEdgeIds = message->tokenIds;
|
||||
|
||||
@@ -25,14 +25,29 @@ void View::addToLayout()
|
||||
m_viewLayout->addView(this);
|
||||
}
|
||||
|
||||
void View::setComponent(Component* component)
|
||||
{
|
||||
m_component = component;
|
||||
}
|
||||
|
||||
ViewWidgetWrapper* View::getWidgetWrapper() const
|
||||
{
|
||||
return m_widgetWrapper.get();
|
||||
}
|
||||
|
||||
void View::setComponent(Component* component)
|
||||
void View::createOverlay()
|
||||
{
|
||||
m_component = component;
|
||||
getWidgetWrapper()->createOverlay();
|
||||
}
|
||||
|
||||
void View::showOverlay()
|
||||
{
|
||||
getWidgetWrapper()->showOverlay();
|
||||
}
|
||||
|
||||
void View::hideOverlay()
|
||||
{
|
||||
getWidgetWrapper()->hideOverlay();
|
||||
}
|
||||
|
||||
ViewLayout* View::getViewLayout() const
|
||||
|
||||
@@ -35,6 +35,10 @@ public:
|
||||
|
||||
ViewWidgetWrapper* getWidgetWrapper() const;
|
||||
|
||||
void createOverlay();
|
||||
void showOverlay();
|
||||
void hideOverlay();
|
||||
|
||||
protected:
|
||||
template <typename ControllerType>
|
||||
ControllerType* getController();
|
||||
|
||||
@@ -6,6 +6,10 @@ class ViewWidgetWrapper
|
||||
public:
|
||||
ViewWidgetWrapper();
|
||||
virtual ~ViewWidgetWrapper();
|
||||
|
||||
virtual void createOverlay() = 0;
|
||||
virtual void showOverlay() = 0;
|
||||
virtual void hideOverlay() = 0;
|
||||
};
|
||||
|
||||
#endif // VIEW_WIDGET_WRAPPER_H
|
||||
|
||||
@@ -24,6 +24,11 @@ TimePoint::TimePoint(std::string s)
|
||||
}
|
||||
}
|
||||
|
||||
TimePoint TimePoint::now()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
}
|
||||
|
||||
std::string TimePoint::toString() const
|
||||
{
|
||||
std::stringstream stream;
|
||||
@@ -32,4 +37,9 @@ std::string TimePoint::toString() const
|
||||
stream.imbue(std::locale(std::locale::classic(), facet));
|
||||
stream << m_time;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
size_t TimePoint::deltaMS(const TimePoint& other) const
|
||||
{
|
||||
return (m_time - other.m_time).total_milliseconds();
|
||||
}
|
||||
@@ -11,6 +11,8 @@ public:
|
||||
//TimePoint(time_t t);
|
||||
TimePoint(std::string s);
|
||||
|
||||
static TimePoint now();
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
inline bool operator==(const TimePoint& rhs){ return m_time == rhs.m_time; }
|
||||
@@ -20,7 +22,9 @@ public:
|
||||
inline bool operator<=(const TimePoint& rhs){ return m_time <= rhs.m_time; }
|
||||
inline bool operator>=(const TimePoint& rhs){ return m_time >= rhs.m_time; }
|
||||
|
||||
inline float operator-(const TimePoint& rhs){ return (m_time - rhs.m_time).total_milliseconds() / 1000.0f; }
|
||||
inline float operator-(const TimePoint& rhs){ return deltaMS(rhs) / 1000.0f; }
|
||||
|
||||
size_t deltaMS(const TimePoint& other) const;
|
||||
|
||||
private:
|
||||
boost::posix_time::ptime m_time;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
TimePoint utility::durationStart()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
return TimePoint::now();
|
||||
}
|
||||
|
||||
float utility::duration(const TimePoint& start)
|
||||
|
||||
@@ -102,6 +102,8 @@ add_files(
|
||||
qt/view/QtUndoRedoView.h
|
||||
qt/view/QtViewFactory.cpp
|
||||
qt/view/QtViewFactory.h
|
||||
qt/view/QtViewOverlay.cpp
|
||||
qt/view/QtViewOverlay.h
|
||||
qt/view/QtViewWidgetWrapper.cpp
|
||||
qt/view/QtViewWidgetWrapper.h
|
||||
|
||||
|
||||
@@ -157,6 +157,8 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
|
||||
m_widget->updateFiles();
|
||||
|
||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||
|
||||
hideOverlay();
|
||||
}
|
||||
|
||||
void QtCodeView::doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert)
|
||||
@@ -170,12 +172,16 @@ void QtCodeView::doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippet
|
||||
|
||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||
|
||||
hideOverlay();
|
||||
|
||||
m_widget->scrollToActiveFileIfRequested();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
{
|
||||
m_widget->addCodeSnippet(params);
|
||||
|
||||
hideOverlay();
|
||||
}
|
||||
|
||||
void QtCodeView::doSetFileState(const FilePath filePath, FileState state)
|
||||
@@ -192,6 +198,8 @@ void QtCodeView::doSetFileState(const FilePath filePath, FileState state)
|
||||
m_widget->setFileMaximized(filePath);
|
||||
break;
|
||||
}
|
||||
|
||||
hideOverlay();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowFirstActiveSnippet(const std::vector<Id>& activeTokenIds, bool scrollTo)
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
#include "qt/graphics/QtGraphicsView.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h"
|
||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeBundle.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
@@ -251,6 +251,8 @@ void QtGraphView::doRebuildGraph(
|
||||
m_graph = graph;
|
||||
}
|
||||
|
||||
hideOverlay();
|
||||
|
||||
if (animated)
|
||||
{
|
||||
createTransition();
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
#include "qt/view/QtViewOverlay.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QTimer>
|
||||
|
||||
ResizeFilter::ResizeFilter(QWidget* widget)
|
||||
: m_widget(widget)
|
||||
{
|
||||
}
|
||||
|
||||
bool ResizeFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Resize)
|
||||
{
|
||||
QWidget* parent = dynamic_cast<QWidget*>(obj);
|
||||
m_widget->setGeometry(0, 0, parent->width(), parent->height());
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
QtOverlay::QtOverlay(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_count(rand() % 1000000)
|
||||
, m_size(40)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(animate()));
|
||||
}
|
||||
|
||||
void QtOverlay::start()
|
||||
{
|
||||
m_timePoint = TimePoint::now();
|
||||
m_timer->start(FRAME_DELAY_MS);
|
||||
show();
|
||||
}
|
||||
|
||||
void QtOverlay::stop()
|
||||
{
|
||||
m_timer->stop();
|
||||
hide();
|
||||
}
|
||||
|
||||
void QtOverlay::animate()
|
||||
{
|
||||
TimePoint t = TimePoint::now();
|
||||
size_t dt = t.deltaMS(m_timePoint);
|
||||
|
||||
if (dt < 5)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_timePoint = t;
|
||||
m_count += dt;
|
||||
|
||||
QPoint center = geometry().center();
|
||||
update(QRect(center.x() - m_size / 2, center.y() - m_size / 2, m_size, m_size));
|
||||
}
|
||||
|
||||
void QtOverlay::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(geometry(), "#AAFFFFFF");
|
||||
|
||||
QPoint center = geometry().center();
|
||||
|
||||
size_t x = m_size / 2;
|
||||
size_t y = m_size / 2;
|
||||
size_t s = (m_count / 7) % 200;
|
||||
|
||||
if (s < 100)
|
||||
{
|
||||
x = std::cos(3.1415f * s / 100) * x;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = std::cos(3.1415f * (s - 100) / 100) * y;
|
||||
}
|
||||
|
||||
painter.translate(center.x(), center.y());
|
||||
// painter.rotate(m_count / 8);
|
||||
|
||||
if (s > 50 && s < 150)
|
||||
{
|
||||
painter.setBrush(QBrush("#882E3C86"));
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.setBrush(QBrush("#88007AC2"));
|
||||
}
|
||||
|
||||
painter.setPen(QPen(Qt::transparent));
|
||||
|
||||
painter.drawEllipse(-x, -y, 2 * x, 2 * y);
|
||||
}
|
||||
|
||||
|
||||
QtViewOverlay::QtViewOverlay(QWidget* parent)
|
||||
: m_parent(parent)
|
||||
, m_showFunctor(std::bind(&QtViewOverlay::doShowOverlay, this))
|
||||
, m_hideFunctor(std::bind(&QtViewOverlay::doHideOverlay, this))
|
||||
{
|
||||
m_overlay = new QtOverlay(m_parent);
|
||||
m_overlay->hide();
|
||||
|
||||
m_parent->installEventFilter(new ResizeFilter(m_overlay));
|
||||
|
||||
m_delayTimer = new QTimer(m_overlay);
|
||||
m_delayTimer->setSingleShot(true);
|
||||
QObject::connect(m_delayTimer, SIGNAL(timeout()), m_overlay, SLOT(start()));
|
||||
}
|
||||
|
||||
void QtViewOverlay::showOverlay()
|
||||
{
|
||||
m_showFunctor();
|
||||
}
|
||||
|
||||
void QtViewOverlay::hideOverlay()
|
||||
{
|
||||
m_hideFunctor();
|
||||
}
|
||||
|
||||
void QtViewOverlay::doShowOverlay()
|
||||
{
|
||||
m_delayTimer->start(500);
|
||||
}
|
||||
|
||||
void QtViewOverlay::doHideOverlay()
|
||||
{
|
||||
m_delayTimer->stop();
|
||||
m_overlay->stop();
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef QT_VIEW_OVERLAY
|
||||
#define QT_VIEW_OVERLAY
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
class ResizeFilter
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void triggered();
|
||||
|
||||
public:
|
||||
ResizeFilter(QWidget* widget);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private:
|
||||
QWidget* m_widget;
|
||||
};
|
||||
|
||||
|
||||
class QtOverlay
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtOverlay(QWidget* parent = nullptr);
|
||||
|
||||
static const size_t FRAME_DELAY_MS = 25;
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void stop();
|
||||
void animate();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QTimer* m_timer;
|
||||
|
||||
size_t m_count;
|
||||
size_t m_size;
|
||||
|
||||
TimePoint m_timePoint;
|
||||
};
|
||||
|
||||
|
||||
class QtViewOverlay
|
||||
{
|
||||
public:
|
||||
QtViewOverlay(QWidget* parent = 0);
|
||||
|
||||
void showOverlay();
|
||||
void hideOverlay();
|
||||
|
||||
private:
|
||||
void doShowOverlay();
|
||||
void doHideOverlay();
|
||||
|
||||
QWidget* m_parent;
|
||||
QtOverlay* m_overlay;
|
||||
|
||||
QTimer* m_delayTimer;
|
||||
|
||||
QtThreadedFunctor<void> m_showFunctor;
|
||||
QtThreadedFunctor<void> m_hideFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_OVERLAY
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "qt/view/QtViewOverlay.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
QWidget* QtViewWidgetWrapper::getWidgetOfView(const View* view)
|
||||
@@ -24,6 +25,7 @@ QWidget* QtViewWidgetWrapper::getWidgetOfView(const View* view)
|
||||
|
||||
QtViewWidgetWrapper::QtViewWidgetWrapper(QWidget* widget)
|
||||
: m_widget(widget)
|
||||
, m_overlay(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,6 +33,27 @@ QtViewWidgetWrapper::~QtViewWidgetWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void QtViewWidgetWrapper::createOverlay()
|
||||
{
|
||||
m_overlay = new QtViewOverlay(m_widget);
|
||||
}
|
||||
|
||||
void QtViewWidgetWrapper::showOverlay()
|
||||
{
|
||||
if (m_overlay)
|
||||
{
|
||||
m_overlay->showOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
void QtViewWidgetWrapper::hideOverlay()
|
||||
{
|
||||
if (m_overlay)
|
||||
{
|
||||
m_overlay->hideOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* QtViewWidgetWrapper::getWidget()
|
||||
{
|
||||
return m_widget;
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
#include "component/view/ViewWidgetWrapper.h"
|
||||
|
||||
class View;
|
||||
class QtViewOverlay;
|
||||
|
||||
class QtViewWidgetWrapper: public ViewWidgetWrapper
|
||||
class QtViewWidgetWrapper
|
||||
: public ViewWidgetWrapper
|
||||
{
|
||||
public:
|
||||
static QWidget* getWidgetOfView(const View* view);
|
||||
@@ -15,10 +17,16 @@ public:
|
||||
QtViewWidgetWrapper(QWidget* widget);
|
||||
virtual ~QtViewWidgetWrapper();
|
||||
|
||||
virtual void createOverlay() override;
|
||||
virtual void showOverlay() override;
|
||||
virtual void hideOverlay() override;
|
||||
|
||||
QWidget* getWidget();
|
||||
|
||||
private:
|
||||
QWidget* m_widget;
|
||||
|
||||
QtViewOverlay* m_overlay;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_WIDGET_WRAPPER_H
|
||||
|
||||
Reference in New Issue
Block a user