Warning, /education/gcompris/src/activities/balancebox/BalanceItem.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - BalanceItem.qml
0002  *
0003  * SPDX-FileCopyrightText: 2014-2015 Holger Kaelberer <holger.k@elberer.de>
0004  *
0005  * Authors:
0006  *   Holger Kaelberer <holger.k@elberer.de>
0007  *
0008  *   SPDX-License-Identifier: GPL-3.0-or-later
0009  */
0010 import QtQuick 2.12
0011 import Box2D 2.0
0012 import QtGraphicalEffects 1.0
0013 
0014 import "../../core"
0015 
0016 Item {
0017     id: item
0018 
0019     z: 2  // above most
0020 
0021     property alias world: itemBody.world
0022 
0023     property alias imageSource: itemImage.source
0024 
0025     property alias body: itemBody
0026     property alias bodyType: itemBody.bodyType
0027     property alias linearDamping: itemBody.linearDamping
0028     
0029     property alias fixtures: itemBody.fixtures
0030     property alias sensor: itemFixture.sensor
0031     property alias categories: itemFixture.categories
0032     property alias collidesWith: itemFixture.collidesWith
0033     property alias density: itemFixture.density
0034     property alias friction: itemFixture.friction
0035     property alias restitution: itemFixture.restitution
0036     
0037     property alias shadow: itemShadow.visible
0038     property alias shadowHorizontalOffset: itemShadow.horizontalOffset
0039     property alias shadowVerticalOffset: itemShadow.verticalOffset
0040     // for goal in the editor, use 1.1 scale
0041     property alias imageScale: itemImage.scale
0042 
0043     signal beginContact(Item item, Item other)
0044     signal endContact(Item item, Item other)
0045 
0046     Image {
0047         id: itemImage
0048         width: item.width
0049         height: item.height
0050         sourceSize.width: width
0051         sourceSize.height: height
0052         source: item.imageSource
0053         anchors.centerIn: parent
0054         scale: 1
0055     }
0056 
0057     DropShadow {
0058         id: itemShadow
0059         anchors.fill: itemImage
0060         cached: true
0061         visible: false  // note: dropping shadows for the walls is really expensive
0062                         // in terms of CPU usage!
0063         radius: 0
0064         samples: 16
0065         color: "#80000000"
0066         source: itemImage
0067     }
0068 
0069     Body {
0070         id: itemBody
0071         
0072         target: item
0073         bodyType: Body.Static
0074         sleepingAllowed: false
0075         fixedRotation: true
0076         linearDamping: 0
0077 
0078         fixtures: Circle {
0079             id: itemFixture
0080 
0081             radius: itemImage.width / 2
0082 
0083             onBeginContact: item.beginContact(getBody().target, other.getBody().target)
0084             onEndContact: item.endContact(getBody().target, other.getBody().target)
0085         }
0086     }
0087 }