Soda v0.7: gorgeous and powerful GUI/ windowing/ button library. Now with fully selectable text.

Soda v0.2 is now available at the GitHub link at the top of the post.

It now has fairly comprehensive hyperlinked documentation, in the GitHub readme (in the demo, you can access this page by pressing the query button in the corner of the pane)

Here are the release notes:

Version Notes

v0.2

  • NEW Soda.DropdownList - A button which, when pressed, toggles a dropdown list (this is a wrapper or factory which makes it much easier to setup dropdown lists). When an item is selected from the list, the button’s label changes to reflect the selection, and an optional callback is triggered.

  • NEW Soda.Toggle - now, in addition to iOS-style Soda.Switch (with an animated lever that ficks back and forth), any button can behave as a toggle. This has been implemented by separating the graphics and animation of Soda.Switch from the toggle button logic.

  • Callbacks have been made more consistent and are triggered by more elements. Callbacks are now always triggered as self:callback (with a colon) so the first argument passed to the callback will always be the sender’s self. If you have any callbacks that take an argument, eg callback = function(inkey), these will now need to have a self/this variable as their first argument (how you name the variables passed to the callback is up to you): eg callback = function(self, inkey).

    • In Soda.TextEntry, callback is triggered by hitting return or the close keyboard button (but not by selecting a different interface element, which closes the keyboard and cancels text entry). Callback is passed the string entered.

    • In Soda.List, callbacks return 3 variables: 1) the sender (the list object itself), 2) the selected item, 3) the selected item’s title string

    • Soda.Toggle and Soda.Switch have two callbacks: callback (when on state is activated) and callbackOff

  • new update parameter. Like a callback, but triggered every frame, in case any elemenets need constant updating (see the new profiler panel in the demo).

  • If you’re using iOS 9, TextEntry fields now have cut, copy, and paste :wink:

  • The Soda.Control wrapper is now called Soda.Window

  • The drawing function called in draw must now be called Soda.drawing

@hpsoft

If you install the new version of Soda, you can use the new dropdownList entity. Instead of needing 3 elements to create a dropdown list, you can do it in one, like this:

    Soda.DropdownList{
        parent = tvmpanel, x = 430, y = -30, w = -10, h = 40, --w = 340
        title = "Compute",
        text = {"N","I/YR","PV","PMT","FV","P/YR"},
        defaultNo = 5
    }

...

    Soda.DropdownList{
        parent = solverpanel, x = 430, y = -80, w = -10, h = 40,
        title = "Algo",
        text = {"Dichotomy","Newton-Raphson","Intersecting","Regula Falsi","Müller Method","IQI","Brent Method","Conjugate Gradient","Fixed Point Method","Sturm Theorem"},
        defaultNo = 1
    }

...

    Soda.DropdownList{
        parent = convertpanel, x = 430, y = -80, w = -10, h = 40,
        title = "Conversion",
        text = {"Base","Morse","Roman","Unit"},
        defaultNo = 1
    }

@yojimbo200

great job you’ve done, thanks for sharing.

I tried your new version, and I think there is a problem with list, I think not selected properly, you have to touch several times to select it.

Sorry for my bad english.

@Rcv yes, there is a bug with List still, where sometimes it returns the wrong answer. It’s proving to be a tricky one to track down to be honest, because I can’t work out the circumstances in which it fails. Maybe 1 in 10 times it returns the wrong answer. I’ll keep looking at it.

@Rcv OK, I’m pretty sure I’ve now zapped the bug where vertical lists occasionally return the wrong result. Let me know if you still get the bug. Updated code and installer at the github link.

Version 1 of the tutorial is now in the GitHub repository. It’s a separate program, SodaTutorial.lua. Currently it just has 7 steps, taking you through very basic stuff, but many more steps will be added. Here’s a screenshot:

tut

I have not yet tried my example with the new simplified controls
But i have tried soda 0.2 and tutorialsoda 0.2 + dependencies ( with last updates ) functioning very good.

The only problem is always with list. The result is not wrong but i have to type repeatedly my choice ( up to 6 times ) for it to take effect. I have iOS 8.3 and 1GB RAM remaining. Perhaps with iOS 9 it’s work.

If it helps, the problem is more present on the tutorial. ( up to 8 times )

Thanks for your big big work

amazing and cool effect,

