Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
UIKit plugin example - Page 2 — Gideros Forum

UIKit plugin example

2

Comments

  • I used the Software GITHUB to for this. I got the code thought from your up and it looks like I committed it to your hub again.
  • evsevs Member
    Hello,

    It's probably because the git has Read-Only access.

    I used the fork icon online to create my own repository and I use Mac GitHub to manage it.

    I suppose Caroline would have to grant you Write access for you to commit to her hub?


    Cheers

    evs
  • I don't think it works like that - on reading this:

    http://help.github.com/send-pull-requests/

    I think that a person (@evs) creates a fork.
    evs then does a pull request.
    I receive the pull request and merge the fork with the master.

    We can experiment to see if this works with evs, and then @mikehart, you could create a fork. Or if you prefer to email me the changes, that will be fine too :).

  • evsevs Member
    @Caroline

    Pull requested

    Cheers

    evs
  • @evs - that seemed to work.

    @mikehart - I'm not sure how all this co-ordinates, but you'll presumably need the new uikit.mm.
  • Ok, forked, changed, committed and pull request send. I am so happy that this damn scrollview issue seems to be fixed.
  • Wow!

    I haven't looked at anything related to iOS plugins until yesterday/today. I just read the guide section on plugins and compiled/ran the uikit example. I'm awed by how much work Caroline and Mike have done in his area and how much you guys have been willing to share. Impressive!

    Thanks!!

    --ND

    Likes: gorkem, MikeHart

    +1 -1 (+2 / -0 )Share on Facebook
  • MikeHartMikeHart Guru
    edited March 2012
    Thanks for your kind words. It is still rough and needs some fine tuning but I think it is on a good track. I am very happy that @evs already contributed to it. @Caroline was working on a tableview and I hope she will implement it soon into this plugin.
  • @MikeHart - I'll get there eventually [-O< :)
  • gorkemgorkem Maintainer
    edited March 2012
    @ndoss I'm pretty aware with the fact that beauties of Gideros Studio is not strongly mentioned on our web page. I think if you've just found out this powerful feature, then probably many users out there cannot see it easily as well. I'm preparing a newsletter now, and mention about UIKit plugin there first, and then write a blog post that explains UIKit thoroughly.
  • CarolineCaroline Guru
    edited March 2012
    I've updated this with a very simple table view with a separate Gideros project as an example. You just provide a table, display text in the cells and receive a selected message when the user selects a cell.

    Before I go any further with this, the whole subviews thing needs to be looked at. I've spent some time going over this, but my C++ skills fail me.

    I would prefer that Gideros provides the table view cell with a contentView that has a view hierarchy for the cell, so that it can be totally formatted inside Gideros Studio, however, view hierarchies are currently not implemented.

    One way I tried approaching it was to have a static contentView for each cell, for example holding a Label and an image, and the label text and image could be updated for each cell. So as an example, if you have 10 visible cells, then you have 10 contentViews for which you can provide different text and different image. I attempted holding these contentView addresses in a table in Gideros, so they could be accessed by the event function, but I gave up on this, because holding the view hierarchy there is ugly.

    Having a subview hierarchy will become important, I'm sure, the more people use UIKit. I'm going to have to abdicate from this, because of lack of skills (AKA my brain hurts) :bz.

    Link is still:
    https://github.com/carolight/MHUIKit
  • As you don't want to do this anymore, is there a way I cna take over this hub or do we have to create now a new one? Maybe I can use my fork further for this. :-?
  • Oh, I didn't mean I don't want to do this, but I'm not competent at making those subviews work. I'm quite happy to merget forks from other people.

    However, at any time, we can take down the source from github and upload it anywhere as a new master.

  • Doesn't Gideros use just one OpenGL view? If it did then Gideros would have to have an OpenGL view for each cell, and that would get kinda messy I think. TableView API's seem kind of super complex to me because Apple uses tons of tricks to get them fast.
  • Gideros provides a root view, to which all UI items are attached. The UIKit plugin is using Apple's UITableView, just hooking into the events that the UITableView provides. The UITableView cells perform in exactly the same way as if the app is an Objective C app.

    If I were writing an Objective C app, I would provide a contentView to the UITableViewCell contentView property for each cell, which is what I would like Gideros to be able to do. The difficulty is that I would like this contentView to have its own subviews hierarchy.
  • Does Gideros draw to an OpenGL view or is it drawing using CoreGraphics? How would it handle drawing to multiple views?
  • As far as I can see, this is the way it works, but I could be wrong, as only @atilim knows the internals of Gideros.

    In Xcode, you can look at the loadview() method in GiderosiPhonePlayerViewController.mm.

    This method creates an OpenGL view (EAGLView) and a UIView. The UIView is the main root view, and the OpenGL view is added to the root view. I'm pretty sure that Gideros would be using OpenGL rather than CoreGraphics.

    I believe that Gideros would be using a single OpenGL view to draw on, although multiple views can be done using CAEAGLLayers layer backed views, according to this thread:
    http://stackoverflow.com/questions/4726745/multiple-opengl-views-on-iphone

    When you use any of the views in this UIKit plugin, they are added to the root view. They would appear on top of the OpenGL view, because they are added later than the OpenGL view.
  • Oh yeah I remember seeing this in the Xcode project, so yeah it uses one OpenGL view.

    It would be pretty amazing if Gideros had multiple OpenGL views it could draw to. Instead of one stage you can have many. Well, ok, the reason I think it would be cool is because I want to create a split screen game with 2 different views of the same thing.

    But really, I can't imagine having multiple OpenGL views in a table view. That would slow the tableview down a lot I think. I've done quite a bit with table views and they are pretty complex because they are so flexible with the delegate and data source protocols.

    If Gideros were going to try to manage a table view at all it would probably have to lose all of the flexibility that comes with UITableViews and wrap the cell contents, data source, delegate calls and pick the most probable usage scenerio and generalize around that.
  • But really, I can't imagine having multiple OpenGL views in a table view.
    I can't imagine that scenario - I have had (not Gideros) a number of UIImageViews in a UITableView, and it works fine. I am always surprised how fast these devices process.
    If Gideros were going to try to manage a table view at all it would probably have to lose all of the flexibility that comes with UITableViews and wrap the cell contents, data source, delegate calls and pick the most probable usage scenerio and generalize around that.
    I don't think you have to lose all flexibility - the data source is generally just an NSArray, so my example above just provides a generic table to the UITableView, but the Gideros program could format any table for it. My CoreData plugin provides the same thing to the same table, and I would guess you could do the same thing with the new SQLite in Gideros.

    When providing the data to a cell, for each cell there is a method called in Gideros (the datasource delegate method), so you have flexibility to provide any data formatting there. Currently Gideros can provide only a string, but if/when we work out how to do subviews, Gideros could provide any view hierarchy for each cell. (Not guaranteeing speed, but it could be OK.)
  • atilimatilim Maintainer
    @Caroline you're exactly right. There is one UIView as the root view and EAGLView is the first child of it.
  • atilimatilim Maintainer
    btw, it won't be possible to create more than one GLView because Gideros runtime have some global functions and assumes that there will be only one GLView.
  • btw, it won't be possible to create more than one GLView because Gideros runtime have some global functions and assumes that there will be only one GLView.
    But if really necessary, you could write a plugin with UIViews that use CAEAGLLayers, I guess, just as described in the link at the bottom of the previous page.
  • Btw, people, I didn't mean to suggest that you can't have subviews with the UIKit plugin, only that if you do, the memory won't be managed. Of course, if you've just got a fairly simple hierarchy that doesn't change much, and doesn't need to be deallocated, then you can just uncomment //{"addView", addView} on line 254 in the plugin which allows you to add subviews to any view.

    Likes: atilim

    +1 -1 (+1 / -0 )Share on Facebook
  • atilimatilim Maintainer

    But if really necessary, you could write a plugin with UIViews that use CAEAGLLayers, I guess, just as described in the link at the bottom of the previous page.
    Oh you're right. I mean you cannot use Gideros in these views, only use OpenGL directly.
  • Hi, I'm new to Gideros and I have just downloaded this ui plugin and tested it. It gave me a warning of "main.lua:24: module 'ui' not found:" , can anyone tell me where I can get the ui file ?? Thanks~
  • CarolineCaroline Guru
    edited March 2012
    UIKit is for iOS only.

    1. You need to have the GiderosiPhonePlayer project open in Xcode.
    2. Add the uikit.mm file to the GiderosiPhonePlayer project.
    3. Run the GiderosiPhonePlayer project in the simulator (or device if you are paid Apple developer).
    4. Check the wireless settings on the simulator white screen, and set the wireless setting in Gideros Studio project.
    5. Run the Gideros Studio project, which should run in the iPhone simulator.

  • P.S. - welcome to the forum @kit2000usa :).
Sign In or Register to comment.