diff --git a/src/activities/simplepaint/CMakeLists.txt b/src/activities/simplepaint/CMakeLists.txt index 46e4cf669..cc7ca463f 100644 --- a/src/activities/simplepaint/CMakeLists.txt +++ b/src/activities/simplepaint/CMakeLists.txt @@ -1 +1 @@ -GCOMPRIS_ADD_RCC(activities/simplepaint *.qml *.svg *.js) +GCOMPRIS_ADD_RCC(activities/simplepaint *.qml *.svg *.js resource/*.svg) diff --git a/src/activities/simplepaint/Simplepaint.qml b/src/activities/simplepaint/Simplepaint.qml index e406fbc3f..31cdf3a2a 100644 --- a/src/activities/simplepaint/Simplepaint.qml +++ b/src/activities/simplepaint/Simplepaint.qml @@ -1,229 +1,240 @@ /* GCompris - Simplepaint.qml * * Copyright (C) 2014 Bruno Coudoin * * Authors: * Christof Petig and Ingo Konrad (GTK+ version) * Bruno Coudoin (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 import "../../core" import "simplepaint.js" as Activity ActivityBase { id: activity onStart: focus = true pageComponent: Image { id: background source: items.backgroundImg sourceSize.width: Math.max(parent.width, parent.height) fillMode: Image.PreserveAspectCrop signal start signal stop focus: true Component.onCompleted: { activity.start.connect(start) activity.stop.connect(stop) } QtObject { id: items property alias background: background property alias bar: bar property alias paintModel: paintModel property var colors: bar.level < 10 ? Activity.colorsSimple : Activity.colorsAdvanced property string colorSelector: colors[0] property string backgroundImg: Activity.backgrounds[bar.level - 1] } onStart: Activity.start(main, items) onStop: Activity.stop() MultiPointTouchArea { anchors.fill: parent onPressed: checkTouchPoint(touchPoints) onTouchUpdated: checkTouchPoint(touchPoints) } function checkTouchPoint(touchPoints) { for(var i in touchPoints) { var touch = touchPoints[i] var block = rootItem.childAt(touch.x, touch.y) if(block) block.touched() } } Item { id: rootItem anchors.fill: parent } ListModel { id: paintModel } // The color selector GridView { id: colorSelector anchors { left: parent.left top: parent.top bottom: bar.top } width: cellWidth + 10 * ApplicationInfo.ratio model: items.colors cellWidth: 60 * ApplicationInfo.ratio cellHeight: cellWidth delegate: Item { width: colorSelector.cellWidth height: width Rectangle { id: rect width: parent.width height: width radius: width * 0.1 z: iAmSelected ? 10 : 1 color: modelData - border.color: 'black' - border.width: 1 + border.color: "#373737" + border.width: modelData == "#00FFFFFF" ? 0 : 1 + + Image { + scale: 0.9 + width: rect.height + height: rect.height + sourceSize.width: rect.height + sourceSize.height: rect.height + source: Activity.url + "eraser.svg" + visible: modelData == "#00FFFFFF" ? 1 : 0 + anchors.centerIn: parent + } property bool iAmSelected: modelData == items.colorSelector states: [ State { name: "notclicked" when: !rect.iAmSelected && !mouseArea.containsMouse PropertyChanges { target: rect scale: 0.8 } }, State { name: "clicked" when: mouseArea.pressed PropertyChanges { target: rect scale: 0.7 } }, State { name: "hover" when: mouseArea.containsMouse PropertyChanges { target: rect scale: 1.1 } }, State { name: "selected" when: rect.iAmSelected PropertyChanges { target: rect scale: 1 } } ] SequentialAnimation { id: anim running: rect.iAmSelected loops: Animation.Infinite alwaysRunToEnd: true NumberAnimation { target: rect property: "rotation" from: 0; to: 10 duration: 200 easing.type: Easing.OutQuad } NumberAnimation { target: rect property: "rotation" from: 10; to: -10 duration: 400 easing.type: Easing.InOutQuad } NumberAnimation { target: rect property: "rotation" from: -10; to: 0 duration: 200 easing.type: Easing.InQuad } } Behavior on scale { NumberAnimation { duration: 70 } } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true onClicked: { activity.audioEffects.play('qrc:/gcompris/src/core/resource/sounds/scroll.wav') items.colorSelector = modelData } } } } } Item { anchors { top: parent.top left: colorSelector.right right: parent.right bottom: parent.bottom } Repeater { model: paintModel parent: rootItem PaintItem { initialX: colorSelector.width + 20 * ApplicationInfo.ratio ix: m_ix iy: m_iy nbx: m_nbx nby: m_nby color: items.colors[0] } } } DialogHelp { id: dialogHelpLeftRight onClose: home() } Bar { id: bar content: BarEnumContent { value: help | home | reload | level } onHelpClicked: { displayDialog(dialogHelpLeftRight) } onReloadClicked: Activity.initLevel() onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: home() } } } diff --git a/src/activities/simplepaint/resource/README b/src/activities/simplepaint/resource/README new file mode 100644 index 000000000..a3454aaaf --- /dev/null +++ b/src/activities/simplepaint/resource/README @@ -0,0 +1,5 @@ +Copyright: Timothée Giet, 2018 +License: CC-BY-SA 4.0 +Files: +eraser.svg + diff --git a/src/activities/simplepaint/resource/eraser.svg b/src/activities/simplepaint/resource/eraser.svg new file mode 100644 index 000000000..473be84b5 --- /dev/null +++ b/src/activities/simplepaint/resource/eraser.svg @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2018 + + + Timothée Giet + + + + + + + + + + + + + + + + + + + + diff --git a/src/activities/simplepaint/simplepaint.js b/src/activities/simplepaint/simplepaint.js index 4c49192c0..b8e570b75 100644 --- a/src/activities/simplepaint/simplepaint.js +++ b/src/activities/simplepaint/simplepaint.js @@ -1,174 +1,176 @@ /* GCompris - simplepaint.js * * Copyright (C) 2014 Bruno Coudoin * * Authors: * Christof Petig and Ingo Konrad (GTK+ version) * Bruno Coudoin (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ .pragma library .import QtQuick 2.6 as Quick +var url = "qrc:/gcompris/src/activities/simplepaint/resource/" + var colorsSimple = [ '#00FFFFFF', '#FF550000', '#FFaa0000', '#FFffaaaa', '#FFffdd55', '#FF918a6f', '#FFccff00', '#FFe5ff80', '#FF330080', '#FF9955ff', '#FFe9afdd', '#FFff2a7f' ] var colorsAdvanced = [ '#00FFFFFF', '#FF550000', '#FF800000', '#FFaa0000', '#FFd40000', '#FFff0000', '#FFff2a2a', '#FFff8080', '#FFffaaaa', '#FFffd5d5', '#FFc83737', '#FFd35f5f', '#FFde8787', '#FFaa4400', '#FFd45500', '#FFff7f2a', '#FFff9955', '#FFffccaa', '#FFaa8800', '#FFffcc00', '#FFffdd55', '#FFffe680', '#FFc8ab37', '#FFd3bc5f', '#FF918a6f', '#FFaca793', '#FFaad400', '#FFccff00', '#FFe5ff80', '#FFf6ffd5', '#FF00d455', '#FF80ffb3', '#FF00ffcc', '#FF80ffe6', '#FF2ad4ff', '#FFaaeeff', '#FF0066ff', '#FF5555ff', '#FF87aade', '#FF80b3ff', '#FF0000ff', '#FF330080', '#FF9955ff', '#FFdd55ff', '#FFff2ad4', '#FFe9afdd', '#FFff2a7f', '#FFff80b2', '#FFd35f8d' ] var backgrounds = [ 'qrc:/gcompris/src/activities/menu/resource/background.svg', 'qrc:/gcompris/src/activities/colors/resource/background.svg', 'qrc:/gcompris/src/activities/wordsgame/resource/background.svg', 'qrc:/gcompris/src/activities/sudoku/resource/background.svg', 'qrc:/gcompris/src/activities/mosaic/resource/background.svg', 'qrc:/gcompris/src/activities/algebra_by/resource/background.svg', 'qrc:/gcompris/src/activities/scalesboard/resource/background.svg', 'qrc:/gcompris/src/activities/redraw/resource/background.svg', 'qrc:/gcompris/src/activities/color_mix/resource/background.svg', 'qrc:/gcompris/src/activities/missing-letter/resource/background.svg', 'qrc:/gcompris/src/activities/enumerate/resource/background.svg', 'qrc:/gcompris/src/activities/football/resource/background.svg', 'qrc:/gcompris/src/activities/hanoi_real/resource/background.svg', 'qrc:/gcompris/src/activities/intro_gravity/resource/background.svg', 'qrc:/gcompris/src/activities/instruments/resource/background.svg', 'qrc:/gcompris/src/activities/gletters/resource/background.svg', 'qrc:/gcompris/src/activities/braille_alphabets/resource/background.svg', 'qrc:/gcompris/src/activities/followline/resource/background.svg', 'qrc:/gcompris/src/activities/money/resource/background.svg', 'qrc:/gcompris/src/activities/menu/resource/background.svg', 'qrc:/gcompris/src/activities/smallnumbers2/resource/background.svg', 'qrc:/gcompris/src/activities/align4-2players/resource/background.svg', 'qrc:/gcompris/src/activities/smallnumbers/resource/background.svg', 'qrc:/gcompris/src/activities/magic-hat-minus/resource/background.svg', 'qrc:/gcompris/src/activities/tic_tac_toe/resource/background.svg', 'qrc:/gcompris/src/activities/click_on_letter/resource/background.svg', 'qrc:/gcompris/src/activities/fifteen/resource/background.svg' ] var main var items // The size of the array var nbx var nby var currentLevel = 0 var numberOfLevel = backgrounds.length function start(main_, items_) { main = main_ items = items_ currentLevel = 0 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 items.paintModel.clear() nbx = 20 + currentLevel nby = Math.floor(nbx * (main.height / main.width)) var model = [] for(var ix = 0; ix < nbx; ++ix) { for(var iy = 0; iy < nby; ++iy) { items.paintModel.append( { "m_ix": ix, "m_iy": iy, "m_nbx": nbx, "m_nby": nby, } ) } } } function nextLevel() { if(numberOfLevel <= ++currentLevel ) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); } function getColor() { return items.colorSelector }