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
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
Odilitime
netrunner
Commits
6963de42
Commit
6963de42
authored
7 years ago
by
Odilitime
Browse files
Options
Downloads
Patches
Plain Diff
only change x/y if boundToPage, useBoxShader support
parent
60b3f6ba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/graphics/components/Component.cpp
+39
-7
39 additions, 7 deletions
src/graphics/components/Component.cpp
with
39 additions
and
7 deletions
src/graphics/components/Component.cpp
+
39
−
7
View file @
6963de42
...
...
@@ -7,16 +7,16 @@
Component
::~
Component
()
{
}
// resize is where width/height can change within the confines of the window
void
Component
::
resize
(
const
int
passedWindowWidth
,
const
int
passedWindowHeight
)
{
//std::cout << "Component::resize" << std::endl;
//std::cout << "Component::resize
- doing nothing
" << std::endl;
windowWidth
=
passedWindowWidth
;
windowHeight
=
passedWindowHeight
;
/*
if (boundToPage) {
} else {
*/
*/
// no vertices in component
/*
float vx = x;
...
...
@@ -38,6 +38,18 @@ void Component::resize(const int passedWindowWidth, const int passedWindowHeight
verticesDirty = true;
*/
//}
// do we recurse down through children?
// well if a parent resizes, yea we should tell our children the window size has changed
// btw a layout already does this
// yea let's let layout handle this
/*
for (std::shared_ptr<Component> child : children) {
// update it's size
// maybe we should called wrap
child->resize(windowWidth, windowHeight);
}
*/
}
void
Component
::
setParent
(
std
::
shared_ptr
<
Component
>
passedParent
)
{
...
...
@@ -51,9 +63,20 @@ void Component::setParent(std::shared_ptr<Component> passedParent) {
parent
=
passedParent
;
// update our position
x
=
passedParent
->
x
;
y
=
passedParent
->
y
-
passedParent
->
height
;
// probably could move this out of here
if
(
boundToPage
)
{
x
=
passedParent
->
x
;
y
=
passedParent
->
y
-
passedParent
->
height
;
}
//std::cout << "Component::setParent - placing at " << static_cast<int>(x) << "," << static_cast<int>(y) << std::endl;
if
(
passedParent
)
{
if
(
passedParent
->
children
.
size
())
{
this
->
previous
=
passedParent
->
children
.
back
();
}
// need to figure out how to make this work
//passedParent->children.push_back(std::make_shared<Component>(this));
}
// add new component as child to parent
//std::shared_ptr<Component> child=*new std::shared_ptr<Component>(this);
...
...
@@ -63,6 +86,7 @@ void Component::setParent(std::shared_ptr<Component> passedParent) {
// window size is required because we need to know if our x is placed outside bounds
// our size is not required
// but all previous children sizes and positions are
// this function should be smart enough to read state, figure out what changes are actually needed and execute them
void
Component
::
layout
()
{
// back up current position
//int lx = x;
...
...
@@ -82,7 +106,7 @@ void Component::layout() {
*/
// if we're a child, get our parents position
if
(
parent
)
{
if
(
parent
&&
boundToPage
)
{
//std::cout << "Component::layout - copying position from parent: " << (int)parent->x << "x" << (int)parent->y << std::endl;
x
=
parent
->
x
;
...
...
@@ -91,6 +115,7 @@ void Component::layout() {
if
(
parent
->
children
.
size
())
{
//std::cout << "Component::layout - parent children: " << parent->children.size() << std::endl;
if
(
previous
)
{
//std::cout << "Component::layout - has previous " << std::endl;
/*
TextComponent *prevTextComponent = dynamic_cast<TextComponent*>(previous.get());
if (prevTextComponent) {
...
...
@@ -153,6 +178,13 @@ void Component::layout() {
// if parent x or y changes or windowWindow changes, all children need to be adjust
//std::cout << "Component::layout - I have " << children.size() << " children affected by my moved" << std::endl;
for
(
std
::
shared_ptr
<
Component
>
child
:
children
)
{
// maybe it should be like this:
// hey new w/h
// update wras
// where do we update layout?
// So no, because this is a relayout, we don't know sf w/h has changes
// most component resize()s already update the w/h
// update new sizes
child
->
windowWidth
=
windowWidth
;
child
->
windowHeight
=
windowHeight
;
...
...
@@ -322,7 +354,7 @@ bool Component::setTexture(GLuint textureNum, GLsizei w, GLsizei h, const unsign
// converts 0-1 to screen
// but centered
void
Component
::
pointToViewport
(
float
&
rawX
,
float
&
rawY
)
const
{
if
(
boundToPage
)
{
if
(
useBoxShader
)
{
//std::cout << "Component::pointToViewport - notBoundToPage converting from " << static_cast<int>(rawX) << "," << static_cast<int>(rawY) << std::endl;
//std::cout << "BoundToPage using " << screenWidth << "x" << screenHeight << std::endl;
rawX
=
((
rawX
/
windowWidth
)
*
2
)
-
1
;
...
...
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