Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Loic Guegan
ochess
Commits
c823df22
Commit
c823df22
authored
Nov 21, 2020
by
Loic Guegan
Browse files
Debug scroll
parent
ebb5abf8
Pipeline
#219400274
passed with stage
in 8 minutes and 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
24 deletions
+41
-24
src/editor/PGNEditor.cpp
src/editor/PGNEditor.cpp
+37
-23
src/editor/PGNEditor.hpp
src/editor/PGNEditor.hpp
+2
-1
src/editor/State.hpp
src/editor/State.hpp
+2
-0
No files found.
src/editor/PGNEditor.cpp
View file @
c823df22
...
...
@@ -37,9 +37,9 @@ void PGNEditor::Render(State *state) {
}
void
PGNEditor
::
DrawHintBar
()
{
Shape
hintBar
(
0
,
-
state
->
offset
Y
,
state
->
hintBarWidth
,
canvasH
);
Shape
hintBar
(
state
->
offset
X
,
0
,
state
->
hintBarWidth
,
canvasH
);
hintBar
.
target
=
Shape
::
HINTBAR
;
Draw
Call
(
hintBar
);
Draw
(
hintBar
);
// Do not issues a DrawCall here (MaxY will change);
}
void
PGNEditor
::
DrawScrollBars
()
{
...
...
@@ -63,31 +63,45 @@ void PGNEditor::DrawScrollBars() {
Shape
HS
(
-
state
->
offsetX
,
canvasH
,
HSSize
,
state
->
scrollbarThickness
);
HS
.
target
=
Shape
::
SCROLLBAR_H
;
Shape
VS
(
canvasW
,
-
state
->
offsetY
,
state
->
scrollbarThickness
,
VSSize
);
VS
.
target
=
Shape
::
SCROLLBAR_V
;
if
(
state
->
IsDragging
){
if
(
LastMouseClickOnHS
){
state
->
offsetX
-
=
(
state
->
mouseX
-
LastMouseClickX
);
CurrentHSX
+
=
(
state
->
mouseX
-
LastMouseClickX
);
LastMouseClickX
=
state
->
mouseX
;
state
->
offsetX
=-
std
::
min
(
std
::
max
(
0
,
-
state
->
offsetX
),
state
->
canvasW
);
if
(
std
::
abs
(
state
->
offsetX
)
>=
(
canvasW
-
HSSize
))
state
->
offsetX
=-
(
canvasW
-
HSSize
);
else
if
(
state
->
offsetX
>=
0
)
state
->
offsetX
=
0
;
if
(
CurrentHSX
<=
0
)
CurrentHSX
=
0
;
else
if
(
CurrentHSX
>=
(
canvasW
-
HSSize
))
CurrentHSX
=
(
canvasW
-
HSSize
);
double
percent
=
0
;
if
((
canvasW
-
HSSize
)
>
0
)
percent
=
CurrentHSX
/
(
canvasW
-
HSSize
);
int
maxOffset
=
(
MaxX
-
MinX
)
-
canvasW
;
state
->
offsetX
=-
(
double
)
maxOffset
*
percent
;
}
if
(
LastMouseClickOnVS
){
state
->
offsetY
-
=
(
state
->
mouseY
-
LastMouseClickY
);
CurrentVSY
+
=
(
state
->
mouseY
-
LastMouseClickY
);
LastMouseClickY
=
state
->
mouseY
;
if
(
std
::
abs
(
state
->
offsetY
)
>=
(
canvasH
-
VSSize
))
state
->
offsetY
=-
(
canvasH
-
VSSize
);
else
if
(
state
->
offsetY
>=
0
)
state
->
offsetY
=
0
;
if
(
CurrentVSY
<=
0
)
CurrentVSY
=
0
;
else
if
(
CurrentVSY
>=
(
canvasH
-
VSSize
))
CurrentVSY
=
(
canvasH
-
VSSize
);
double
percent
=
0
;
if
((
canvasH
-
VSSize
)
>
0
)
percent
=
CurrentVSY
/
(
canvasH
-
VSSize
);
int
maxOffset
=
std
::
max
((
MaxY
-
MinY
)
-
canvasH
,
0
);
state
->
offsetY
=-
(
double
)
maxOffset
*
percent
;
}
}
//std::cout << "MaxY:" << MaxY << " MinY " << MinY << " Diff:"<< MaxY-MinY << std::endl << std::flush;
Shape
HS
(
CurrentHSX
,
canvasH
,
HSSize
,
state
->
scrollbarThickness
);
HS
.
target
=
Shape
::
SCROLLBAR_H
;
Shape
VS
(
canvasW
,
CurrentVSY
,
state
->
scrollbarThickness
,
VSSize
);
VS
.
target
=
Shape
::
SCROLLBAR_V
;
// Check mouse over
if
(
HS
.
x
<=
state
->
mouseX
&&
HS
.
y
<=
state
->
mouseY
...
...
@@ -207,10 +221,10 @@ void PGNEditor::DrawCall(Shape shape) {
int
maxX
=
shape
.
x
+
width
;
int
maxY
=
shape
.
y
+
height
;
if
(
maxX
>
MaxX
)
MaxX
=
maxX
;
if
(
maxY
>
MaxY
)
MaxY
=
maxY
;
if
(
(
maxX
+
state
->
extraCanvasMargin
)
>
MaxX
)
MaxX
=
(
maxX
+
state
->
extraCanvasMargin
)
;
if
(
(
maxY
+
state
->
extraCanvasMargin
)
>
MaxY
)
MaxY
=
(
maxY
+
state
->
extraCanvasMargin
)
;
if
(
shape
.
x
<
MinX
)
MinX
=
shape
.
x
;
if
(
shape
.
y
<
MinY
)
...
...
src/editor/PGNEditor.hpp
View file @
c823df22
...
...
@@ -30,6 +30,7 @@ private:
bool
LastMouseClickOnHS
;
bool
LastMouseClickOnVS
;
int
CurrentVSY
;
int
CurrentHSX
;
/// @brief Used by scrollbars
int
MaxX
,
MinX
;
...
...
@@ -46,7 +47,7 @@ protected:
void
Render
(
State
*
state
);
virtual
void
Draw
(
Shape
shape
)
=
0
;
public:
PGNEditor
()
:
LastMouseClickOnHS
(
false
),
LastMouseClickOnVS
(
false
){
PGNEditor
()
:
LastMouseClickOnHS
(
false
),
LastMouseClickOnVS
(
false
)
,
CurrentVSY
(
0
),
CurrentHSX
(
0
)
{
}
};
...
...
src/editor/State.hpp
View file @
c823df22
...
...
@@ -35,6 +35,7 @@ public:
/// @brief Size of the move counter column
int
counterW
;
int
varationSepW
;
int
extraCanvasMargin
;
State
(){
moveline
=
nullptr
;
...
...
@@ -57,6 +58,7 @@ public:
varationSepW
=
5
;
MouseClick
=
false
;
IsDragging
=
false
;
extraCanvasMargin
=
50
;
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment