ui: Keyboard controls (#935)
* switch focus between views with Tab * move focus within views with WASD/HJKL/Arrows * move focus between graph edges by holding Shift * move focus between code references by holding Shift * removed graph panning with WASD and moved zooming to Alt + W/S * removed graph navigation by pressing starting character in graph view lists * changed local reference and custom trail shortcuts * updated Keyboard Shortcuts window * use common back and forward shortcuts and YZ & Shift + YZ * fix macOS issue where widgets don't get proper focus after creating a new tab * don't use shared_ptr in QtMainView fixes #486, #327, #214, #210
This commit is contained in:
@@ -474,6 +474,12 @@ add_files(
|
||||
utility/messaging/type/error/MessageErrorsHelpMessage.h
|
||||
utility/messaging/type/error/MessageShowError.h
|
||||
|
||||
utility/messaging/type/focus/MessageFocusChanged.h
|
||||
utility/messaging/type/focus/MessageFocusedSearchView.h
|
||||
utility/messaging/type/focus/MessageFocusIn.h
|
||||
utility/messaging/type/focus/MessageFocusOut.h
|
||||
utility/messaging/type/focus/MessageFocusView.h
|
||||
|
||||
utility/messaging/type/graph/MessageActivateEdge.h
|
||||
utility/messaging/type/graph/MessageActivateNodes.h
|
||||
utility/messaging/type/graph/MessageActivateTrailEdge.h
|
||||
@@ -513,8 +519,6 @@ add_files(
|
||||
utility/messaging/type/MessageClearStatusView.h
|
||||
utility/messaging/type/MessageCloseProject.h
|
||||
utility/messaging/type/MessageFlushUpdates.h
|
||||
utility/messaging/type/MessageFocusIn.h
|
||||
utility/messaging/type/MessageFocusOut.h
|
||||
utility/messaging/type/MessageLoadProject.h
|
||||
utility/messaging/type/MessageLogFilterChanged.h
|
||||
utility/messaging/type/MessageProjectEdit.h
|
||||
@@ -531,6 +535,7 @@ add_files(
|
||||
utility/messaging/type/MessageSwitchColorScheme.h
|
||||
utility/messaging/type/MessageTooltipHide.h
|
||||
utility/messaging/type/MessageTooltipShow.h
|
||||
utility/messaging/type/MessageWindowChanged.h
|
||||
utility/messaging/type/MessageWindowClosed.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
@@ -41,7 +41,7 @@ void ComponentManager::setupMain(ViewLayout* viewLayout, Id appId)
|
||||
{
|
||||
std::shared_ptr<CompositeView> compositeView =
|
||||
m_componentFactory.getViewFactory()->createCompositeView(
|
||||
viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
|
||||
viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search", 0);
|
||||
m_singleViews.push_back(compositeView);
|
||||
|
||||
std::shared_ptr<UndoRedoView> undoRedoView =
|
||||
@@ -134,7 +134,7 @@ void ComponentManager::setupTab(ViewLayout* viewLayout, Id tabId, ScreenSearchSe
|
||||
{
|
||||
std::shared_ptr<CompositeView> compositeView =
|
||||
m_componentFactory.getViewFactory()->createCompositeView(
|
||||
viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
|
||||
viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search", tabId);
|
||||
m_singleViews.push_back(compositeView);
|
||||
|
||||
std::shared_ptr<Component> undoRedoComponent = m_componentFactory.createUndoRedoComponent(
|
||||
@@ -209,6 +209,29 @@ void ComponentManager::refreshViews()
|
||||
}
|
||||
}
|
||||
|
||||
View* ComponentManager::getView(const std::string& name) const
|
||||
{
|
||||
for (const std::shared_ptr<Component>& component: m_components)
|
||||
{
|
||||
View* view = component->getViewPtr();
|
||||
|
||||
if (view && view->getName() == name)
|
||||
{
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<View>& view: m_singleViews)
|
||||
{
|
||||
if (view->getName() == name)
|
||||
{
|
||||
return view.get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> ComponentManager::getDialogView(DialogView::UseCase useCase) const
|
||||
{
|
||||
auto it = m_dialogViews.find(useCase);
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
void clearComponents();
|
||||
void refreshViews();
|
||||
|
||||
View* getView(const std::string& name) const;
|
||||
std::shared_ptr<DialogView> getDialogView(DialogView::UseCase useCase) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "Tab.h"
|
||||
|
||||
#include "CodeView.h"
|
||||
#include "GraphView.h"
|
||||
|
||||
Tab::Tab(
|
||||
Id tabId,
|
||||
const ViewFactory* viewFactory,
|
||||
@@ -19,6 +22,11 @@ Tab::~Tab()
|
||||
m_componentManager.teardownTab(m_screenSearchSender);
|
||||
}
|
||||
|
||||
Id Tab::getSchedulerId() const
|
||||
{
|
||||
return m_tabId;
|
||||
}
|
||||
|
||||
void Tab::setParentLayout(ViewLayout* parentLayout)
|
||||
{
|
||||
m_parentLayout = parentLayout;
|
||||
@@ -72,6 +80,34 @@ void Tab::setViewEnabled(View* view, bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void Tab::handleMessage(MessageFocusView* message)
|
||||
{
|
||||
GraphView* graphView = dynamic_cast<GraphView*>(m_componentManager.getView(GraphView::VIEW_NAME));
|
||||
CodeView* codeView = dynamic_cast<CodeView*>(m_componentManager.getView(CodeView::VIEW_NAME));
|
||||
|
||||
if (!graphView || !codeView)
|
||||
{
|
||||
LOG_ERROR("Tab has no code or graph view.");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageFocusView::ViewType type = message->type;
|
||||
if (type == MessageFocusView::ViewType::TOGGLE)
|
||||
{
|
||||
if (graphView->hasNavigationFocus())
|
||||
{
|
||||
type = MessageFocusView::ViewType::CODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = MessageFocusView::ViewType::GRAPH;
|
||||
}
|
||||
}
|
||||
|
||||
graphView->setNavigationFocus(type == MessageFocusView::ViewType::GRAPH);
|
||||
codeView->setNavigationFocus(type == MessageFocusView::ViewType::CODE);
|
||||
}
|
||||
|
||||
void Tab::handleMessage(MessageRefreshUI* message)
|
||||
{
|
||||
m_componentManager.refreshViews();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "ComponentManager.h"
|
||||
#include "MessageFocusView.h"
|
||||
#include "MessageListener.h"
|
||||
#include "MessageRefreshUI.h"
|
||||
#include "View.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
class Tab
|
||||
: public ViewLayout
|
||||
, public MessageListener<MessageFocusView>
|
||||
, public MessageListener<MessageRefreshUI>
|
||||
{
|
||||
public:
|
||||
@@ -20,6 +22,8 @@ public:
|
||||
ScreenSearchSender* screenSearchSender);
|
||||
virtual ~Tab();
|
||||
|
||||
Id getSchedulerId() const override;
|
||||
|
||||
void setParentLayout(ViewLayout* parentLayout);
|
||||
|
||||
// ViewLayout implementation
|
||||
@@ -32,6 +36,7 @@ public:
|
||||
void setViewEnabled(View* view, bool enabled) override;
|
||||
|
||||
private:
|
||||
void handleMessage(MessageFocusView* message) override;
|
||||
void handleMessage(MessageRefreshUI* message) override;
|
||||
|
||||
const Id m_tabId;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "CodeController.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ApplicationSettings.h"
|
||||
#include "FileInfo.h"
|
||||
#include "MessageFocusView.h"
|
||||
#include "MessageMoveIDECursor.h"
|
||||
#include "MessageShowError.h"
|
||||
#include "MessageStatus.h"
|
||||
@@ -314,6 +316,8 @@ void CodeController::handleMessage(MessageCodeReference* message)
|
||||
{
|
||||
iterateReference(next);
|
||||
}
|
||||
|
||||
MessageFocusView(MessageFocusView::ViewType::CODE).dispatch();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageCodeShowDefinition* message)
|
||||
@@ -427,6 +431,14 @@ void CodeController::handleMessage(MessageErrorCountClear* message)
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageFocusChanged* message)
|
||||
{
|
||||
if (message->isReplayed() && message->isFromCode())
|
||||
{
|
||||
m_codeParams.locationIdToFocus = message->tokenOrLocationId;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageFlushUpdates* message)
|
||||
{
|
||||
showFiles(m_codeParams, m_scrollParams, true);
|
||||
@@ -434,12 +446,12 @@ void CodeController::handleMessage(MessageFlushUpdates* message)
|
||||
|
||||
void CodeController::handleMessage(MessageFocusIn* message)
|
||||
{
|
||||
getView()->focusTokenIds(message->tokenIds);
|
||||
getView()->coFocusTokenIds(message->tokenIds);
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageFocusOut* message)
|
||||
{
|
||||
getView()->defocusTokenIds();
|
||||
getView()->deCoFocusTokenIds();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageScrollToLine* message)
|
||||
@@ -522,6 +534,99 @@ void CodeController::handleMessage(MessageShowScope* message)
|
||||
showFiles(m_codeParams, CodeScrollParams(), !message->isReplayed());
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageToNextCodeReference* message)
|
||||
{
|
||||
FilePath currentFilePath = message->filePath;
|
||||
size_t currentLineNumber = message->lineNumber;
|
||||
bool next = message->next;
|
||||
bool inListMode = getView()->isInListMode();
|
||||
|
||||
if (currentFilePath.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::pair<int, int> referencePos = findClosestReferenceIndex(
|
||||
m_references, currentFilePath, currentLineNumber, next);
|
||||
std::pair<int, int> localReferencePos = findClosestReferenceIndex(
|
||||
m_localReferences, currentFilePath, currentLineNumber, next);
|
||||
|
||||
int referenceIndex = referencePos.first;
|
||||
int referenceFileIndex = referencePos.second;
|
||||
int localReferenceIndex = localReferencePos.first;
|
||||
int localReferenceFileIndex = localReferencePos.second;
|
||||
|
||||
if (referenceIndex >= 0 && localReferenceIndex >= 0)
|
||||
{
|
||||
if (referenceFileIndex == localReferenceFileIndex)
|
||||
{
|
||||
if (referenceFileIndex < 0)
|
||||
{
|
||||
if (m_references[referenceIndex].filePath !=
|
||||
m_localReferences[localReferenceIndex].filePath ||
|
||||
m_references[referenceIndex].lineNumber >
|
||||
m_localReferences[localReferenceIndex].lineNumber)
|
||||
{
|
||||
localReferenceIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
referenceIndex = -1;
|
||||
}
|
||||
}
|
||||
else if (referenceFileIndex == 0)
|
||||
{
|
||||
if (std::abs(
|
||||
static_cast<int>(m_references[referenceIndex].lineNumber) -
|
||||
static_cast<int>(currentLineNumber)) <
|
||||
std::abs(
|
||||
static_cast<int>(m_localReferences[localReferenceIndex].lineNumber) -
|
||||
static_cast<int>(currentLineNumber)))
|
||||
{
|
||||
localReferenceIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
referenceIndex = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_references[referenceIndex].filePath !=
|
||||
m_localReferences[localReferenceIndex].filePath ||
|
||||
m_references[referenceIndex].lineNumber <
|
||||
m_localReferences[localReferenceIndex].lineNumber)
|
||||
{
|
||||
localReferenceIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
referenceIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (referenceFileIndex == 0)
|
||||
{
|
||||
localReferenceIndex = -1;
|
||||
}
|
||||
else if (localReferenceFileIndex == 0)
|
||||
{
|
||||
referenceIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (localReferenceIndex >= 0)
|
||||
{
|
||||
m_localReferenceIndex = localReferenceIndex;
|
||||
showCurrentLocalReference(true);
|
||||
}
|
||||
else if (referenceIndex >= 0)
|
||||
{
|
||||
m_referenceIndex = referenceIndex;
|
||||
showCurrentReference();
|
||||
}
|
||||
}
|
||||
|
||||
CodeView* CodeController::getView() const
|
||||
{
|
||||
return Controller::getView<CodeView>();
|
||||
@@ -899,6 +1004,7 @@ void CodeController::createReferences()
|
||||
ref.tokenId = 0;
|
||||
ref.locationId = location->getLocationId();
|
||||
ref.locationType = location->getType();
|
||||
ref.lineNumber = location->getLineNumber();
|
||||
m_references.push_back(ref);
|
||||
return;
|
||||
}
|
||||
@@ -910,6 +1016,7 @@ void CodeController::createReferences()
|
||||
ref.tokenId = i;
|
||||
ref.locationId = location->getLocationId();
|
||||
ref.locationType = location->getType();
|
||||
ref.lineNumber = location->getLineNumber();
|
||||
|
||||
std::map<Id, Id>::const_iterator it = scopeLocationIds.find(i);
|
||||
if (it != scopeLocationIds.end())
|
||||
@@ -947,6 +1054,7 @@ void CodeController::createLocalReferences(const std::set<Id>& localSymbolIds)
|
||||
ref.filePath = location->getFilePath();
|
||||
ref.locationId = location->getLocationId();
|
||||
ref.locationType = location->getType();
|
||||
ref.lineNumber = location->getLineNumber();
|
||||
m_localReferences.push_back(ref);
|
||||
return;
|
||||
}
|
||||
@@ -999,8 +1107,7 @@ void CodeController::iterateReference(bool next)
|
||||
}
|
||||
}
|
||||
|
||||
const Reference& ref = m_references[m_referenceIndex - 1];
|
||||
MessageShowReference(m_referenceIndex, ref.tokenId, ref.locationId, true).dispatch();
|
||||
showCurrentReference();
|
||||
}
|
||||
|
||||
void CodeController::iterateLocalReference(bool next, bool updateView)
|
||||
@@ -1031,6 +1138,17 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
|
||||
}
|
||||
}
|
||||
|
||||
showCurrentLocalReference(updateView);
|
||||
}
|
||||
|
||||
void CodeController::showCurrentReference()
|
||||
{
|
||||
const Reference& ref = m_references[m_referenceIndex];
|
||||
MessageShowReference(m_referenceIndex, ref.tokenId, ref.locationId, true).dispatch();
|
||||
}
|
||||
|
||||
void CodeController::showCurrentLocalReference(bool updateView)
|
||||
{
|
||||
const Reference& ref = m_localReferences[m_localReferenceIndex];
|
||||
m_codeParams.currentActiveLocalLocationIds = {ref.locationId};
|
||||
|
||||
@@ -1049,6 +1167,57 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
|
||||
showFiles(m_codeParams, toReferenceScrollParams(ref), updateView);
|
||||
}
|
||||
|
||||
std::pair<int, int> CodeController::findClosestReferenceIndex(
|
||||
const std::vector<Reference>& references,
|
||||
const FilePath& currentFilePath,
|
||||
size_t currentLineNumber,
|
||||
bool next) const
|
||||
{
|
||||
int referenceIndex = -1;
|
||||
bool beforeCurrentFile = true;
|
||||
|
||||
for (size_t i = 0; i < references.size(); i++)
|
||||
{
|
||||
if (references[i].filePath == currentFilePath)
|
||||
{
|
||||
if (!next)
|
||||
{
|
||||
if (references[i].lineNumber < currentLineNumber)
|
||||
{
|
||||
referenceIndex = static_cast<int>(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {referenceIndex, beforeCurrentFile ? -1 : 0};
|
||||
}
|
||||
}
|
||||
else if (references[i].lineNumber > currentLineNumber)
|
||||
{
|
||||
return {static_cast<int>(i), 0};
|
||||
}
|
||||
|
||||
beforeCurrentFile = false;
|
||||
}
|
||||
else if (!next)
|
||||
{
|
||||
if (beforeCurrentFile)
|
||||
{
|
||||
referenceIndex = static_cast<int>(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {referenceIndex, 1};
|
||||
}
|
||||
}
|
||||
else if (next && !beforeCurrentFile)
|
||||
{
|
||||
return {static_cast<int>(i), 1};
|
||||
}
|
||||
}
|
||||
|
||||
return {referenceIndex, beforeCurrentFile ? -1 : 1};
|
||||
}
|
||||
|
||||
void CodeController::expandVisibleFiles(bool useSingleFileCache)
|
||||
{
|
||||
TRACE();
|
||||
@@ -1300,9 +1469,7 @@ CodeScrollParams CodeController::firstReferenceScrollParams() const
|
||||
const Reference& ref = m_references.front();
|
||||
|
||||
return CodeScrollParams::toReference(
|
||||
ref.filePath,
|
||||
ref.scopeLocationId ? ref.scopeLocationId : ref.locationId,
|
||||
CodeScrollParams::Target::TOP);
|
||||
ref.filePath, ref.locationId, ref.scopeLocationId, CodeScrollParams::Target::TOP);
|
||||
}
|
||||
|
||||
return CodeScrollParams();
|
||||
@@ -1318,7 +1485,7 @@ CodeScrollParams CodeController::definitionReferenceScrollParams(const std::vect
|
||||
if (ref.scopeLocationId && ref.tokenId == activeTokenId)
|
||||
{
|
||||
return CodeScrollParams::toReference(
|
||||
ref.filePath, ref.scopeLocationId, CodeScrollParams::Target::TOP);
|
||||
ref.filePath, ref.locationId, ref.scopeLocationId, CodeScrollParams::Target::TOP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1327,7 +1494,7 @@ CodeScrollParams CodeController::definitionReferenceScrollParams(const std::vect
|
||||
if (ref.tokenId == activeTokenId)
|
||||
{
|
||||
return CodeScrollParams::toReference(
|
||||
ref.filePath, ref.locationId, CodeScrollParams::Target::TOP);
|
||||
ref.filePath, ref.locationId, ref.scopeLocationId, CodeScrollParams::Target::TOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1338,9 +1505,7 @@ CodeScrollParams CodeController::definitionReferenceScrollParams(const std::vect
|
||||
CodeScrollParams CodeController::toReferenceScrollParams(const Reference& ref) const
|
||||
{
|
||||
return CodeScrollParams::toReference(
|
||||
ref.filePath,
|
||||
ref.scopeLocationId ? ref.scopeLocationId : ref.locationId,
|
||||
CodeScrollParams::Target::CENTER);
|
||||
ref.filePath, ref.locationId, ref.scopeLocationId, CodeScrollParams::Target::CENTER);
|
||||
}
|
||||
|
||||
void CodeController::saveOrRestoreViewMode(MessageBase* message)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "MessageCodeShowDefinition.h"
|
||||
#include "MessageDeactivateEdge.h"
|
||||
#include "MessageErrorCountClear.h"
|
||||
#include "MessageFocusChanged.h"
|
||||
#include "MessageFlushUpdates.h"
|
||||
#include "MessageFocusIn.h"
|
||||
#include "MessageFocusOut.h"
|
||||
@@ -28,6 +29,7 @@
|
||||
#include "MessageShowError.h"
|
||||
#include "MessageShowReference.h"
|
||||
#include "MessageShowScope.h"
|
||||
#include "MessageToNextCodeReference.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "CodeView.h"
|
||||
@@ -54,6 +56,7 @@ class CodeController
|
||||
, public MessageListener<MessageCodeShowDefinition>
|
||||
, public MessageListener<MessageDeactivateEdge>
|
||||
, public MessageListener<MessageErrorCountClear>
|
||||
, public MessageListener<MessageFocusChanged>
|
||||
, public MessageListener<MessageFlushUpdates>
|
||||
, public MessageListener<MessageFocusIn>
|
||||
, public MessageListener<MessageFocusOut>
|
||||
@@ -62,6 +65,7 @@ class CodeController
|
||||
, public MessageListener<MessageShowError>
|
||||
, public MessageListener<MessageShowReference>
|
||||
, public MessageListener<MessageShowScope>
|
||||
, public MessageListener<MessageToNextCodeReference>
|
||||
{
|
||||
public:
|
||||
CodeController(StorageAccess* storageAccess);
|
||||
@@ -77,6 +81,7 @@ private:
|
||||
Id locationId = 0;
|
||||
Id scopeLocationId = 0;
|
||||
LocationType locationType = LOCATION_TOKEN;
|
||||
size_t lineNumber = 0;
|
||||
};
|
||||
|
||||
void handleMessage(MessageActivateErrors* message) override;
|
||||
@@ -92,6 +97,7 @@ private:
|
||||
void handleMessage(MessageCodeShowDefinition* message) override;
|
||||
void handleMessage(MessageDeactivateEdge* message) override;
|
||||
void handleMessage(MessageErrorCountClear* message) override;
|
||||
void handleMessage(MessageFocusChanged* message) override;
|
||||
void handleMessage(MessageFlushUpdates* message) override;
|
||||
void handleMessage(MessageFocusIn* message) override;
|
||||
void handleMessage(MessageFocusOut* message) override;
|
||||
@@ -100,6 +106,7 @@ private:
|
||||
void handleMessage(MessageShowError* message) override;
|
||||
void handleMessage(MessageShowReference* message) override;
|
||||
void handleMessage(MessageShowScope* message) override;
|
||||
void handleMessage(MessageToNextCodeReference* message) override;
|
||||
|
||||
CodeView* getView() const;
|
||||
|
||||
@@ -133,6 +140,15 @@ private:
|
||||
void iterateReference(bool next);
|
||||
void iterateLocalReference(bool next, bool updateView);
|
||||
|
||||
void showCurrentReference();
|
||||
void showCurrentLocalReference(bool updateView);
|
||||
|
||||
std::pair<int, int> findClosestReferenceIndex(
|
||||
const std::vector<Reference>& references,
|
||||
const FilePath& currentFilePath,
|
||||
size_t currentLineNumber,
|
||||
bool next) const;
|
||||
|
||||
void expandVisibleFiles(bool useSingleFileCache);
|
||||
CodeFileParams* addSourceLocations(std::shared_ptr<SourceLocationFile> locationFile);
|
||||
void setFileState(
|
||||
|
||||
@@ -326,6 +326,14 @@ void GraphController::handleMessage(MessageDeactivateEdge* message)
|
||||
getView()->activateEdge(0);
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageFocusChanged* message)
|
||||
{
|
||||
if (message->isReplayed() && message->isFromGraph())
|
||||
{
|
||||
m_tokenIdToFocus = message->tokenOrLocationId;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageFlushUpdates* message)
|
||||
{
|
||||
GraphView::GraphParams params;
|
||||
@@ -344,12 +352,12 @@ void GraphController::handleMessage(MessageScrollGraph* message)
|
||||
|
||||
void GraphController::handleMessage(MessageFocusIn* message)
|
||||
{
|
||||
getView()->focusTokenIds(message->tokenIds);
|
||||
getView()->coFocusTokenIds(message->tokenIds);
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageFocusOut* message)
|
||||
{
|
||||
getView()->defocusTokenIds(message->tokenIds);
|
||||
getView()->deCoFocusTokenIds(message->tokenIds);
|
||||
}
|
||||
|
||||
void GraphController::handleMessage(MessageGraphNodeBundleSplit* message)
|
||||
@@ -635,6 +643,7 @@ void GraphController::clear()
|
||||
|
||||
m_useBezierEdges = false;
|
||||
m_showsLegend = false;
|
||||
m_tokenIdToFocus = 0;
|
||||
|
||||
getView()->clear();
|
||||
}
|
||||
@@ -2353,8 +2362,11 @@ void GraphController::buildGraph(MessageBase* message, GraphView::GraphParams pa
|
||||
params.isIndexedList = params.scrollToTop;
|
||||
params.bezierEdges = m_useBezierEdges;
|
||||
params.disableInteraction = m_showsLegend;
|
||||
params.tokenIdToFocus = m_tokenIdToFocus;
|
||||
|
||||
getView()->rebuildGraph(m_graph, m_dummyNodes, m_dummyEdges, params);
|
||||
|
||||
m_tokenIdToFocus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "MessageActivateTrail.h"
|
||||
#include "MessageActivateTrailEdge.h"
|
||||
#include "MessageDeactivateEdge.h"
|
||||
#include "MessageFocusChanged.h"
|
||||
#include "MessageFlushUpdates.h"
|
||||
#include "MessageFocusIn.h"
|
||||
#include "MessageFocusOut.h"
|
||||
@@ -42,6 +43,7 @@ class GraphController
|
||||
, public MessageListener<MessageActivateTrail>
|
||||
, public MessageListener<MessageActivateTrailEdge>
|
||||
, public MessageListener<MessageDeactivateEdge>
|
||||
, public MessageListener<MessageFocusChanged>
|
||||
, public MessageListener<MessageFlushUpdates>
|
||||
, public MessageListener<MessageFocusIn>
|
||||
, public MessageListener<MessageFocusOut>
|
||||
@@ -67,6 +69,7 @@ private:
|
||||
void handleMessage(MessageActivateTrail* message) override;
|
||||
void handleMessage(MessageActivateTrailEdge* message) override;
|
||||
void handleMessage(MessageDeactivateEdge* message) override;
|
||||
void handleMessage(MessageFocusChanged* message) override;
|
||||
void handleMessage(MessageFlushUpdates* message) override;
|
||||
void handleMessage(MessageFocusIn* message) override;
|
||||
void handleMessage(MessageFocusOut* message) override;
|
||||
@@ -170,6 +173,7 @@ private:
|
||||
|
||||
bool m_useBezierEdges = false;
|
||||
bool m_showsLegend = false;
|
||||
Id m_tokenIdToFocus = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPH_CONTROLLER_H
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "MessageIndexingFinished.h"
|
||||
#include "MessageScrollToLine.h"
|
||||
#include "MessageSearch.h"
|
||||
#include "MessageWindowChanged.h"
|
||||
#include "ScreenSearchInterfaces.h"
|
||||
#include "TabId.h"
|
||||
#include "TaskLambda.h"
|
||||
@@ -52,6 +53,8 @@ void TabsController::addTab(Id tabId, SearchMatch match)
|
||||
m_tabs.emplace(
|
||||
tabId, std::make_shared<Tab>(tabId, m_viewFactory, m_storageAccess, m_screenSearchSender));
|
||||
|
||||
MessageWindowChanged().dispatch();
|
||||
|
||||
if (match.isValid())
|
||||
{
|
||||
MessageSearch msg({match}, NodeTypeSet::all());
|
||||
|
||||
@@ -42,7 +42,7 @@ void TooltipController::handleMessage(MessageActivateLocalSymbols* message)
|
||||
|
||||
void TooltipController::handleMessage(MessageFocusIn* message)
|
||||
{
|
||||
if (!message->tokenIds.size())
|
||||
if (!message->tokenIds.size() || message->origin == TOOLTIP_ORIGIN_NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,6 +183,19 @@ void UndoRedoController::handleMessage(MessageDeactivateEdge* message)
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageFocusChanged* message)
|
||||
{
|
||||
if (sameMessageTypeAsLast(message) &&
|
||||
static_cast<MessageFocusChanged*>(lastMessage())->tokenOrLocationId ==
|
||||
message->tokenOrLocationId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Command command(std::make_shared<MessageFocusChanged>(*message), Command::ORDER_VIEW, true);
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void UndoRedoController::handleMessage(MessageGraphNodeBundleSplit* message)
|
||||
{
|
||||
Command command(std::make_shared<MessageGraphNodeBundleSplit>(*message), Command::ORDER_ADAPT);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "MessageChangeFileView.h"
|
||||
#include "MessageCodeShowDefinition.h"
|
||||
#include "MessageDeactivateEdge.h"
|
||||
#include "MessageFocusChanged.h"
|
||||
#include "MessageGraphNodeBundleSplit.h"
|
||||
#include "MessageGraphNodeExpand.h"
|
||||
#include "MessageGraphNodeHide.h"
|
||||
@@ -49,6 +50,7 @@ class UndoRedoController
|
||||
, public MessageListener<MessageChangeFileView>
|
||||
, public MessageListener<MessageCodeShowDefinition>
|
||||
, public MessageListener<MessageDeactivateEdge>
|
||||
, public MessageListener<MessageFocusChanged>
|
||||
, public MessageListener<MessageGraphNodeBundleSplit>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeHide>
|
||||
@@ -102,6 +104,7 @@ private:
|
||||
void handleMessage(MessageChangeFileView* message) override;
|
||||
void handleMessage(MessageCodeShowDefinition* message) override;
|
||||
void handleMessage(MessageDeactivateEdge* message) override;
|
||||
void handleMessage(MessageFocusChanged* message) override;
|
||||
void handleMessage(MessageGraphNodeBundleSplit* message) override;
|
||||
void handleMessage(MessageGraphNodeExpand* message) override;
|
||||
void handleMessage(MessageGraphNodeHide* message) override;
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
{
|
||||
bool clearSnippets = false;
|
||||
bool useSingleFileCache = true;
|
||||
Id locationIdToFocus = 0;
|
||||
|
||||
size_t referenceCount = 0;
|
||||
size_t referenceIndex = 0;
|
||||
@@ -68,14 +69,17 @@ public:
|
||||
|
||||
virtual bool showsErrors() const = 0;
|
||||
|
||||
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds) = 0;
|
||||
virtual void defocusTokenIds() = 0;
|
||||
virtual void coFocusTokenIds(const std::vector<Id>& coFocusedTokenIds) = 0;
|
||||
virtual void deCoFocusTokenIds() = 0;
|
||||
|
||||
virtual bool isInListMode() const = 0;
|
||||
virtual void setMode(bool listMode) = 0;
|
||||
|
||||
virtual bool hasSingleFileCached(const FilePath& filePath) const = 0;
|
||||
|
||||
virtual void setNavigationFocus(bool focus) = 0;
|
||||
virtual bool hasNavigationFocus() const = 0;
|
||||
|
||||
protected:
|
||||
CodeController* getController();
|
||||
};
|
||||
|
||||
@@ -2,13 +2,18 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name)
|
||||
: View(viewLayout), m_direction(direction), m_name(name)
|
||||
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId)
|
||||
: View(viewLayout), m_direction(direction), m_name(name), m_tabId(tabId)
|
||||
{
|
||||
}
|
||||
|
||||
CompositeView::~CompositeView() {}
|
||||
|
||||
Id CompositeView::getSchedulerId() const
|
||||
{
|
||||
return m_tabId;
|
||||
}
|
||||
|
||||
CompositeView::CompositeDirection CompositeView::getDirection() const
|
||||
{
|
||||
return m_direction;
|
||||
@@ -50,3 +55,8 @@ void CompositeView::setViewEnabled(View* view, bool enabled)
|
||||
{
|
||||
getViewLayout()->setViewEnabled(view, enabled);
|
||||
}
|
||||
|
||||
void CompositeView::handleMessage(MessageFocusedSearchView* message)
|
||||
{
|
||||
showFocusIndicator(message->focusIn);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "MessageFocusedSearchView.h"
|
||||
#include "MessageListener.h"
|
||||
#include "View.h"
|
||||
#include "ViewLayout.h"
|
||||
|
||||
class CompositeView
|
||||
: public View
|
||||
, public ViewLayout
|
||||
, public MessageListener<MessageFocusedSearchView>
|
||||
{
|
||||
public:
|
||||
enum CompositeDirection
|
||||
@@ -17,30 +20,37 @@ public:
|
||||
DIRECTION_VERTICAL
|
||||
};
|
||||
|
||||
CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name);
|
||||
CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name, Id tabId);
|
||||
virtual ~CompositeView();
|
||||
|
||||
Id getSchedulerId() const override;
|
||||
|
||||
CompositeDirection getDirection() const;
|
||||
const std::vector<View*>& getViews() const;
|
||||
|
||||
virtual void addViewWidget(View* view) = 0;
|
||||
|
||||
virtual void showFocusIndicator(bool focus) = 0;
|
||||
|
||||
// View implementation
|
||||
virtual std::string getName() const;
|
||||
virtual std::string getName() const override;
|
||||
|
||||
// ViewLayout implementation
|
||||
virtual void addView(View* view);
|
||||
virtual void removeView(View* view);
|
||||
void addView(View* view) override;
|
||||
void removeView(View* view) override;
|
||||
|
||||
virtual void showView(View* view);
|
||||
virtual void hideView(View* view);
|
||||
void showView(View* view) override;
|
||||
void hideView(View* view) override;
|
||||
|
||||
virtual void setViewEnabled(View* view, bool enabled);
|
||||
void setViewEnabled(View* view, bool enabled) override;
|
||||
|
||||
private:
|
||||
void handleMessage(MessageFocusedSearchView* message) override;
|
||||
|
||||
std::vector<View*> m_views;
|
||||
CompositeDirection m_direction;
|
||||
std::string m_name;
|
||||
const std::string m_name;
|
||||
const Id m_tabId;
|
||||
};
|
||||
|
||||
#endif // COMPOSITE_VIEW_H
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
bool isIndexedList = false;
|
||||
bool bezierEdges = false;
|
||||
bool disableInteraction = false;
|
||||
Id tokenIdToFocus = 0;
|
||||
};
|
||||
|
||||
GraphView(ViewLayout* viewLayout);
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
const GraphParams params) = 0;
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void focusTokenIds(const std::vector<Id>& focusedTokenIds) = 0;
|
||||
virtual void defocusTokenIds(const std::vector<Id>& defocusedTokenIds) = 0;
|
||||
virtual void coFocusTokenIds(const std::vector<Id>& focusedTokenIds) = 0;
|
||||
virtual void deCoFocusTokenIds(const std::vector<Id>& defocusedTokenIds) = 0;
|
||||
|
||||
virtual void resizeView() = 0;
|
||||
|
||||
@@ -54,6 +55,9 @@ public:
|
||||
virtual void scrollToValues(int xValue, int yValue) = 0;
|
||||
|
||||
virtual void activateEdge(Id edgeId) = 0;
|
||||
|
||||
virtual void setNavigationFocus(bool focus) = 0;
|
||||
virtual bool hasNavigationFocus() const = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPH_VIEW_H
|
||||
|
||||
@@ -19,6 +19,7 @@ int GraphViewStyle::s_fontSize;
|
||||
std::string GraphViewStyle::s_fontName;
|
||||
float GraphViewStyle::s_zoomFactor;
|
||||
|
||||
std::string GraphViewStyle::s_focusColor;
|
||||
std::map<std::string, GraphViewStyle::NodeColor> GraphViewStyle::s_nodeColors;
|
||||
std::map<std::string, std::string> GraphViewStyle::s_edgeColors;
|
||||
std::map<bool, GraphViewStyle::NodeColor> GraphViewStyle::s_screenMatchColors;
|
||||
@@ -141,6 +142,7 @@ void GraphViewStyle::loadStyleSettings()
|
||||
s_charWidths.clear();
|
||||
s_charHeights.clear();
|
||||
|
||||
s_focusColor.clear();
|
||||
s_nodeColors.clear();
|
||||
s_edgeColors.clear();
|
||||
s_screenMatchColors.clear();
|
||||
@@ -369,7 +371,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren, bool hasQualifier)
|
||||
NodeType type, bool defined, bool isActive, bool isFocused, bool isCoFocused, bool hasChildren, bool hasQualifier)
|
||||
{
|
||||
return getStyleForNodeType(
|
||||
type.getNodeStyle(),
|
||||
@@ -378,6 +380,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
defined,
|
||||
isActive,
|
||||
isFocused,
|
||||
isCoFocused,
|
||||
hasChildren,
|
||||
hasQualifier);
|
||||
}
|
||||
@@ -389,17 +392,18 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
bool defined,
|
||||
bool isActive,
|
||||
bool isFocused,
|
||||
bool isCoFocused,
|
||||
bool hasChildren,
|
||||
bool hasQualifier)
|
||||
{
|
||||
NodeStyle style;
|
||||
|
||||
style.color = getNodeColor(underscoredTypeString, isActive || isFocused);
|
||||
style.color = getNodeColor(underscoredTypeString, isActive || isCoFocused);
|
||||
|
||||
style.fontName = getFontNameForDataNode();
|
||||
style.fontSize = getFontSizeForStyleType(type);
|
||||
|
||||
if (isActive || isFocused)
|
||||
if (isActive || isCoFocused)
|
||||
{
|
||||
style.fontBold = true;
|
||||
}
|
||||
@@ -485,6 +489,12 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
}
|
||||
}
|
||||
|
||||
if (isFocused)
|
||||
{
|
||||
style.color.border = getFocusColor();
|
||||
style.borderWidth = 3;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
@@ -541,6 +551,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
|
||||
true,
|
||||
false,
|
||||
isFocused,
|
||||
isFocused,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
@@ -570,7 +581,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfTextNode(int fontSizeDiff)
|
||||
return style;
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfGroupNode(GroupType type, bool isFocused)
|
||||
GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfGroupNode(GroupType type, bool isCoFocused)
|
||||
{
|
||||
NodeStyle style;
|
||||
|
||||
@@ -594,7 +605,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfGroupNode(GroupType type, bo
|
||||
{
|
||||
colorType += "inheritance";
|
||||
|
||||
if (isFocused)
|
||||
if (isCoFocused)
|
||||
{
|
||||
style.borderWidth = 3;
|
||||
}
|
||||
@@ -604,7 +615,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfGroupNode(GroupType type, bo
|
||||
return style;
|
||||
}
|
||||
|
||||
style.color = getNodeColor(colorType, isFocused);
|
||||
style.color = getNodeColor(colorType, isCoFocused);
|
||||
|
||||
style.fontName = getFontNameOfGroupNode();
|
||||
style.fontSize = getFontSizeOfGroupNode();
|
||||
@@ -621,12 +632,14 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
{
|
||||
EdgeStyle style;
|
||||
|
||||
style.width = isActive ? 4.0f : 2.0f;
|
||||
style.zValue = isActive ? 5 : 2;
|
||||
bool active = isActive || isFocused;
|
||||
|
||||
style.width = active ? 4.0f : 2.0f;
|
||||
style.zValue = active ? 5 : 2;
|
||||
|
||||
if (isTrailEdge)
|
||||
{
|
||||
style.zValue = isActive ? 5 : 2;
|
||||
style.zValue = active ? 5 : 2;
|
||||
}
|
||||
|
||||
style.arrowLength = 5;
|
||||
@@ -641,8 +654,14 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
style.originOffset.y = 5;
|
||||
style.targetOffset.y = -5;
|
||||
|
||||
style.color = getEdgeColor(
|
||||
utility::encodeToUtf8(Edge::getUnderscoredTypeString(type)), isActive || isFocused);
|
||||
if (isFocused)
|
||||
{
|
||||
style.color = getFocusColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
style.color = getEdgeColor(utility::encodeToUtf8(Edge::getUnderscoredTypeString(type)));
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -655,7 +674,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
style.originOffset.y = 0;
|
||||
style.targetOffset.y = 0;
|
||||
style.verticalOffset = 0;
|
||||
style.zValue = isActive ? 1 : -5;
|
||||
style.zValue = active ? 1 : -5;
|
||||
break;
|
||||
|
||||
case Edge::EDGE_CALL:
|
||||
@@ -666,10 +685,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
if (isTrailEdge && isActive)
|
||||
{
|
||||
style.width = 3;
|
||||
style.color = ColorScheme::getInstance()->getColor(
|
||||
"graph/edge/" + utility::encodeToUtf8(Edge::getUnderscoredTypeString(type)) +
|
||||
"/trail_focus",
|
||||
style.color);
|
||||
style.color = ColorScheme::getInstance()->getColor("graph/edge/call_trail_focus", style.color);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -690,17 +706,17 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
style.targetOffset.y = -10;
|
||||
style.verticalOffset = 0;
|
||||
style.cornerRadius = 7;
|
||||
style.zValue = isActive ? 2 : -3;
|
||||
style.width = isActive ? 3.0f : 2.0f;
|
||||
style.zValue = active ? 2 : -3;
|
||||
style.width = active ? 3.0f : 2.0f;
|
||||
|
||||
if (isTrailEdge)
|
||||
{
|
||||
style.zValue = isActive ? 2 : -20;
|
||||
style.zValue = active ? 2 : -20;
|
||||
}
|
||||
break;
|
||||
|
||||
case Edge::EDGE_TEMPLATE_SPECIALIZATION:
|
||||
style.zValue = isActive ? 2 : -3;
|
||||
style.zValue = active ? 2 : -3;
|
||||
style.arrowLength = 10;
|
||||
style.arrowWidth = 13;
|
||||
style.arrowClosed = true;
|
||||
@@ -708,7 +724,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
break;
|
||||
|
||||
case Edge::EDGE_INCLUDE:
|
||||
style.zValue = isActive ? 2 : -3;
|
||||
style.zValue = active ? 2 : -3;
|
||||
case Edge::EDGE_MACRO_USAGE:
|
||||
style.originOffset.y = 0;
|
||||
style.targetOffset.y = 0;
|
||||
@@ -755,9 +771,19 @@ float GraphViewStyle::getZoomFactor()
|
||||
return s_zoomFactor;
|
||||
}
|
||||
|
||||
const GraphViewStyle::NodeColor& GraphViewStyle::getNodeColor(const std::string& typeStr, bool focus)
|
||||
const std::string& GraphViewStyle::getFocusColor()
|
||||
{
|
||||
std::string type = focus ? typeStr + "focus" : typeStr;
|
||||
if (s_focusColor.empty())
|
||||
{
|
||||
s_focusColor = ColorScheme::getInstance()->getColor("window/focus");
|
||||
}
|
||||
|
||||
return s_focusColor;
|
||||
}
|
||||
|
||||
const GraphViewStyle::NodeColor& GraphViewStyle::getNodeColor(const std::string& typeStr, bool highlight)
|
||||
{
|
||||
std::string type = highlight ? typeStr + "highlight" : typeStr;
|
||||
std::map<std::string, NodeColor>::const_iterator it = s_nodeColors.find(type);
|
||||
|
||||
if (it != s_nodeColors.end())
|
||||
@@ -767,33 +793,27 @@ const GraphViewStyle::NodeColor& GraphViewStyle::getNodeColor(const std::string&
|
||||
|
||||
NodeColor color;
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
ColorScheme::ColorState state = focus ? ColorScheme::FOCUS : ColorScheme::NORMAL;
|
||||
|
||||
color.fill = scheme->getNodeTypeColor(typeStr, "fill", state);
|
||||
color.border = scheme->getNodeTypeColor(typeStr, "border", state);
|
||||
color.text = scheme->getNodeTypeColor(typeStr, "text", state);
|
||||
color.icon = scheme->getNodeTypeColor(typeStr, "icon", state);
|
||||
color.hatching = scheme->getNodeTypeColor(typeStr, "hatching", state);
|
||||
color.fill = scheme->getNodeTypeColor(typeStr, "fill", highlight);
|
||||
color.border = scheme->getNodeTypeColor(typeStr, "border", highlight);
|
||||
color.text = scheme->getNodeTypeColor(typeStr, "text", highlight);
|
||||
color.icon = scheme->getNodeTypeColor(typeStr, "icon", highlight);
|
||||
color.hatching = scheme->getNodeTypeColor(typeStr, "hatching", highlight);
|
||||
|
||||
s_nodeColors.emplace(type, color);
|
||||
|
||||
return s_nodeColors.find(type)->second;
|
||||
}
|
||||
|
||||
const std::string& GraphViewStyle::getEdgeColor(const std::string& typeStr, bool focus)
|
||||
const std::string& GraphViewStyle::getEdgeColor(const std::string& type)
|
||||
{
|
||||
std::string type = focus ? typeStr + "focus" : typeStr;
|
||||
std::map<std::string, std::string>::const_iterator it = s_edgeColors.find(type);
|
||||
|
||||
if (it != s_edgeColors.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
ColorScheme::ColorState state = focus ? ColorScheme::FOCUS : ColorScheme::NORMAL;
|
||||
std::string color = scheme->getEdgeTypeColor(typeStr, state);
|
||||
|
||||
std::string color = ColorScheme::getInstance()->getEdgeTypeColor(type);
|
||||
s_edgeColors.emplace(type, color);
|
||||
|
||||
return s_edgeColors.find(type)->second;
|
||||
|
||||
@@ -121,14 +121,20 @@ public:
|
||||
static NodeMargins getMarginsOfGroupNode(GroupType type, bool hasName);
|
||||
|
||||
static NodeStyle getStyleForNodeType(
|
||||
NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren, bool hasQualifier);
|
||||
NodeType type,
|
||||
bool defined,
|
||||
bool isActive,
|
||||
bool isFocused,
|
||||
bool isCoFocused,
|
||||
bool hasChildren,
|
||||
bool hasQualifier);
|
||||
static NodeStyle getStyleOfAccessNode();
|
||||
static NodeStyle getStyleOfExpandToggleNode();
|
||||
static NodeStyle getStyleOfCountCircle();
|
||||
static NodeStyle getStyleOfBundleNode(bool isFocused);
|
||||
static NodeStyle getStyleOfQualifier();
|
||||
static NodeStyle getStyleOfTextNode(int fontSizeDiff);
|
||||
static NodeStyle getStyleOfGroupNode(GroupType type, bool isFocused);
|
||||
static NodeStyle getStyleOfGroupNode(GroupType type, bool isCoFocused);
|
||||
|
||||
static EdgeStyle getStyleForEdgeType(
|
||||
Edge::EdgeType type, bool isActive, bool isFocused, bool isTrailEdge, bool isAmbiguous);
|
||||
@@ -139,8 +145,9 @@ public:
|
||||
|
||||
static float getZoomFactor();
|
||||
|
||||
static const NodeColor& getNodeColor(const std::string& typeStr, bool focus);
|
||||
static const std::string& getEdgeColor(const std::string& typeStr, bool focus);
|
||||
static const std::string& getFocusColor();
|
||||
static const NodeColor& getNodeColor(const std::string& typeStr, bool highlight);
|
||||
static const std::string& getEdgeColor(const std::string& type);
|
||||
static const NodeColor& getScreenMatchColor(bool focus);
|
||||
|
||||
static int s_gridCellSize;
|
||||
@@ -154,6 +161,7 @@ private:
|
||||
bool defined,
|
||||
bool isActive,
|
||||
bool isFocused,
|
||||
bool isCoFocused,
|
||||
bool hasChildren,
|
||||
bool hasQualifier);
|
||||
|
||||
@@ -172,6 +180,7 @@ private:
|
||||
static std::string s_fontName;
|
||||
static float s_zoomFactor;
|
||||
|
||||
static std::string s_focusColor;
|
||||
static std::map<std::string, NodeColor> s_nodeColors;
|
||||
static std::map<std::string, std::string> s_edgeColors;
|
||||
static std::map<bool, NodeColor> s_screenMatchColors;
|
||||
|
||||
@@ -35,7 +35,8 @@ public:
|
||||
virtual std::shared_ptr<CompositeView> createCompositeView(
|
||||
ViewLayout* viewLayout,
|
||||
CompositeView::CompositeDirection direction,
|
||||
const std::string& name) const = 0;
|
||||
const std::string& name,
|
||||
const Id tabId) const = 0;
|
||||
virtual std::shared_ptr<TabbedView> createTabbedView(
|
||||
ViewLayout* viewLayout, const std::string& name) const = 0;
|
||||
|
||||
|
||||
@@ -22,57 +22,63 @@ struct CodeScrollParams
|
||||
TOP
|
||||
};
|
||||
|
||||
static CodeScrollParams toReference(const FilePath& filePath, Id locationId, Target target)
|
||||
static CodeScrollParams toReference(const FilePath& filePath, Id locationId, Id scopeLocationId, Target target)
|
||||
{
|
||||
return CodeScrollParams(Type::TO_REFERENCE, target, filePath, locationId, 0, 0, false);
|
||||
return CodeScrollParams(Type::TO_REFERENCE, target, filePath, locationId, scopeLocationId, 0, 0, false);
|
||||
}
|
||||
|
||||
static CodeScrollParams toFile(const FilePath& filePath, Target target)
|
||||
{
|
||||
return CodeScrollParams(Type::TO_LINE, target, filePath, 0, 0, 0, false);
|
||||
return CodeScrollParams(Type::TO_LINE, target, filePath, 0, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
static CodeScrollParams toLine(const FilePath& filePath, size_t line, Target target)
|
||||
{
|
||||
return CodeScrollParams(Type::TO_LINE, target, filePath, 0, line, 0, false);
|
||||
return CodeScrollParams(Type::TO_LINE, target, filePath, 0, 0, line, 0, false);
|
||||
}
|
||||
|
||||
static CodeScrollParams toValue(size_t value, bool inListMode)
|
||||
{
|
||||
return CodeScrollParams(Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, value, inListMode);
|
||||
return CodeScrollParams(Type::TO_VALUE, Target::VISIBLE, FilePath(), 0, 0, 0, value, inListMode);
|
||||
}
|
||||
|
||||
CodeScrollParams(
|
||||
Type type, Target target, FilePath filePath, Id locationId, size_t line, size_t value, bool inListMode)
|
||||
Type type,
|
||||
Target target,
|
||||
FilePath filePath,
|
||||
Id locationId,
|
||||
Id scopeLocationId,
|
||||
size_t line,
|
||||
size_t value,
|
||||
bool inListMode
|
||||
)
|
||||
: type(type)
|
||||
, target(target)
|
||||
, filePath(filePath)
|
||||
, locationId(locationId)
|
||||
, scopeLocationId(scopeLocationId)
|
||||
, line(line)
|
||||
, value(value)
|
||||
, inListMode(inListMode)
|
||||
{
|
||||
}
|
||||
|
||||
CodeScrollParams()
|
||||
: type(Type::NONE), target(Target::VISIBLE), locationId(0), line(0), value(0), inListMode(false)
|
||||
{
|
||||
}
|
||||
CodeScrollParams() {}
|
||||
|
||||
|
||||
Type type;
|
||||
Target target;
|
||||
Type type = Type::NONE;
|
||||
Target target = Target::VISIBLE;
|
||||
|
||||
FilePath filePath;
|
||||
|
||||
// Reference
|
||||
Id locationId;
|
||||
Id locationId = 0;
|
||||
Id scopeLocationId = 0;
|
||||
|
||||
// Line
|
||||
size_t line;
|
||||
size_t line = 0;
|
||||
|
||||
// Value
|
||||
size_t value;
|
||||
size_t value = 0;
|
||||
bool inListMode = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -2220,7 +2220,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(
|
||||
{
|
||||
info.offset = Vec2i(20, 30);
|
||||
}
|
||||
else
|
||||
else if (origin == TOOLTIP_ORIGIN_GRAPH)
|
||||
{
|
||||
info.offset = Vec2i(50, 20);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
enum TooltipOrigin
|
||||
{
|
||||
TOOLTIP_ORIGIN_NONE,
|
||||
TOOLTIP_ORIGIN_GRAPH,
|
||||
TOOLTIP_ORIGIN_CODE
|
||||
};
|
||||
|
||||
@@ -31,69 +31,57 @@ std::string ColorScheme::getColor(const std::string& key, const std::string& def
|
||||
return getValue<std::string>(key, defaultColor);
|
||||
}
|
||||
|
||||
std::string ColorScheme::getNodeTypeColor(NodeType type, const std::string& key, ColorState state) const
|
||||
std::string ColorScheme::getNodeTypeColor(NodeType type, const std::string& key, bool highlight) const
|
||||
{
|
||||
return getNodeTypeColor(type.getUnderscoredTypeString(), key, state);
|
||||
return getNodeTypeColor(type.getUnderscoredTypeString(), key, highlight);
|
||||
}
|
||||
|
||||
std::string ColorScheme::getNodeTypeColor(
|
||||
const std::string& typeStr, const std::string& key, ColorState state) const
|
||||
const std::string& typeStr, const std::string& key, bool highlight) const
|
||||
{
|
||||
disableWarnings();
|
||||
|
||||
const std::string type = getValue<std::string>("graph/node/" + typeStr + "/like", typeStr);
|
||||
std::string color = getValue<std::string>(
|
||||
"graph/node/" + type + "/" + key + "/" + stateToString(state), "");
|
||||
"graph/node/" + type + "/" + key + "/" + (highlight ? "highlight" : "normal"), "");
|
||||
|
||||
if (!color.size() && state != NORMAL)
|
||||
if (!color.size() && highlight)
|
||||
{
|
||||
color = getValue<std::string>(
|
||||
"graph/node/" + type + "/" + key + "/" + stateToString(NORMAL), "");
|
||||
color = getValue<std::string>("graph/node/" + type + "/" + key + "/normal", "");
|
||||
}
|
||||
|
||||
if (!color.size())
|
||||
{
|
||||
color = getValue<std::string>("graph/node/default/" + key + "/" + stateToString(state), "");
|
||||
color = getValue<std::string>(
|
||||
"graph/node/default/" + key + "/" + (highlight ? "highlight" : "normal"), "");
|
||||
}
|
||||
|
||||
enableWarnings();
|
||||
|
||||
if (!color.size() && state != NORMAL)
|
||||
if (!color.size() && highlight)
|
||||
{
|
||||
color = getValue<std::string>(
|
||||
"graph/node/default/" + key + "/" + stateToString(NORMAL), "#FFFFFF");
|
||||
color = getValue<std::string>("graph/node/default/" + key + "/normal", "#FF1493");
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type, ColorState state) const
|
||||
std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type) const
|
||||
{
|
||||
return getEdgeTypeColor(utility::encodeToUtf8(Edge::getUnderscoredTypeString(type)), state);
|
||||
return getEdgeTypeColor(utility::encodeToUtf8(Edge::getUnderscoredTypeString(type)));
|
||||
}
|
||||
|
||||
std::string ColorScheme::getEdgeTypeColor(const std::string& typeStr, ColorState state) const
|
||||
std::string ColorScheme::getEdgeTypeColor(const std::string& type) const
|
||||
{
|
||||
disableWarnings();
|
||||
|
||||
std::string type = getValue<std::string>("graph/edge/" + typeStr + "/like", typeStr);
|
||||
std::string color = getValue<std::string>("graph/edge/" + type + "/" + stateToString(state), "");
|
||||
|
||||
if (!color.size() && state != NORMAL)
|
||||
{
|
||||
color = getValue<std::string>("graph/edge/" + type + "/" + stateToString(NORMAL), "");
|
||||
}
|
||||
|
||||
if (!color.size())
|
||||
{
|
||||
color = getValue<std::string>("graph/edge/default/" + stateToString(state), "");
|
||||
}
|
||||
std::string color = getValue<std::string>("graph/edge/" + type, "");
|
||||
|
||||
enableWarnings();
|
||||
|
||||
if (!color.size() && state != NORMAL)
|
||||
if (!color.size())
|
||||
{
|
||||
color = getValue<std::string>("graph/edge/default/" + stateToString(NORMAL), "#FFFFFF");
|
||||
color = getValue<std::string>("graph/edge/default", "#FF1493");
|
||||
}
|
||||
|
||||
return color;
|
||||
@@ -103,12 +91,12 @@ std::string ColorScheme::getSearchTypeColor(
|
||||
const std::string& searchTypeName, const std::string& key, const std::string& state) const
|
||||
{
|
||||
std::string path = "search/query/" + searchTypeName + "/" + state + "/" + key;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
return getValue<std::string>(path, "#FF1493");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getSyntaxColor(const std::string& key) const
|
||||
{
|
||||
return getValue<std::string>("code/snippet/syntax/" + key, "#FFFFFF");
|
||||
return getValue<std::string>("code/snippet/syntax/" + key, "#FF1493");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getCodeAnnotationTypeColor(
|
||||
|
||||
@@ -23,12 +23,11 @@ public:
|
||||
std::string getColor(const std::string& key) const;
|
||||
std::string getColor(const std::string& key, const std::string& defaultColor) const;
|
||||
|
||||
std::string getNodeTypeColor(NodeType type, const std::string& key, ColorState state) const;
|
||||
std::string getNodeTypeColor(
|
||||
const std::string& typeStr, const std::string& key, ColorState state) const;
|
||||
std::string getNodeTypeColor(NodeType type, const std::string& key, bool highlight) const;
|
||||
std::string getNodeTypeColor(const std::string& typeStr, const std::string& key, bool highlight) const;
|
||||
|
||||
std::string getEdgeTypeColor(Edge::EdgeType type, ColorState state) const;
|
||||
std::string getEdgeTypeColor(const std::string& typeStr, ColorState state) const;
|
||||
std::string getEdgeTypeColor(Edge::EdgeType type) const;
|
||||
std::string getEdgeTypeColor(const std::string& type) const;
|
||||
|
||||
std::string getSearchTypeColor(
|
||||
const std::string& searchTypeName,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef MESSAGE_WINDOW_CHANGED_H
|
||||
#define MESSAGE_WINDOW_CHANGED_H
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
class MessageWindowChanged: public Message<MessageWindowChanged>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageWindowChanged";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_WINDOW_CHANGED_H
|
||||
@@ -8,11 +8,6 @@
|
||||
class MessageActivateLocalSymbols: public Message<MessageActivateLocalSymbols>
|
||||
{
|
||||
public:
|
||||
MessageActivateLocalSymbols()
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
MessageActivateLocalSymbols(const std::vector<Id>& symbolIds): symbolIds(symbolIds)
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef MESSAGE_TO_NEXT_CODE_REFERENCE_H
|
||||
#define MESSAGE_TO_NEXT_CODE_REFERENCE_H
|
||||
|
||||
#include "Message.h"
|
||||
#include "TabId.h"
|
||||
|
||||
class MessageToNextCodeReference: public Message<MessageToNextCodeReference>
|
||||
{
|
||||
public:
|
||||
MessageToNextCodeReference(const FilePath& filePath, size_t lineNumber, bool next)
|
||||
: filePath(filePath), lineNumber(lineNumber), next(next)
|
||||
{
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageToNextCodeReference";
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
os << filePath.wstr() << L' ' << lineNumber << L' ';
|
||||
|
||||
if (next)
|
||||
{
|
||||
os << L"next";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << L"previous";
|
||||
}
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
const size_t lineNumber;
|
||||
const bool next;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TO_NEXT_CODE_REFERENCE_H
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef MESSAGE_FOCUS_CHANGED_H
|
||||
#define MESSAGE_FOCUS_CHANGED_H
|
||||
|
||||
#include "Message.h"
|
||||
#include "TabId.h"
|
||||
|
||||
class MessageFocusChanged: public Message<MessageFocusChanged>
|
||||
{
|
||||
public:
|
||||
enum class ViewType
|
||||
{
|
||||
GRAPH,
|
||||
CODE
|
||||
};
|
||||
|
||||
MessageFocusChanged(ViewType type, Id tokenOrLocationId)
|
||||
: type(type)
|
||||
, tokenOrLocationId(tokenOrLocationId)
|
||||
{
|
||||
setIsLogged(false);
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageFocusChanged";
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ViewType::GRAPH:
|
||||
os << "graph";
|
||||
break;
|
||||
case ViewType::CODE:
|
||||
os << "code";
|
||||
break;
|
||||
}
|
||||
|
||||
os << " " << tokenOrLocationId;
|
||||
}
|
||||
|
||||
bool isFromGraph() const
|
||||
{
|
||||
return type == ViewType::GRAPH;
|
||||
}
|
||||
|
||||
bool isFromCode() const
|
||||
{
|
||||
return type == ViewType::CODE;
|
||||
}
|
||||
|
||||
const ViewType type;
|
||||
const Id tokenOrLocationId;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FOCUS_CHANGED_H
|
||||
+2
-3
@@ -5,14 +5,13 @@
|
||||
|
||||
#include "Message.h"
|
||||
#include "TabId.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "TooltipOrigin.h"
|
||||
#include "types.h"
|
||||
|
||||
class MessageFocusIn: public Message<MessageFocusIn>
|
||||
{
|
||||
public:
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds, TooltipOrigin origin)
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds, TooltipOrigin origin = TOOLTIP_ORIGIN_NONE)
|
||||
: tokenIds(tokenIds), origin(origin)
|
||||
{
|
||||
setIsLogged(false);
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef MESSAGE_FOCUS_VIEW_H
|
||||
#define MESSAGE_FOCUS_VIEW_H
|
||||
|
||||
#include "Message.h"
|
||||
#include "TabId.h"
|
||||
|
||||
class MessageFocusView: public Message<MessageFocusView>
|
||||
{
|
||||
public:
|
||||
enum class ViewType
|
||||
{
|
||||
GRAPH,
|
||||
CODE,
|
||||
TOGGLE
|
||||
};
|
||||
|
||||
MessageFocusView(ViewType type): type(type)
|
||||
{
|
||||
setIsLogged(false);
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageFocusView";
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ViewType::GRAPH:
|
||||
os << "graph";
|
||||
break;
|
||||
case ViewType::CODE:
|
||||
os << "code";
|
||||
break;
|
||||
case ViewType::TOGGLE:
|
||||
os << "toggle";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const ViewType type;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FOCUS_VIEW_H
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef MESSAGE_FOCUSED_SEARCH_VIEW_H
|
||||
#define MESSAGE_FOCUSED_SEARCH_VIEW_H
|
||||
|
||||
#include "Message.h"
|
||||
#include "TabId.h"
|
||||
|
||||
class MessageFocusedSearchView: public Message<MessageFocusedSearchView>
|
||||
{
|
||||
public:
|
||||
MessageFocusedSearchView(bool focusIn)
|
||||
: focusIn(focusIn)
|
||||
{
|
||||
setIsLogged(false);
|
||||
setSchedulerId(TabId::currentTab());
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageFocusedSearchView";
|
||||
}
|
||||
|
||||
const bool focusIn;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FOCUSED_SEARCH_VIEW_H
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <cstdarg>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
@@ -49,6 +50,9 @@ std::vector<T> toVector(const std::deque<T>& d);
|
||||
template <typename T>
|
||||
std::vector<T> toVector(const std::set<T>& d);
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> toVector(const std::list<T>& d);
|
||||
|
||||
template <typename T>
|
||||
std::set<T> toSet(const std::vector<T>& d);
|
||||
|
||||
@@ -242,6 +246,15 @@ std::vector<T> utility::toVector(const std::set<T>& d)
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> utility::toVector(const std::list<T>& d)
|
||||
{
|
||||
std::vector<T> v;
|
||||
v.reserve(d.size());
|
||||
v.insert(v.begin(), d.begin(), d.end());
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::set<T> utility::toSet(const std::vector<T>& v)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user