Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GCompris
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
27
Issues
27
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
GCompris
Commits
21e5673d
Commit
21e5673d
authored
Mar 17, 2020
by
Timothée Giet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
colors, T188 optimize layout and calculate item size dynamically
parent
fe275ad2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
11 deletions
+31
-11
src/activities/colors/FindIt.qml
src/activities/colors/FindIt.qml
+31
-11
No files found.
src/activities/colors/FindIt.qml
View file @
21e5673d
...
@@ -90,29 +90,49 @@ ActivityBase {
...
@@ -90,29 +90,49 @@ ActivityBase {
id
:
containerModel
id
:
containerModel
}
}
function
fitItems
(
x_
,
y_
,
n_
)
{
var
sx
var
sy
var
px
=
Math
.
ceil
(
Math
.
sqrt
(
n_
*
x_
/
y_
));
if
(
Math
.
floor
(
px
*
y_
/
x_
)
*
px
<
n_
)
{
sx
=
y
/
Math
.
ceil
(
px
*
y_
/
x_
);
}
else
{
sx
=
x_
/
px
;
}
var
py
=
Math
.
ceil
(
Math
.
sqrt
(
n_
*
y_
/
x_
));
if
(
Math
.
floor
(
py
*
x_
/
y_
)
*
py
<
n_
)
{
sy
=
x_
/
Math
.
ceil
(
x_
*
py
/
y_
);
}
else
{
sy
=
y_
/
py
;
}
return
Math
.
max
(
sx
,
sy
);
}
GridView
{
GridView
{
id
:
container
id
:
container
model
:
containerModel
model
:
containerModel
x
:
background
.
width
*
0.2
anchors.top
:
questionItem
.
bottom
y
:
background
.
height
*
0.2
anchors.topMargin
:
score
.
height
*
0.2
width
:
background
.
width
*
0.7
anchors.bottom
:
score
.
top
height
:
background
.
height
*
0.6
anchors.horizontalCenter
:
background
.
horizontalCenter
width
:
background
.
width
-
score
.
width
*
2
interactive
:
false
interactive
:
false
cellWidth
:
item
Height
+
10
cellWidth
:
item
Width
cellHeight
:
itemWidth
+
10
cellHeight
:
itemWidth
keyNavigationWraps
:
true
keyNavigationWraps
:
true
property
int
itemWidth
:
Math
.
min
((
parent
.
width
*
0.6
)
/
(
count
/
2
),
property
int
itemWidth
:
fitItems
(
container
.
width
,
container
.
height
,
container
.
count
)
(
parent
.
height
*
0.5
)
/
(
count
/
3
))
property
int
itemHeight
:
itemWidth
delegate
:
ColorItem
{
delegate
:
ColorItem
{
audioVoices
:
activity
.
audioVoices
audioVoices
:
activity
.
audioVoices
source
:
model
.
image
source
:
model
.
image
audioSrc
:
model
.
audio
?
model
.
audio
:
""
audioSrc
:
model
.
audio
?
model
.
audio
:
""
question
:
model
.
text
question
:
model
.
text
sourceSize.height
:
container
.
item
Height
sourceSize.height
:
container
.
item
Width
*
0.9
sourceSize.width
:
container
.
itemWidth
sourceSize.width
:
container
.
itemWidth
*
0.9
}
}
add
:
Transition
{
add
:
Transition
{
PathAnimation
{
PathAnimation
{
...
...
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