-
Notifications
You must be signed in to change notification settings - Fork 790
change import media dialog box #1666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
For costumes, backgrounds and sounds, the import dialog box now display categories. For costumes and background, it displays small thumbnails instead of large original files.
|
I think this is really helpful! A few things:
|
|
Yes you're right : I've commited the whole thing at once but I shouldn't have to do it this way... I understand it's not easy for you to review : I'm really sorry about that !
could become in future :
|
|
Thank you, @erichake , for this really nice contribution! You've really caught on the Morphic way of doing things very quickly and thoroughly, I'm impressed. I really like these changes, especially the categories and the thumbnails, this feels a lot better and is much nicer to use. I'll definitely take a closer look at this pull-request with the intention of integrating it into the main Snap trunk. But I'm going to have to ask you for a little patience, since I'm mostly travelling this week. In the meantime you've already convinced Bernat and Michael :-) |
gui.js
Outdated
| msg.destroy(); | ||
| myself.popupMediaImportDialog(folderName, items); | ||
| myself.getURL( | ||
| folderName + "/catalog.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
this.getURL(this.resourceURL(folderName, 'catalog.json'), ...
| myself.getURL( | ||
| folderName + "/catalog.json", | ||
| function (txt) { | ||
| myself.popupMediaImportDialog(folderName, JSON.parse(txt)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to this about this - we have a getMediaList function or something similar.
gui.js
Outdated
| return element.name; | ||
| }, | ||
| null, | ||
| function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this.
gui.js
Outdated
|
|
||
| var colect = {}; | ||
| items.forEach(function (item) { | ||
| var section = (item.section === "") ? "other" : item.section; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might to make the check more broad... Maybe isNil(item.section) || item.section === '' ?
Otherwise if someone leaves off a section key then the sections list would have a "null" section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think it'd be an undefined section...anyway I don't think we want that either. :)
|
Thank's for this review, I've made the changes :
|
|
Oups sorry I said a wrong thing : I didn't see that getMedialList was used by getExamplesProjectList... |
|
@erichake Thank you for this great contribution 👍 Would it be difficult to add a right button in the costumes area to import a costume from the media library ? idem for the sounds in the sound area ? Because it was the first thing I tried to do when I looked for the import dialogue box for the costumes. |
|
One other thing which would be great: That it be possible to draw the costumes with blocks, like draw a star with a sprite, then import the star as a costume; or draw a fraction with LaTeX and have it as a costume afterwards. The biggest fun would be a "build a costume" block ;-) (imagine that a sprite could build its own costume when created as a clone) |
|
@AlainBusser we have that in Snap! It's a library called here are a bunch of sample projects that make use of this feature: Valentine and the coolest of them all, the world's fastest fractals, by Dan Garcia: Enjoy! |
I think this should be used, even if it's just calling JSON.parse. But also I think we should extract the sections stuff out of the actual morph layout code. I'll write more later after work when I can better look at some stuff. The mediaList could be adapted to look for folder/catalog.json which could also be used for libraries and example projects so that we don't have multiple formats.
And this makes sense. Both formats are easy so I don't mind much either way, I was more curious as to why. :) |
|
Thanks for the examples; I have an other idea yet: Gerbert abacus The sprites (Gerbert called them "apices") each have a numerical value (but depending on where they are inside the abacus) and each apice should have as a costume, the digit yielding its value. I'll try it when I have some time |
cycomachead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some code comments - most are minor.
This basically is 2 parts, including #1594
I think it would be good, if we do this to also update the code for libraries and examples, which would have no section data. It might make sense to do that first, but it doesn't matter me to. :)
index.php
Outdated
| @@ -0,0 +1,17 @@ | |||
| <!DOCTYPE html> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to commit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups sorry, I didn't see it was in my commit !
|
|
||
| listField.action = function (elt) { | ||
| msg = myself.showMessage('Opening ' + elt.name + '...'); | ||
| // Not proud of this... I wasn't able to display the msg dialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're missing a call to .fixLayout() or popUp(). You can look at this, perhaps:
https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/gui.js#L6576
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there's possibly an issue with using the count variable. Not sure.
gui.js
Outdated
| }; | ||
|
|
||
| listField.action = function (elt) { | ||
| msg = myself.showMessage('Opening ' + elt.name + '...'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're combining fields, then explicitly call localize() around opening.
gui.js
Outdated
| count = items.length; | ||
| items.forEach(function (item) { | ||
|
|
||
| if ((item.section === section) || (section === "All")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function if much easier to read if it has:
if (condition) {return; } as the first statement and everything else is de-indented.
gui.js
Outdated
| sections.sort(sectionsSortFilter); | ||
| sections.push({ "name": "All" }); | ||
|
|
||
| var listField = new ListMorph(sections, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter should be on it's own line.
|
|
||
| var colect = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to put this in getMediaList, and have that function return something that has sections and the data. Otherwise I think it should be it's own small function, to get sections and sort items.
gui.js
Outdated
|
|
||
| content.color = dialog.color; | ||
| listField.setWidth(listFieldWidth); | ||
| listField.contents.children[0].alpha = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jens would know better, if there's no other way, but generally accessing another morph through children is not desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right : childrens are changing sometimes :-)
So I finally found the MenuMorph without dealing with children :
listField.listContents.alpha = 0;
is far better...
gui.js
Outdated
| ); | ||
| var decrement = function () { | ||
| count--; | ||
| // console.log(count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be removed.
gui.js
Outdated
| var section = (elt.name === "other") ? "" : elt.name; | ||
| frame.contents.children.splice(0, frame.contents.children.length); | ||
| count = items.length; | ||
| items.forEach(function (item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it probably makes sense to extract this into it's own function, so we can do items.forEach(renderIcon) or something.
gui.js
Outdated
| }; | ||
| img.src = url; | ||
| } | ||
| } else decrement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be braces around all conditional expressions.
|
I have a minor request: Could you change the little "SVG" flag to "vector" or maybe just "vec"? I would like our users not to have to know what an svg is. (And no doubt someday someone will invent another vector file format.) Otherwise it's great! Adding "blessed by Jens" label because he did! |
|
@brianharvey , you can't just add "blessed by jens". I really love this PR and we're going to pull it, but "blessed by jens" means that I've reviews the code and it's something that helps me remember I actually did. So, please don't confuse my memory! That said, @erichake, this is beautiful, and now I did review it. :-) |
|
Okay, sorry, I had to "unbless" this for now, because we found out, that a vast majority of the costumes are still broken, especially having the wrong size. This issue has been reported elsewhere in schools and needs to be addressed before we can pull this and work on it. @brianharvey , what's the status on the broken costumes? These need to be fixed urgently, so we can work on both this and on the release. |
|
That said, @erichake your changes are beautiful, and we will incorporate them! |
|
Sorry, Jens, I thought I'd understood you to say that it was blessed. Remind me what's wrong with the costumes? I just copied them from Scratch. |
|
@brianharvey , many costumes are way too big, about double the size they are in Scratch. Teachers (and Mary) have complained about that a lot over on Piazza, because they have to tell students to scale the whole sprite down to 50% size to get them to look right. Worse, some costumes are "normal", and others are not, so changing to another costume often requires a sprite-resize. I'm pretty sure that this is an unintentional artifact that happens when you edit graphics on a retina display. Not in Snap but in some other image processing app. Anyway, this has been pretty urgent for a longish time, so we should work on it now, to fix it for the upcoming release. After that I really want most of @erichake's contributions. If we can get the costumes right in time, I'd love to include these contributions in the upcoming release as well. |
|
Hmm. It looks to me as if the problem is with new Scratch-2.0 bitmap costumes; vector costumes and old Scratch costumes both seem okay. I didn't edit any of the costumes, though, so I don't believe your theory. My theory is that Scratch added double-density costumes on purpose for the benefit of retina displays, and they have code that half-sizes them on input on non-retina displays. Will investigate further... |
|
We really should work on this -- not sure how big the conflicts are now, but it should be fairly easily resolved. |
|
@jmoenig @brianharvey How do we feel about tidying this up and merging soon? The biggest "downside" is having thumbnails in the repo, but it's really not all that much data. |
|
Yes, please! |


I've changed import dialog box for costumes, backgrounds and sounds and I've created categories, like this :
Beside, this import dialog loads costumes and backgrounds as light thumbnails instead of large picture files.
I've also found out that on my mac, a large amount of sound files were not loading correctly (wav codecs not recognised in some browsers, for example for "A-trombone.wav" on my firefox and my chrome). So I've changed .wav to .mp3, and it also reduced the Sound folder size by 3Mo.
All of this could be seen here :
http://db-maths.nuxit.net/snap/snap.html