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:
Eberhard Gräther
2020-03-02 14:48:03 +01:00
committed by GitHub
parent f4b37f9763
commit b0616778f3
98 changed files with 4204 additions and 863 deletions
@@ -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
@@ -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
+13
View File
@@ -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)
{