![]() |
|
A question for Steve Terry, Miran, Spellcaster and other GUI people! |
Steve Terry
Member #1,989
March 2002
![]() |
.. Agreed ___________________________________ |
Matt Smith
Member #783
November 2000
|
Not agreed My reasoning is as follows. It is not possible to use a C++ library in a C program, but a C++ API can be wrapped around a C library. C is easier to optimise and debug, IMO My lib is in C, and works fine. OK, that isn't all exactly objective reasoning, but the first point is hard to argue with. |
X-G
Member #856
December 2000
![]() |
Quote: It is not possible to use a C++ library in a C program, but a C++ API can be wrapped around a C library. Some of Allegro 5's internals are C++, and it will be useable with C. You can link to non-overloaded static C++ functions from C, AFAIK. -- |
Steve Terry
Member #1,989
March 2002
![]() |
aigh ok, can it be agreed upon then to have some parts of the GUI in C++ as long as there is NO overloading for C backwards compatibility if it must be done so less work is needed. I'm cool with that idea, but yes we must not limit the audience by using strict C++ code because many will be turned away. I mean that IS the main reason I'm attempting my lib in pure C and it's come a long ways... yet I still have a long way to go. Maybe if someone helps me work on my GUI subsystem aka nas.c, gets relative systems going and some way to do menus/multiple dialogs it'd be good to go. I have an excellent mouse system (at least I think so), I have the font system down with both points accomplished (the && system with TTF and partial strings... I clip mine but I think you mean the ... thing which I have yet to hack out), the skin system could use some help, but it works. But again it's probably best to start over since rewriting the subsytem will probably mean I'd have to propegate though all my other functions and apply any needed changes.. which definately takes time. ___________________________________ |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Signals and slots is where its at -- |
Andrei Ellman
Member #3,434
April 2003
|
MattSmith said: It is not possible to use a C++ library in a C program Another possible way of doing this is to turn the library into a COM object. This is probably overkill and X-G's method may be sufficient, but this is how DirectX works. When I was at Criterion, our game engine (not Renderware, Dive - the one they use internally) was built entirely out of COM objects. We wrote the objects in C++, but they could easily be used by a C program simply because they were COM objects. The downside is that COM only exists natively on Windows (AFAIK), but at Criterion, we managed to create a working multi-platform implementation of COM (at the time I left, we were getting it to work on the Dreamcast). Even with Windows's native COM, it would require quite a bit to get a working COM engine up and running. Another suggestion for the GUI is to write it in C++, but use a C++ to C translator so the end-user can build a C version of the library if they're using C. I know that such programs exist. In fact, the first ever C++ 'compiler' was really just a C++ to C translator that passed the output to a C compiler. I'm writing a GUI as part of Chickens which is being written in C. The GUI is the only part of the code where I think writing it in C++ would have been a lot better. Writing the rest of the game in C feels fine to me. AE. -- |
X-G
Member #856
December 2000
![]() |
You know, both C and C++ are compiled down to machine code by the time you link them anyway - the only problem lies in name mangling, and extern "C" { } will take care of that. -- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
One thing I'll have to note, In the game I'll probably die before it gets done, will use the game engine for the gui.. all scripted and such. Don't know how possible it'll be to use a premade lib for the handling.. probably impossible. Or at the very least improbable. -- |
axilmar
Member #1,204
April 2001
|
Well, personally I prefer C++, but if I am a minority, I am willing to accept C as the language of choice. From what I see, C++ looks scary to some people. C is no problem for me. If we use C, I propose that we do a clever system with classes like the following:
So, classes can be declared like this:
In a few words, this is a C interface for doing object-oriented programming, while at the same time allowing COM-style functionality, run-time object identification, single inheritance, and run-time property management for IDEs. Inheritance works by embedding the super class instance as the first member of the object. Example: typedef struct BUTTON { WIDGET widget; char *text; } BUTTON; In the above example, OBJECT *, WIDGET * and BUTTON * all point to the same object. We could also generalize the signals & slots/callbacks/object events/whatever in the following way:
By the way, we we also need a generalized linked list module, as it is obvious from the above example. P.S.: if you like the above style of programming, let me know. I can finish the module today. |
Richard Phipps
Member #1,632
November 2001
![]() |
Argh, you've just depressed me Axilmar! You're far far beyond me in your programming skills. EDIT: I think it's the way you use C to do C++ things. I just can't seem to get my head around C++ concepts. Even concepts in C like pointers get me confused.. Any chance you can explain what's happening in your code examples? |
Thomas Fjellstrom
Member #476
June 2000
![]() |
RP: You've got to be kidding me, you're totally capable of that -- |
spellcaster
Member #1,493
September 2001
![]() |
I'm not that sure if choosing the C approach will result in any postive results for us. Using aggregation to implement inheritance on that level is not a very good idea, as well. Ok, after all this nay-saying I should try to come up with some positive suggestions as well, I guess What about using a hashtable to store methods and attributes? We could even have different tables for private / protected / public members if needed. But this is just an idea, not sure if it would be practical... BTW, I still say we should stick with C++. -- |
Richard Phipps
Member #1,632
November 2001
![]() |
Unfortunately I'm not kidding... What's aggregation and what's a hash table? |
X-G
Member #856
December 2000
![]() |
Aggregation, in OO, is what's some times call "has a" relation - when a class contains another object. The alternative is Inheritance - "is a". -- |
axilmar
Member #1,204
April 2001
|
Richard: Quote:
Argh, you've just depressed me Axilmar! You're far far beyond me in your programming skills. Please, don't be depressed. Of course each one of us has different skills, according to our experience. If you think you are not at the same level, it's a good chance for you to learn while giving something back to the community. We are all going to learn many things through cooperation. Quote: Any chance you can explain what's happening in your code examples? It's easy: a CLASS struct has all information that describes a class. This information is used to create OBJECT structs, i.e. structs that inherit from OBJECT. The CLASS struct is filled by you, the programmer with proper information. The rest is done by the framework which has 4 main functions: 1) a function for creating an object : 'create_object' Since the framework knows which properties each object has, it searches the class table to find a property (search is done by the property id), then calls either 'set' or 'get' of the found PROPERTY struct. Spellcaster: Quote:
I'm not that sure if choosing the C approach will result in any postive results for us. I don't like the C approach either, but a good GUI needs many hands. So, if it is difficult to find C++ coders in here, maybe we should do it in C. For me, a primary concern is to get it over as quickly as possible, because a good gui for Allegro is long overdue (some years!!!). The VTABLE struct has a method 'get_instance' that is used to query the object for interfaces. |
X-G
Member #856
December 2000
![]() |
If anyone cares, I'm a C++ coder. Not that I'm any good. -- |
axilmar
Member #1,204
April 2001
|
Ok, here is a zip file that contains the object-oriented C framework I talked earlier and an example. If we choose C, I suggest we use this or a similar framework, in order to make our lifes easier... |
spellcaster
Member #1,493
September 2001
![]() |
As said, I coded quite few java widgets sets at work. It's not that difficult once you have basic framework. Starting from java.awt.Container it's normally a 8 week job to create a basic widget set with all widgets needed for your normal digital tv needs. We normally did this in a 4week, 2 persons routine (using your normal 8h workdays). I don't think writing a widget set / gui lib is that much of a problem if one decides first what he wants. The problem with GUIs for game development is normally that the "what people want" part is the most problematic point. IMO, throwing code around right now, is a pretty bad idea. Then we should start grouping them, both inheritance and priority wise. Once this is done, we'll be able to get an image of what we need as a framework. I think most of us (reading this thread) have already a pretty good view of what they want. I also think our views are prety different. Others might prefer the win style. So, i't important that we get a better idea of what we want, before we start thinking about "how we implement it". -- |
X-G
Member #856
December 2000
![]() |
Again, I know this is skipping ahead ... but today I wrote (entirely unrelated to this) another entity system I realized in the end was very similar to how GUI systems group their widgets. A .tar.gz is attached - have a look if you want. No, I'm not trying to hijack the thread. -- |
Richard Phipps
Member #1,632
November 2001
![]() |
X-G!! I could swear at you!! You say you can't do work on your version of Chaos and then you show me some code that I can't even understand! Grrr... On-topic I think that people need to decide C/C++ before they do any coding. |
X-G
Member #856
December 2000
![]() |
That work wasn't for my Chaos clone. If you didn't know, it's listed as Inactive/Abandoned on my page (see sig). -- |
axilmar
Member #1,204
April 2001
|
Ok, here is a list of widgets that I would like to have: 1) button Hmmm...it certainly does not seem as a 2 month job to me, especially if the underlying window and drawing system is not there. On top of it, I would like a programming style as simple as possible: just creating one widget within the other, set a few properties, a few callbacks, and that's it basically. I am thinking towards applications for Allegro, and not necessarily games. Bah, now that I think it, it is too much work, especially for the summer... |
X-G
Member #856
December 2000
![]() |
Okay, I'm going to be critical a bit - see this as positive feedback, because I'm interested in seeing a good GUI lib too, and communication is what makes things better. Quote: 10) raised panel Same widget, different options to change drawing style. Quote: 20) text box Same widget - one can do multi-line, the other can't. Might as well be a flag. One can subclass if one wants, say, richtext features. Quote: 25) combo box Aggregation of button/label, but still a widget in its own ... Quote: 27) common dialogs Aggregation of window and buttons - doesn't deserve its own widget, should just be a static function that creates a preset common window. Quote: 28) bitmap button Add bitmap support to the regular button instead. Quote: 29) message box See #27. Also, I would like to add something like an icon pane (like your desktop, for instance) and a scrollable canvas space. -- |
spellcaster
Member #1,493
September 2001
![]() |
What's a "button border"? Labels and buttons share most of the layout code (position of text and image in relation to another and the area they occupy). Toolbars are just a container with a lot of buttons, but I agree we should have some utilities to allow a quick creation of them. I see no difference between a menu and a pop-up menu. Your normal menu is just a pop-up menu which is shown at agiven position below your menu bar. Ok, so let's group this list a little.
I removed the window and html viewer. Reason to remove the window was that a window makes no sense ATM, since it would be equivalent to a Panel at the moment (Since allegro doesn't allow us to spawn new windows). The html viewer is too much to chew, IMO. If you have the label, the push button is almost done as well. Once the push button is done, the others will follow, since labels and all buttons have just a few minor differences. Most containers are pretty simple as well, since they are mainly aggregations of existing widgets. The most complex widget in that list is the table (or grid) followed by the tree. The other widgets are more or less pretty simply, since they only extend existing widgets, add new functionality by grouping widgets or simply because they have a simple structure.... So, besides the table and tree, the foundation, the event, drawing and layout/resize code is the largest problem. -- |
X-G
Member #856
December 2000
![]() |
I feel no distinction should be made between togglebuttons and regular buttons - "togglable" should be a flag. They both share the same behaviour, and I don't feel such a small change warrants a widget of its own. I'm not sure what you mean with "formatted input field" - if you mean richtext, then yes, it should be its own. If you just mean "format masked", then it should probably be a part of the textbox. What would the different between a Panel and a Frame be? And, as mentioned, the dialogs might as well not be widgets of their own ... a file list might very well be though (a list or iconview that automatically populates by reading from filesystem). -- |
|
|