Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netrunner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sharinigma
netrunner
Commits
3562de1b
Commit
3562de1b
authored
7 years ago
by
Odilitime
Browse files
Options
Downloads
Patches
Plain Diff
transformMatrix scroll, onWheel scroll fixes, setDOM reset scrool position
parent
dcbec2a9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/graphics/components/DocumentComponent.cpp
+46
-3
46 additions, 3 deletions
src/graphics/components/DocumentComponent.cpp
src/graphics/components/DocumentComponent.h
+9
-0
9 additions, 0 deletions
src/graphics/components/DocumentComponent.h
with
55 additions
and
3 deletions
src/graphics/components/DocumentComponent.cpp
+
46
−
3
View file @
3562de1b
...
...
@@ -24,6 +24,7 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
std
::
cout
<<
"DocumentComponent::DocumentComponent - height was less than zero"
<<
std
::
endl
;
height
=
0
;
}
//std::cout << "DocumentComponent::DocumentComponent - our size" << static_cast<int>(width) << "x" << static_cast<int>(height) << std::endl;
onMousemove
=
[
this
](
int
passedX
,
int
passedY
)
{
// set hover component
...
...
@@ -36,7 +37,8 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
lx
=
passedX
;
ly
=
passedY
;
//std::cout << "DocumentComponent::DocumentComponent:onMousemove - size " << this->windowWidth << "," << this->windowHeight << std::endl;
this
->
hoverComponent
=
this
->
searchComponentTree
(
this
->
rootComponent
,
passedX
,
passedY
);
//std::cout << "DocumentComponent::DocumentComponent:onMousemove - at " << passedX << "," << passedY << " scroll: " << (int)(((this->transformMatrix[13] / 2) - 1) * this->windowHeight) << std::endl;
this
->
hoverComponent
=
this
->
searchComponentTree
(
this
->
rootComponent
,
passedX
,
passedY
+
(((
this
->
transformMatrix
[
13
]
/
2
)
-
1
)
*
this
->
windowHeight
));
if
(
this
->
hoverComponent
)
{
//std::cout << "DocumentComponent::DocumentComponent:onMousemove - hovering over " << typeOfComponent(this->hoverComponent) << " component" << std::endl;
if
(
this
->
hoverComponent
->
onMousemove
)
{
...
...
@@ -55,7 +57,7 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
onWheel
=
[
this
](
int
passedX
,
int
passedY
)
{
//std::cout << "DocumentComponent::DocumentComponent:::onWheel - scroll yDelta: " << y << std::endl;
//Component::printComponentTree(rootComponent, 0);
double
pY
=
passedY
/
10
;
double
pY
=
passedY
/
10
.0
;
this
->
scrollY
-=
pY
;
if
(
this
->
scrollY
<
0
)
{
this
->
scrollY
=
0
;
...
...
@@ -67,6 +69,22 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
//std::cout << "root.y: " << static_cast<int>(rootComponent->y) << std::endl;
//std::cout << "windowSize: " << windowWidth << "," << windowHeight << std::endl;
// new system
//std::cout << "DocumentComponent::DocumentComponent:::onWheel - old position: " << this->transformMatrix[13] << " adjustment:" << (-pY*0.1) << std::endl;
this
->
transformMatrix
[
13
]
+=
-
pY
*
0.01
;
// 2.0 is one screen height
// we draw from 0 downwards (y+), so can't scroll past our starting draw point
if
(
this
->
transformMatrix
[
13
]
<
2
)
{
this
->
transformMatrix
[
13
]
=
2
;
}
// calculate scroll max by calculating how many screens are in the rootComponent's Height
if
(
this
->
transformMatrix
[
13
]
>
std
::
max
(
(
this
->
rootComponent
->
height
-
this
->
rootComponent
->
y
)
/
this
->
windowHeight
*
2.0
f
,
2.0
f
))
{
this
->
transformMatrix
[
13
]
=
std
::
max
(
(
this
->
rootComponent
->
height
-
this
->
rootComponent
->
y
)
/
this
->
windowHeight
*
2.0
f
,
2.0
f
);
}
this
->
transformMatrixDirty
=
true
;
/*
// adjust root position
rootComponent->y = this->y + this->scrollY;
//std::cout << "now root.y: " << static_cast<int>(rootComponent->y) << std::endl;
...
...
@@ -84,6 +102,7 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
// should we mark win->renderDirty = true?
const std::clock_t end = clock();
std::cout << "Scrolled document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
*/
//rootComponent->y = this->y - this->scrollY;
//std::cout << "after root.y: " << static_cast<int>(rootComponent->y) << std::endl;
...
...
@@ -212,7 +231,10 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) {
if
(
domRootNode
)
{
deleteNode
(
domRootNode
);
}
// reset scroll position ?
// reset scroll position
transformMatrix
[
13
]
=
2
;
transformMatrixDirty
=
true
;
// new root component
rootComponent
=
std
::
make_shared
<
Component
>
();
...
...
@@ -236,7 +258,28 @@ void DocumentComponent::render() {
domDirty
=
false
;
//std::cout << "root Height: " << static_cast<int>(rootComponent->height) << " window Height: " << windowHeight << " y " << static_cast<int>(this->y) << std::endl;
scrollHeight
=
std
::
max
(
0
,
static_cast
<
int
>
(
rootComponent
->
height
-
(
windowHeight
+
(
this
->
y
*
2
))));
// recalculate scroll max by calculating how many screens are in the rootComponent's Height
if
(
transformMatrix
[
13
]
>
std
::
max
((
rootComponent
->
height
)
/
(
windowHeight
)
*
2.0
f
,
2.0
f
))
{
transformMatrix
[
13
]
=
std
::
max
((
rootComponent
->
height
)
/
(
windowHeight
)
*
2.0
f
,
2.0
f
);
transformMatrixDirty
=
true
;
}
}
// we have to do this each time
// because window resets it
//if (transformMatrixDirty) {
//const std::clock_t begin = clock();
GLint
transformLocation
=
glGetUniformLocation
(
win
->
fontProgram
,
"transform"
);
glUniformMatrix4fv
(
transformLocation
,
1
,
GL_FALSE
,
transformMatrix
);
//const std::clock_t end = clock();
//std::cout << "Updated font matrix in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
GLint
transformLocation2
=
glGetUniformLocation
(
win
->
textureProgram
,
"transform"
);
glUniformMatrix4fv
(
transformLocation2
,
1
,
GL_FALSE
,
transformMatrix
);
transformMatrixDirty
=
false
;
//}
//std::cout << "DocumentComponent::render - renderDirty" << std::endl;
glUseProgram
(
win
->
textureProgram
);
renderBoxComponents
(
rootComponent
);
...
...
This diff is collapsed.
Click to expand it.
src/graphics/components/DocumentComponent.h
+
9
−
0
View file @
3562de1b
...
...
@@ -11,6 +11,7 @@
#include
"MultiComponent.h"
// document is scrollable until multicomponent
class
DocumentComponent
:
public
MultiComponent
{
public:
DocumentComponent
(
const
float
rawX
,
const
float
rawY
,
const
float
rawWidth
,
const
float
rawHeight
,
const
int
passedWindowWidth
,
const
int
passedWindowHeight
);
...
...
@@ -25,6 +26,14 @@ public:
bool
domDirty
=
false
;
int
scrollY
=
0
;
int
scrollHeight
=
0
;
float
transformMatrix
[
16
]
=
{
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
};
bool
transformMatrixDirty
=
true
;
};
//bool setWindowContent(URL const& url);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment