Cider -- interface builder / code generator

Thanks. You know, if you want i can put your code in my website, with the downloader i have used recently. So you dont have to worry about github (which seems to have the hidden characters problem, i had to remove them from Mark gist) If so you could just send me the text file by mail. Let me know.

I already archive to DropBox and SkyDrive…just looking for a better source code control method; I’m basically only doing. Source code archival.

@Jmv38. Nice to see someone using the code.

TextBox obviously needs a major rewrite. I’m planning a version that better handles multiple lines, cursor position, and copying to a “clipboard” (even if it’s one that only works within the app).

I’ve done some minor fixes on TextInput; I wanted to get that one fixed before even looking at TExtBox; that’s got a lot of good work in it already that I didn’t think I could reproduce…

Can anyone tell me why only a blank dark screen shows up, after I copy the Cider 1.5 code into my Codea?

You’ll probably still need to add the library dependency, or you have to have code that uses the controls. What does your main() look like?

Hi @syrswr you probably have the devillish ‘black screen bug’…
Dave 1707 solved that:



-- fix the black screen problem by dave1707

function setup()
    project = "forum_cider_controls"
    projectTabs = listProjectTabs(project)
    for t = 1, #projectTabs do
        fix(project..":"..projectTabs[t])
    end
    print("finished")
end

function fix(name)
    count=0
    str=""
    a=readProjectTab(name)
    for z=1,string.len(a) do
        s=string.sub(a,z,z)
        if string.byte(s)>142 then
            str=str.." "
            count = count + 1
        else
            str=str..s
        end
    end
    saveProjectTab(name,str)
    print(name,"fixed",count)
end 

run that code (adapt the ‘project’ value to your context).
I had the same problem, thix code fixed it

.Jmv38 thx! It works.

I’ve just done a fairly sizable update to Cider.

o Reworked appearance on all controls to bring them closer to the design of Apple’s standard UI elements

o Reorganized interface with controls split across multiple pages, providing room for labels and most importantly, more controls

o New SelectList controls provides a list of items, similar to the grouped controls in Settings. Works as either a list allowing multiple selections or a list where only one item can be selected.

o New tab strip control — Cider uses it, and so can your designs.

o Improved properties dialog with better access to control properties

o improved code generation with more optional properties

o Bug fixes and minor refactoring abounds

Cider Controls

https://gist.github.com/devilstower/5384106

Cider

https://gist.github.com/devilstower/5384102

Quick Peek

http://www.youtube.com/watch?v=oHqNLMsGXF4&sns=em

@Mark - very nice. I just used Cider to demo my audio add on tute. One suggestion, I was expecting the controls to be (x, y, width, height) rather than (left, bottom, right, top). The results are obviously the same but (x, y, width, height) is more consistent with the other Codea controls.

@Reefwing left, bottom, right, top is just so ingrained for me that I have a hard time even thinking about it otherwise. Just seems so much neater when you need to place multiple controls together on a screen.

That said, it’s always great to see someone actually using the controls.

I’m definitely planning on grabbing your audioplayer for an update of Bull Puckey, How can BP be the next Angry Birds without a catchy tune?

@Mark, great update! The controls look better (and I’ll have to see what I can optimize from the original release :slight_smile: and I like the tab strip ontrol.

As an aside, I agree with the comment made by @Reefwing; direct screen coords are a little hard to conceptualize unless you are only doing screen work, which in Cider’s case makes sense.

In Cider2, I didn’t use explicit coords and CORNERS drawing because all of my windows are offsets and context-based, so explicit screen corrds are really hard to conceptualize…and Codea doesn’t use that coord system either.

I cant seem to get the callback to work. If I pass the callback name with () as in test_Callback() it will run it one on load but a tap of the button does nothing. If I just pass the name test_Callback I get nothing.

@Briarfox, post some sample code.

Generally, you don’t need the parens unless you are passing a parameter (you are not) or defining a function (again, not here).

It’s possible that you are trying to call something that you didn’t define or you might be calling a function from a class instead of an instance of a class.

Also, button tap means that you have to have code in your touched() function to check for the button press, so you should have:

function touched()
btn:touched()
end

Until we can see some sample code, we can’t help a lot…

@aciolino same example as Jmv’s up a bit in the post. Just using a text box and a button. the code generated test_Clicked as a call back.
If I use:

button1001 = TextButton('Press Me', 300, 440, 430, 480, test_Clicked())

it will run the callback on start but only once. Without () it seems to do nothing.


-- Generated by Cider
--
-- Add CiderControls as a dependency
--

 

displayMode(FULLSCREEN)
 
function setup()
    textBox1000 = TextBox('Text Box', 260, 540, 450, 590)

    button1001 = TextButton('Press Me', 300, 440, 430, 480, test_Clicked)

end

function draw()
     background(194, 194, 194, 255)
     textBox1000:draw()

     button1001:draw()

end

function touched(touch)
     textBox1000:touched(touch)

     button1001:touched(touch)

end

function keyboard(key)
    if CCActiveTextBox then
       CCActiveTextBox:acceptKey(key)
    end
end

function test_Clicked()
    print("Hello World")
    sound(SOUND_POWERUP, 15118)
   textBox1000.text = "Hello World" 
end
  

The code looks right. You’ll need to look at the TextButton class to make sure that it’s got something like (paraprasing)

if self.callback ~= nil then self.callback() end

it’s also possible that this should say “self.callback(self)”, can’t recall exactly.

Also, make sure the Control class stores the callback, otherwise you won’t get anywhere. So in the top of Control:init() you should have:

function Control:init(s,left,bottom,right,top, callback)

and you should also see at the bottom of the initializer:

self.callback = callback or nil

if you see all that, try to do a print(button1001.callback) and see if you get a nil or a table: value. a nil means a bug in Cider, a table: value means that we’re not calling it correctly.

@aciolino All appears to be correct, I’ve recopied the cider controls and cider into new projects, same issue. @Jmv38 did you have any luck getting the callback working?

No i didnt. I am focused on recoding my own lib with classes and subclasses for the moment…

Sorry, I apparently typed over a line in this version.

In CiderControls, go to the TextButton tab then find the touched function. Insert this line right above the line “return true.”

if self.callback ~= nil then self.callback() end

Lol - think that’s what I typed earlier :slight_smile: