www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 4144bed5aac63b51782e8ca7b69869232e15102c
parent 3525f79c252a0ff264af683f365dec1364b5b7f4
Author: gduperon <gduperon@5d9ba3ac-444b-4713-9fb3-0b58e79229a2>
Date:   Sat, 15 May 2010 20:44:57 +0000

ajout d'instance-bloc avec dimensions de la zone, sur toutes les vues \o/

git-svn-id: https://projetud.info-ufr.univ-montp2.fr/svn/flin607-2009-gduperon@48 5d9ba3ac-444b-4713-9fb3-0b58e79229a2

Diffstat:
Ajside3/bugs | 1+
Mjside3/extensions-jQuery.js | 4++++
Mjside3/mvc/barre-outils.js | 14+-------------
Mjside3/mvc/definition.js | 6++----
Mjside3/mvc/instance-bloc.js | 4++++
Mjside3/mvc/instance-recherche.js | 8++++----
Mjside3/mvc/monde.js | 34++++++++++++++++++++++++++++++++--
Mjside3/mvc/recherche.js | 2+-
Mjside3/mvc/resultat-recherche.js | 12++++++++++--
Mjside3/style.css | 8++++----
10 files changed, 63 insertions(+), 30 deletions(-)

diff --git a/jside3/bugs b/jside3/bugs @@ -0,0 +1 @@ +Lors de la création de la vue d'une instance-bloc, les définitions existantes ne sont pas ajoutées. diff --git a/jside3/extensions-jQuery.js b/jside3/extensions-jQuery.js @@ -191,6 +191,10 @@ surchargeAccesseur( getRectangle = function(x1,y1,x2,y2) { + if (y1 === undefined) { + var o = $(x1).offset(); + return getRectangle(o.left, o.top, o.left + $(x1).width(), o.top + $(x1).height()); + } if (x2 === undefined) { var oa = $(x1).offset(); var ob = $(y1).offset(); diff --git a/jside3/mvc/barre-outils.js b/jside3/mvc/barre-outils.js @@ -28,19 +28,7 @@ function CBarreOutils(mBarreOutils, vMondeParente) { (this.vue.vBoutonNouveauBloc) .click(function() { that.modèle.monde.log.envoiMessage("Cliquez-glissez pour créer un nouveau bloc."); - that.modèle.monde.outilZone = function(cDéfinition, rect) { - console.log('Zone sur', cDéfinition, rect.x1, rect.y1, rect.x2, rect.y2, rect.width, rect.height); - that.modèle.monde.outilZone = that.modèle.monde.actionAucune; - - var mb = new MBloc(); - that.modèle.monde.ajouterBloc(mb); - var mib = mb.demanderInstance(); - cDéfinition.modèle.ajouterInstanceBloc(mib); - } -/* var mb = new MBloc(); - that.modèle.monde.ajouterBloc(mb); - var mib = mb.demanderInstance(); - that.modèle.monde.scratch.ajouterInstanceBloc(mib);*/ + that.modèle.monde.outilZone = that.modèle.monde.actionNouveauBloc; }); (this.vue.vBoutonRecherche) diff --git a/jside3/mvc/definition.js b/jside3/mvc/definition.js @@ -46,16 +46,14 @@ function CDéfinition(mDéfinition, vInstanceBlocParente) { var that = this; this.vue.zonable({ start: function() { - console.log('startZone'); }, zone: function() { - //console.log('zone'); }, end: function(start, end, rect) { - console.log('endZone'); - that.modèle.bloc.monde.outilZone(that, rect); + that.modèle.bloc.monde.outilZone(that, rect, getRectangle(that.vue)); } }); + this.modèle.onAjoutInstanceBloc(function(instanceBloc) { var cib = new CInstanceBloc(instanceBloc, that.vue); }); diff --git a/jside3/mvc/instance-bloc.js b/jside3/mvc/instance-bloc.js @@ -75,6 +75,10 @@ function CInstanceBloc(mInstanceBloc, vDéfinitionParente) { }); this.vue.titre(this.modèle.bloc.nom); + this.vue.css('left', (this.modèle.rect.x1 - this.modèle.rectParent.x1) / this.modèle.rectParent.width * vDéfinitionParente.width()); + this.vue.css('top', (this.modèle.rect.y1 - this.modèle.rectParent.y1) / this.modèle.rectParent.height * vDéfinitionParente.height()); + this.vue.width(this.modèle.rect.width / this.modèle.rectParent.width * vDéfinitionParente.width()); + this.vue.height(this.modèle.rect.height / this.modèle.rectParent.height * vDéfinitionParente.height()); new CDéfinitions(this.modèle, this.vue.vDéfinitions); } diff --git a/jside3/mvc/instance-recherche.js b/jside3/mvc/instance-recherche.js @@ -2,7 +2,7 @@ function MInstanceRecherche() { $.extend(this, { uid: singleton.uid(), // Propriétés - recherche: null, + mRecherche: null, termes: '', sélection: [], ajouterRésultatSélection: function(s) { @@ -91,19 +91,19 @@ function CInstanceRecherche(mInstanceRecherche, vMondeParente) { that.actualiserRecherche(); }); - (this.modèle.recherche.monde) + (this.modèle.mRecherche.monde) .onAjoutBloc(function(bloc) { that.actualiserRecherche([bloc], true, true); }); - (this.modèle.recherche.monde) + (this.modèle.mRecherche.monde) .onModificationBloc(function(bloc) { that.actualiserRecherche([bloc], true, true); }); this.actualiserRecherche = function(domaine, animAjout, animSuppression) { var termes = this.vue.termes().toLowerCase().split(" "); - var domaine = domaine || this.modèle.recherche.monde.blocs; + var domaine = domaine || this.modèle.mRecherche.monde.blocs; var résultats = filtrerValeurs(mInstanceRecherche, domaine, termes, function(b) { return { original: b.nom, diff --git a/jside3/mvc/monde.js b/jside3/mvc/monde.js @@ -52,15 +52,45 @@ function MMonde(nom) { this.blocs.remove(b); } }); + + var that = this; /* Actions */ - this.actionAucune = function() {} + this.actionAucune = function() {}; + this.actionNouveauBloc = function(cDéfinition, rect, rectParent) { + that.outilZone = that.actionAucune; + if (rect.width < 10 || rect.height < 10) { + return; + } + + var mb = new MBloc(); + that.ajouterBloc(mb); + var mib = mb.demanderInstance(); + mib.rect = rect; + mib.rectParent = rectParent + cDéfinition.modèle.ajouterInstanceBloc(mib); + }; + + this.actionInstanceBloc_mBloc = null; + this.actionInstanceBloc = function(cDéfinition, rect, rectParent) { + that.outilZone = that.actionAucune; + if (rect.width < 10 || rect.height < 10 || that.actionInstanceBloc_mBloc === null) { + return; + } + + console.log(that); + var mib = that.actionInstanceBloc_mBloc.demanderInstance(); + mib.rect = rect; + mib.rectParent = rectParent + cDéfinition.modèle.ajouterInstanceBloc(mib); + }; /* Outils */ this.outilZone = this.actionAucune; /* Scratch */ - this.mBlocScratch = new MBloc(); // this.scratch.bloc == null; + this.mBlocScratch = new MBloc(); + this.mBlocScratch.changeNom("Scratch"); this.ajouterBloc(this.mBlocScratch); this.mDéfinitionScratch = new MDéfinition(); this.mBlocScratch.ajouterDéfinition(this.mDéfinitionScratch); diff --git a/jside3/mvc/recherche.js b/jside3/mvc/recherche.js @@ -11,7 +11,7 @@ function MRecherche() { instances: [], demanderInstance: function() { var mir = new MInstanceRecherche(); - mir.recherche = this; + mir.mRecherche = this; this.instances.push(mir); return mir; }, diff --git a/jside3/mvc/resultat-recherche.js b/jside3/mvc/resultat-recherche.js @@ -50,9 +50,17 @@ function CRésultatRecherche(mRésultatRecherche, vInstanceRechercheParente) { var that = this; this.vue.toggle(function() { - that.modèle.mInstanceRecherche.ajouterRésultatSélection(that); + var mir = that.modèle.mInstanceRecherche; + mir.ajouterRésultatSélection(that); + var monde = mir.mRecherche.monde; + monde.actionInstanceBloc_mBloc = that.modèle.objet; + monde.outilZone = monde.actionInstanceBloc; }, function() { - that.modèle.mInstanceRecherche.supprimerRésultatSélection(that); + var mir = that.modèle.mInstanceRecherche; + mir.supprimerRésultatSélection(that); + var monde = mir.mRecherche.monde; + monde.actionInstanceBloc_mBloc = null; + monde.outilZone = monde.actionAucune; }); this.ajoutSélection = function() { diff --git a/jside3/style.css b/jside3/style.css @@ -139,12 +139,12 @@ body { /* Instance-bloc */ .instance-bloc.vMain { position: absolute; - top: 250px; - left: 300px; - width: 25em; + top: 2%; + left: 3%; + width: 20%; min-width: 4em; min-height: 3em; - height: 12em; + height: 20%; border: medium solid gray; background-color: white;