@Yojimbo2000 here is the correction for @hpsoft bug report:
in Scroll, line 45, replace

        if self.touchMove==0 then --only test selectors if this touch was not a scroll gesture

by

        if math.abs(self.touchMove)<10 then --only test selectors if this touch was not a scroll gesture

then it works as expected. The problem is that you always move your finger by a couple pixels between BEGAN and ENDED, so demanding 0 is too much.

@hpsoft the wrong-result-returning list bug should be fixed now. Can I ask you to reinstall Soda from the GitHub page? I didn’t post the bug fix until around 6 hours after I first posted 0.2. So it’s possible you have the pre-fix version. I should have bumped the version number to 0.3 when I posted the fix to avoid confusion. Maybe I’ll do that now.

But it sounds like you’re describing a different problem, that the list isn’t having an effect (eg in the tutorial, selecting different options isn’t updating the code and output windows)? Have I got that right? I’m not seeing that at all.

The individual selectors within the scrolling list class have to reject swipe gestures (otherwise you wouldn’t be able to scroll the list without selecting something). I did in the last version make this more aggressive. So if your finger moves at all inbetween began and ended, the touch is interpreted as a swipe gesture (the user wants to scroll, not select), and won’t result in a selection. You have to tap the list to make a selection. For me, this works very well. But I’m very interested to hear other users’ reports. I could turn down the gesture rejection slightly, so that very slight finger movement still registers as a selection (tap) gesture.

i had same bad experience as hpsoft (ipad air). jvm38 correction fixes it for me.

@yojimbo2000. Thanks for the correction in the scrool tab you are posted.
This correction fixed the problem.

This was the problem i have reported. Sorry for my bad english.

Great job.

Thank you again.

with the @Jmv38 correction soda 0.3 is perfect thanks :)>-

Oh I didn’t see @Jmv38 's post. I wrote mine at the same time, and then the page flicked over.

Yes, that’s how to make the scroll gesture rejection less aggressive.

In the previous versions of Soda I experimented with different values there. It used to be if self.touchMove<0.1 (touchMove always has maths.abs values added, so you don’t need another maths.abs when you query it)

@hpsoft could I ask you to try putting 1 and 0.1 (as well as 10 suggested by @Jmv38), and let me know which “feels” best?

For now, I’ll update the code with if self.touchMove < 1.

Thanks to @Jmv38 @hpsoft @Rcv for testing and suggestions

I guess the lesson here is that different iPads (and different fingers!) return different parameters. I guess we discovered this back when we had the “fat finger contest”.

For me with ipad air 128mb and ios 8.3 from 5 it works. but i prefer 10.
it 's catastrophic between 0.1 and 3.
with value = 4 it works one in two.

@hpsoft that’s really interesting. Thanks for the feedback. Ok, I’ll change it to 10.

V0.4 is out, with quite a few fixes and additions. The tutorial is now complete, it covers most of the element types.

Release notes:

v0.4

  • Vertical list selectors now less aggressive at rejecting scroll gestures
  • Lists now have :clearSelection() method
  • Lists now have an enumerate flag. Set this to true to automatically number the items in the list
  • To populate a TextScroll or TextWindow with text, constructor argument is now textBody, instead of text
  • Soda.Alert2 - 2-Button proceed/ cancel alerts have been fixed
  • Fixed a bug in the appearance of buttons in alerts
  • Close button is now a proper X
  • Selector touch logic now greatly simplified
  • Tutorial now updated with all major element types

The GitHub link again:

https://github.com/Utsira/Soda

V0.5 is out at the same link, it now has sliders!

v0.5

  • NEW Soda.Sliders - Sliders can be any length (default to 300 pixels), can be integer or floating point, can have an optional set of “snap points” that the value will snap to, support tapping either side of the handle for fine +/- adjustments, and at slow drag speeds have a cubic relation to touch allowing for up to 1/20,000 accuracy.

  • New, more comprehensive overview of all the elements supported by Soda when you run the program.

  • In TextScroll and TextWindow, method inputString(text) now appends text to whatever is already in the window, instead of clearing the window. New method clearString() clears the window.

  • Panel switching functionality of Soda.Segment now also available in Soda.List via panels parameter

  • Soda.Window can now have optional automatic ok and cancel buttons by setting ok and cancel attributes.

Sliders Sliders