Commit 1a3e523a authored by Loic Guegan's avatar Loic Guegan
Browse files

Add double click = unfold all the variation

parent 448399d1
Pipeline #219610150 passed with stage
in 9 minutes and 4 seconds
......@@ -18,7 +18,6 @@ float clamp(float d, float min, float max) {
}
void PGNEditor::Render() {
this->MoveCount = 1;
this->LineCount = 1;
this->CurrentX = Config.leftMargin + Config.hintBarWidth;
this->CurrentY = Config.topMargin;
InCanvasSize.w = CanvasSize.w - Config.scrollbarThickness;
......@@ -39,6 +38,7 @@ void PGNEditor::Render() {
this->DrawScrollBars();
IsMouseClicked = false;
IsMouseDoubleClicked=false;
IsMouseDragging=false;
}
......@@ -89,7 +89,7 @@ bool PGNEditor::MouseHover(Shape shape){
return((x <= Mouse.x) && (y <= Mouse.y) && (maxX >= Mouse.x) && (maxY >= Mouse.y));
}
void PGNEditor::SetConfiguration(EditorConfig config){
void PGNEditor::SetEditorConfig(EditorConfig config){
this->Config=config;
}
......@@ -221,9 +221,12 @@ void PGNEditor::DrawVariations(Move *line) {
DrawCall(sep);
CurrentY += Config.VarSepH;
if(IsMouseClicked){
if(IsMouseClicked||IsMouseDoubleClicked){
if(MouseHover(sep)){
line->fold=!line->fold;
if(IsMouseDoubleClicked)
UnfoldLine(line);
else
line->fold=!line->fold;
}
}
if(line->fold){
......@@ -261,6 +264,16 @@ void PGNEditor::DrawCount() {
DrawCall(count);
}
void PGNEditor::UnfoldLine(Move* line){
if(line==nullptr)
return;
for(auto variation: line->variations){
UnfoldLine(variation);
}
line->fold=false;
UnfoldLine(line->next);
}
void PGNEditor::DrawCall(Shape shape) {
shape.x += Offset.x;
shape.y += Offset.y;
......
......@@ -24,7 +24,6 @@ private:
Size InCanvasSize;
int MoveCount;
int LineCount;
Point Current;
int CurrentX;
int CurrentY;
......@@ -47,8 +46,10 @@ private:
void DrawCount();
void DrawMove(std::string move);
bool MouseHover(Shape shape);
void UnfoldLine(Move*line);
protected:
bool IsMouseClicked;
bool IsMouseDoubleClicked;
bool IsMouseDragging;
Size CanvasSize;
Point Mouse;
......@@ -59,13 +60,18 @@ protected:
void Render();
void ScrollV(int percent);
void ScrollH(int percent);
void SetConfiguration(EditorConfig config);
void SetEditorConfig(EditorConfig config);
public:
PGNEditor():PGNEditor(EditorConfig()){}
PGNEditor(EditorConfig config):LastMouseClickOnHS(false),LastMouseClickOnVS(false),CurrentVSY(0),CurrentHSX(0){
PGNEditor(EditorConfig config){
this->Config=config;
IsMouseClicked=IsMouseDoubleClicked=IsMouseDragging=false;
WhiteToPlay=true;
CurrentHSX=CurrentVSY=MaxX=MinX=MaxY=MinY=CurrentX=CurrentY=0;
LastMouseClickOnHS=LastMouseClickOnVS=false;
MoveLine=nullptr;
MoveCount=1;
}
};
......
......@@ -37,6 +37,8 @@ void Editor::MouseEvent(wxMouseEvent &event) {
if(event.LeftDown()){
IsMouseClicked=true;
}
if(event.LeftDClick())
IsMouseDoubleClicked=true;
else if(event.GetWheelRotation()!=0){
if(event.GetWheelRotation()>0)
ScrollV(-10);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment