hsqml-demo-samples 0.3.3.0 → 0.3.4.0
raw patch · 9 files changed
+158/−15 lines, 9 filesdep ~OpenGLdep ~OpenGLRawdep ~hsqmlnew-component:exe:hsqml-model1
Dependency ranges changed: OpenGL, OpenGLRaw, hsqml
Files
- CHANGELOG +8/−1
- LICENSE +1/−1
- hsqml-demo-samples.cabal +16/−6
- qml/factorial1.qml +2/−2
- qml/factorial2.qml +2/−2
- qml/model1.qml +114/−0
- src/Model1.hs +11/−0
- src/OpenGL1.hs +2/−2
- src/OpenGL2.hs +2/−1
CHANGELOG view
@@ -1,8 +1,15 @@ HsQML Samples - Release History +release 0.3.4.0 - 2016.02.24++ * Added AutoListModel sample.+ * Changed OpenGL samples to use versions 2.10 to 2.13 of the OpenGL package.+ * Fixed insufficient vertical space for text in the factorial samples.+ * Fixed build error with GHC 7.10.+ release-0.3.3.0 - 2015.01.20 - * Add OpenGLControlContext sample.+ * Added OpenGLControlContext sample. release-0.3.2.0 - 2014.11.13
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c)2014-2015, Robin KAY+Copyright (c)2014-2016, Robin KAY All rights reserved.
hsqml-demo-samples.cabal view
@@ -1,10 +1,10 @@ Name: hsqml-demo-samples-Version: 0.3.3.0+Version: 0.3.4.0 Cabal-version: >= 1.10 Build-type: Simple License: BSD3 License-file: LICENSE-Copyright: (c) 2014-2015 Robin KAY+Copyright: (c) 2014-2016 Robin KAY Author: Robin KAY Maintainer: komadori@gekkou.co.uk Stability: experimental@@ -43,6 +43,16 @@ hsqml == 0.3.* GHC-options: -threaded +Executable hsqml-model1+ Default-language: Haskell2010+ Hs-source-dirs: src+ Main-is: Model1.hs+ Build-depends:+ base == 4.*,+ text >= 0.11 && < 1.3,+ hsqml >= 0.3.4 && < 0.4+ GHC-options: -threaded+ Executable hsqml-opengl1 Default-language: Haskell2010 Hs-source-dirs: src@@ -50,8 +60,8 @@ Build-depends: base == 4.*, text >= 0.11 && < 1.3,- OpenGL == 2.9.*,- OpenGLRaw == 1.5.*,+ OpenGL >= 2.10 && < 2.14,+ OpenGLRaw >= 2.1 && < 2.6, hsqml >= 0.3.2 && < 0.4 GHC-options: -threaded if !flag(OpenGL)@@ -64,8 +74,8 @@ Build-depends: base == 4.*, text >= 0.11 && < 1.3,- OpenGL == 2.9.*,- OpenGLRaw == 1.5.*,+ OpenGL >= 2.10 && < 2.14,+ OpenGLRaw >= 2.1 && < 2.6, hsqml >= 0.3.3 && < 0.4 GHC-options: -threaded if !flag(OpenGL)
qml/factorial1.qml view
@@ -3,12 +3,12 @@ Column { height: 300; TextInput {- id: input; width: 300; height: 30; font.pixelSize: 30; focus: true;+ id: input; width: 300; font.pixelSize: 30; focus: true; } Rectangle { color: "red"; width: childrenRect.width; height: childrenRect.height; Text {- width: 300; height: 30; font.pixelSize: 30;+ width: 300; font.pixelSize: 30; text: "Calculate Factorial"; color: "white"; } MouseArea {
qml/factorial2.qml view
@@ -3,12 +3,12 @@ Column { height: 300; TextInput {- id: input; width: 300; height: 30; font.pixelSize: 30; focus: true;+ id: input; width: 300; font.pixelSize: 30; focus: true; } Rectangle { color: "red"; width: childrenRect.width; height: childrenRect.height; Text {- width: 300; height: 30; font.pixelSize: 30;+ width: 300; font.pixelSize: 30; text: "Calculate Factorial"; color: "white"; } MouseArea {
+ qml/model1.qml view
@@ -0,0 +1,114 @@+import QtQuick 2.0+import QtQuick.Controls 1.0+import QtQuick.Layouts 1.0+import HsQML.Model 1.0++ColumnLayout {+ spacing: 1;++ Text {+ Layout.fillWidth: true;+ text: 'Step 1) Enter a valid JSON array of values.';+ }+ TextField {+ id: input;+ Layout.fillWidth: true;+ text: '[]';++ property var json : null;+ onTextChanged: {+ try {+ json = JSON.parse(text);+ if (!(json instanceof Array)) {+ json = null;+ }+ }+ catch (e) {+ json = null;+ }+ }+ }++ Text {+ Layout.fillWidth: true;+ text: 'Step 2) Select the mode for calculating model changes.'+ }+ ComboBox {+ id: modeSelector;+ Layout.fillWidth: true;+ model: ListModel {+ ListElement { text: 'By Reset'; mode: AutoListModel.ByReset;}+ ListElement { text: 'By Index'; mode: AutoListModel.ByIndex;}+ ListElement { text: 'By Key'; mode: AutoListModel.ByKey;}+ ListElement {+ text: 'By Key (No Reorder)';+ mode: AutoListModel.ByKeyNoReorder;+ }+ }+ }++ Text {+ Layout.fillWidth: true;+ text: 'Step 3) Click the button to change the model.'+ }+ Button {+ Layout.fillWidth: true;+ text: 'Update Model';+ enabled: input.json != null;+ onClicked: autoModel.source = input.json;+ }++ Rectangle {+ Layout.fillWidth: true;+ Layout.fillHeight: true;+ Layout.preferredWidth: 300;+ Layout.minimumHeight: 30;+ color: 'lightblue';++ ListView {+ id: view;+ anchors.fill: parent;+ orientation: ListView.Horizontal;+ model: AutoListModel {+ id: autoModel;+ mode: modeSelector.model.get(modeSelector.currentIndex).mode;+ }+ delegate: Item {+ width: 30; height: 30;+ clip: true;++ Rectangle {+ anchors.fill: parent;+ border.width: 1;+ border.color: 'white';+ color: 'blue';+ opacity: 0.5;+ }++ Text {+ anchors.centerIn: parent;+ font.pixelSize: 25;+ text: String(modelData);+ }+ }+ displaced: Transition {+ NumberAnimation { properties: "x,y"; duration: 1000; }+ NumberAnimation { properties: "scale"; duration: 1000; to: 1; }+ }+ move: Transition {+ NumberAnimation { properties: "x,y"; duration: 1000; }+ NumberAnimation { properties: "scale"; duration: 1000; to: 1; }+ }+ add: Transition {+ NumberAnimation {+ properties: "scale"; duration: 1000; from: 0; to: 1;+ }+ }+ remove: Transition {+ NumberAnimation {+ properties: "scale"; duration: 1000; to: 0;+ }+ }+ }+ }+}
+ src/Model1.hs view
@@ -0,0 +1,11 @@+module Main where++import Graphics.QML++import Paths_hsqml_demo_samples++main :: IO ()+main = do+ doc <- getDataFileName "model1.qml"+ runEngineLoop defaultEngineConfig {+ initialDocument = fileDocument doc}
src/OpenGL1.hs view
@@ -4,7 +4,7 @@ import Graphics.QML.Canvas import Graphics.Rendering.OpenGL.GL import Graphics.Rendering.OpenGL.GLU.Errors-import Graphics.Rendering.OpenGL.Raw.ARB.ShaderObjects (glUniformMatrix4fv)+import Graphics.Rendering.OpenGL.Raw.ARB.ShaderObjects (glUniformMatrix4fvARB) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as T@@ -100,7 +100,7 @@ let num = realToFrac $ modelData paint :: GLfloat currentProgram $= Just program let (UniformLocation matLocId) = matLoc- glUniformMatrix4fv matLocId 1 0 (+ glUniformMatrix4fvARB matLocId 1 0 ( castPtr $ matrixPtr paint :: Ptr GLfloat) uniform modelLoc $= Index1 num bindBuffer ArrayBuffer $= Just buf
src/OpenGL2.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE- ScopedTypeVariables+ ScopedTypeVariables,+ TypeFamilies #-} module Main where