Folding: Toggling folds by clicking the indicator
This commit is contained in:
parent
2176954aee
commit
818fcd51f4
3 changed files with 31 additions and 0 deletions
|
@ -459,6 +459,17 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
AssDialogue *dlg = GetVisDialogue(row);
|
AssDialogue *dlg = GetVisDialogue(row);
|
||||||
if (!dlg) row = 0;
|
if (!dlg) row = 0;
|
||||||
|
|
||||||
|
// Find the column the mouse is over
|
||||||
|
int colx = event.GetX();
|
||||||
|
int col;
|
||||||
|
for (col = 0; col < columns.size(); col++) {
|
||||||
|
int w = columns[col]->Width();
|
||||||
|
if (colx < w) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
colx -= w;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.ButtonDown() && OPT_GET("Subtitle/Grid/Focus Allow")->GetBool())
|
if (event.ButtonDown() && OPT_GET("Subtitle/Grid/Focus Allow")->GetBool())
|
||||||
SetFocus();
|
SetFocus();
|
||||||
|
|
||||||
|
@ -488,6 +499,10 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (columns[col]->OnMouseEvent(dlg, context, event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((click || holding || dclick) && dlg) {
|
if ((click || holding || dclick) && dlg) {
|
||||||
int old_extend = extendRow;
|
int old_extend = extendRow;
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,18 @@ struct GridColumnFolds final : GridColumn {
|
||||||
return " " + value;
|
return " " + value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OnMouseEvent(AssDialogue *d, agi::Context *c, wxMouseEvent &event) const override {
|
||||||
|
if ((event.LeftDown() || event.LeftDClick()) && !event.ShiftDown() && !event.CmdDown() && !event.AltDown()) {
|
||||||
|
if (d->Fold.hasFold() && !d->Fold.isEnd()) {
|
||||||
|
std::vector<AssDialogue *> lines;
|
||||||
|
lines.push_back(d);
|
||||||
|
c->foldController->ToggleFoldsAt(lines);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
||||||
int maxdepth = c->foldController->GetMaxDepth();
|
int maxdepth = c->foldController->GetMaxDepth();
|
||||||
if (maxdepth == 0) {
|
if (maxdepth == 0) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// Aegisub Project http://www.aegisub.org/
|
// Aegisub Project http://www.aegisub.org/
|
||||||
|
|
||||||
#include "flyweight_hash.h"
|
#include "flyweight_hash.h"
|
||||||
|
#include "wx/event.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -68,6 +69,9 @@ public:
|
||||||
virtual wxString const& Description() const = 0;
|
virtual wxString const& Description() const = 0;
|
||||||
virtual void Paint(wxDC &dc, int x, int y, const AssDialogue *d, const agi::Context *c) const;
|
virtual void Paint(wxDC &dc, int x, int y, const AssDialogue *d, const agi::Context *c) const;
|
||||||
|
|
||||||
|
// Returns true if the default action should be skipped
|
||||||
|
virtual bool OnMouseEvent(AssDialogue *d, agi::Context *c, wxMouseEvent &event) const { return false; }
|
||||||
|
|
||||||
int Width() const { return width; }
|
int Width() const { return width; }
|
||||||
bool Visible() const { return visible; }
|
bool Visible() const { return visible; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue