SoundRecorder, but how do I do layout?

Post your nifty GP projects here!

Moderator: MSandro

Post Reply
mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

SoundRecorder, but how do I do layout?

Post by mguzdial » Jul 3rd, '16, 16:13

Here's the working but ugly SoundRecorder project.

Click Record to record a sound. The status will tell you that it's recording. Click Stop to stop the recording.
Click Play to play the sound. The status will show you that it's playing. Click Stop to stop the playback -- but as Steve pointed out, it doesn't actually work because the "stop all sounds" block currently isn't working.

But here's the part that I'm struggling with -- how do you layout morphs in GP? I've tried broadcasting a "layout" message and lining everything up with the Record button. Doesn't work. No matter what I do, the status morph just seems to wander all over.

Is there any way to position morphs and have them stay there?
Attachments
soundrecorder.gpp
(268.37 KiB) Downloaded 41 times

MrSteve
Posts: 61
Joined: Jun 16th, '16, 01:22

Re: SoundRecorder, but how do I do layout?

Post by MrSteve » Jul 4th, '16, 04:14

Actually I think "stop all sounds" does work. It's the "stop" block that doesn't work.

I added "set shared playing to 1" block in Play class for "When clicked" and it works. (see attached project) Here is where the ability to step through scripts and watch them run would be VERY useful to students of all levels. Ideally with the ability to set a breakpoint on a script.
Screen Shot 2016-07-03 at 11.47.56 PM.png
Now it would also be good if we could add a pause button as well, but couldn't quickly figure that out.

Now regarding laying out morphs, the sample project in Widgets -> DragNDropList.gpp shows a way. This is like a holder in Etoys (although what are looking for is more like "place into a row" in Etoys.) I don't like the implementation of DragNDropList as it requires you to add behaviors to objects you want to drop into a holder/row. I tried to build a holder but I can't figure out how to reference another objects attributes such as: x, y, width, height. Droppable behaviors might also help me but I haven't figured that out either.

Anyway given current state/design of GP (and given I can't figure out how to reference another objects attributes such as: x, y, width, height) the use of a shared variable as you tried is another way.
Attachments
soundrecorder.st.gpp
(126.35 KiB) Downloaded 42 times

MrSteve
Posts: 61
Joined: Jun 16th, '16, 01:22

Re: SoundRecorder, but how do I do layout?

Post by MrSteve » Jul 4th, '16, 04:38

Okay I created a project that does the layout (see attached). I also modified it so you can move around the sound recorder by dragging the Record button (after you click "Go"). This way a user could add this to any project and move it around. You could also add in scaling so scaling the Record button would also scale the other buttons as well. The only issue I have is the images should all be the same size.

I would prefer a text block widget (and a number of other items say from the Etoys parts bin - hint, hint, nudge, nudge, wink, wink). I will think more about why and write a post on that at a later date.

Cheers
Mr. Steve
Attachments
soundrecorder.st.v2.gpp
(134.93 KiB) Downloaded 39 times

MrSteve
Posts: 61
Joined: Jun 16th, '16, 01:22

Re: SoundRecorder, but how do I do layout?

Post by MrSteve » Jul 4th, '16, 05:01

Okay last post of the evening, have to get up early to get to the parade with the kids.

Attached is version that detects "shift-click" and allows you to set the scale of the "recorder". To try "shift-click" on Record button and enter a scale value.

Couldn't find a "is this an number" check block, which would be useful for validating user input.
Attachments
soundrecorder.st.v3.gpp
(45.18 KiB) Downloaded 48 times

mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

Re: SoundRecorder, but how do I do layout?

Post by mguzdial » Jul 6th, '16, 19:25

When I did shift-click, I could drag Record around. Play snapped to its side when I hit Go, but then was in a forever loop.

It's the Status morph that I was dragging into place, but it wouldn't stay there. I just tried again. I can drag it into place next to the Play/Record buttons. But when I set Alpha to 0 to hide it, then back to 1 to show it, it moves! Very weird.

mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

Re: SoundRecorder, but how do I do layout?

Post by mguzdial » Jul 6th, '16, 19:52

Yup, Stephen was right -- stop all sounds works. I just hadn't set my Playing shared variable correctly so that I was stopping all sounds correctly. Attached version works. Still can't figure out how to get a morph to stay fixed in place. Does setAlpha change the position of the morph?
Attachments
soundrecorder-v2.gpp
(268.44 KiB) Downloaded 47 times

mguzdial
Posts: 70
Joined: Sep 15th, '15, 11:21

Re: SoundRecorder, but how do I do layout?

Post by mguzdial » Jul 6th, '16, 21:33

No, there's no layout bug. I just had a goTo:x:y lying around. <sigh>

This version is my most correct version yet.
Attachments
soundrecorder-v3.gpp
(278.05 KiB) Downloaded 45 times

Post Reply