What 2D GUI Foundation Do You Use?
Zmee writes "I am looking to build a 2D application for personal use and I will need to use a canvas to paint custom objects. I am trying to determine what foundation to use and have not located a good side-by-side comparison of the various flavors. For reference, I need the final application to work in Windows; Linux is preferred, but not required. I have looked at WPF, Qt, OpenGL, Tcl/Tk, Java's AWT, and others. I have little preference as to the language itself, but each of the tutorials appear to require significant time investment. As such, I am looking to see what the community uses and what seems to work for people prior to making that investment."
HTML and Javascript?
Microsoft Foundation Classes
Have you checked out vpython? not many people have heard of it and I find it quite usable.
OpenGL is portable across all platforms, hardware accelerated, and lightweight. Win, win, win.
Qt would be my next choice but it's not lightweight at all. You can always wrap your OpenGL app with Qt for extra "GUI stuff" if needed. OpenGL works with practically everything.
GDI+ is good enough for low frame rates and trivial to use if you have any C# experience. If these are static controls that need to be painted and then updated on user input, it's more than sufficient.
Nothing is easier for amateurs, even though I'm no Microsoft fan.
Design your application to modularize the OS-dependent code away from the OS-independent code. When it comes time to port (if it ever happens) you should only have to worry about the OS-dependent stuff with minimal modification to the core of the application.
If you aren't a Flash-hater:
The IDE isn't free...but the SDK (including all the GUI widgets) is, under MPL. While the traditional usage is browser-based (iFoos excluded), Flex can also produce Windows/Mac/Linux executables that run top of on their AIR run-time (similar to .NET or Java's) :
http://www.adobe.com/products/flex/
A quick tour of what's possible: http://www.adobe.com/devnet-apps/flex/tourdeflex/web/
You haven't provided nearly enough information. Are you talking GUI interfaces, or rendering? If rendering, is it raster or vector? If vector, then what primitives do you need? Full SVG? Is this real-time, and if so, how many polygons / pixels do you need to push and at what minimum framerate?
As a totally shoot-from-the-hip, off-the-wall recommendation, I'd say OpenGL for portability, including support on iPhone / iPad / iPod touch. Note that you'll want to stick to the OpenGL ES subset in that case.
Better known as 318230.
Don't have much experience with GUI, but if you need to draw stuff, I found Flash+ActionScript to be pretty easy to jump into, w/o much tutorialling (though this was 7-8 years ago, no idea what's going on with it now; don't even know if there's a free version for non-commercial users of flash).
weinersmith
I'd use Java AWT or OpenGL. They're both cross-platform, and what you learn will can be easily leveraged elsewhere, since they're widely adopted technologies. (No matter what you pick, you're going to have some learning curve.)
FLTK (www.fltk.org) is still in active development and is my cross-platform toolkit of choice - C++-based, easy to use, and works on Windows, Linux, and Mac OS X with ports for other platforms available.
I print, therefore I am.
You might want to look at SFML, its cross platform and 2D oriented and works with a number of window toolkits: http://www.sfml-dev.org/
I would recommend OpenGL because its flexible, efficient, and cross platform. DirectX is a lot easier to use for 3D graphics but for simple 2D stuff I wouldn't mind using OpenGL and it's worth it for the benefit of being cross platform.
QT 4+ has been pretty decent. It has bindings for most languages and is really nice to work with.
Out of everything I've tried (pretty much everything usable from C, C++, and C#), WPF is the best UI framework around. It is extremely flexible and can be very intimidating if you try to learn all the details too quickly, but the basics of it are easy. You should be able to pop out a good design pretty quickly. It's a shame that Mono has no plans to implement it, because everything else feels primitive in comparison.
If you don't mind dirtying your C++ with a less-than-modern design and ugly preprocessor hijinks, Qt can be a pretty solid framework. Works well on many platforms and is full of features. Has a lot of portable non-UI things too, but I haven't used much of it.
Python's UI stuff is simple but has a lot of features. Great for quick, portable apps. Easy integration with C++ if you need it.
I avoid wxWidgets. The last time I tried using it (about a year ago), I ended up very frustrated rooting around their code to find that it makes a bunch of stupid assumptions about things like DPI, default fonts, etc. that fall apart pretty easily.
I also avoid GTK, but mainly just because it always feels "off" on Windows.
Having used everything on the list and much more (such as wx, GTK, etc), as well as making my own toolkits for embedded devices and products, my personal experience tells me hands down that Qt is the best choice for anything GUI related. It's power, ease of use, tools, documentation and learning curve are unparalleled to this day and age. Any other toolkit or API I've use fails in one or more of such areas.
Qt is the only toolkit that made me feel as if they could know in advance everything i'd ever need (so when i go to the docs it's there, right how as i imagined it should be), yet keeping the bloat down with great modularization. I have used it from C++ as well as from Python with great success.
I'm personally a fan of .NET, mainly because the toolset goes a long way towards making development easy. Consider: You start the Visual Studio C# IDE, create a new Windows Forms application, then use a simple menu selection to create a new User Control class. You are given a canvas and can immediately begin adding existing controls to it, and if you want to custom-draw the whole thing then you just use the Events tab of the Properties window to create a handler for the Paint event. The paint event handler's args give you access to the control's canvas, and you're off and running. The IDE adds your custom control to the Toolbox, so you can just drag it onto a form to create an instance, and a good portion of it functions in design mode so you can check it out before you ever actually run your project.
.NET, and Visual Studio and MonoDevelop, to speak to how easy or difficult it really is to do Windows/Linux cross-platform development with it. Yet.
It doesn't get any easier, I think.
I've begun learning Mono. I don't know enough about the differences between MONO and
Fun with Anagarams! LADS HOST, SHALT DOS. HAS DOLTS. AD SLOTHS, HATS SOLD. ASS HO, LTD.
I use the Qt framework at home and at work and I have published a couple teeny GPL'd apps:
Regardless of which framework you decide to use, I wish you luck!
I have extensive experience using Qt under both linux and windows (5+ years), as well as WinForms. However, for the last year I've been using WPF and I think it's a dream. Granted, there are cons to it and if your bottom line is performance in all situations (e.g. this is a game) then I would avoid it. They talk a big game about high object counts, but it requires extensive virtualization and time and then it still might not work depending on what you're trying to do. That being said, WPF's use of binding is fantastic and if you do a little bit of homework on binding I think you'll be pleasantly surprised. Don't get me wrong, I love Qt (and C++ for that matter!). But for the amount of stuff I need to crank out, it's tough to beat WPF. One last caveat: I wouldn't count on Mono to bring your apps to linux. I've only spent a little time with mono, but unfortunately (in my opinion), the linux community seems to have largely shunned C#, .NET and all that goes with it.
even opengl :)
you could build something on top of them, but its a lot of wasted effort
You want to use
http://www.tkzinc.org/
http://www.wxart2d.org/
http://www.box2d.org/
or the like
I was about to reply some pros&cons and that in the end all frameworks have their limits and how if you try something else than asking for a birthdate in a textbox and outputing the age in another when the user hits a button you'll spend hours and hours tweaking little details (why won't it let me put an icon here! Why won't it align correctly!)
But I re-read you question and you talk about re-writing all the GUI yourself, so I don't really understand why you need a UI toolkit to start with. But you probably have not phrased your needs completely.
Anyway, the obvious answer is to try WPF for Windows if your app is for Windows.
Python is a language with bindings to various gui toolkits like Qt/wxWidgets/Gtk2/Tk ... even WPF with IronPython. It doesn't have UI stuff of its own. You know nothing.
If you want 'easy' with a slightly 'limited' set of options long term, then I would say Windows Forms in a .NET language, use Mono rather than VisualStudio so you have a much easier chance of it working in Linux out of the box, and most likely OSX, FreeBSD and several others in the process. Its not required, but Mono's code completion will point you in the right direction where as VisualStudio is going to point you more towards MSy things. Though VisualStudio is much more enjoyable to use in my opinion. If you've never used either, its not likely to matter for a while I suspect, though on OS X, Mono seems to miss most initial clicks I send to it, could just be me.
That will give you all the basic controls an application gui will need and make it so you can reuse the massive amount of examples out there.
For your custom painted widget its a little different. What kind of painting are you doing?
Is it something that lends itself to OpenGL really well? If its fits well into geometric primatives, then I would go with OpenTK's OpenGL Control. Works pretty good in my experience.
How often does it update the displayed data? Is it a game/animation kind of thing or are we talking about something that renders once after the user changes a setting?
If you need a high FPS on the updates, you're going to want to use OpenGL with textures for displaying the rasterized data. You're learning curve will be a little steep I think if you're starting from no knowledge, but its probably your only solution for something that needs to be fast (I'm just flat out ignoring DirectX, which for Windows would be easier than OGL but would cut you off of Linux and the advantages on Windows aren't that great really)
If you have real slow update rates, then you could just throw a image control on a form and paint the pixels yourself one at a time, or load images from a file/resource.
If this is a project that has a long expected life and will become rather complex and need high performance eventually, then you're probably going to do it wrong the first time no matter WHAT you do now, at least, thats my experience. I never get it right until AT LEAST the 3rd rewrite :/
Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
Stop suggesting various toolkits, that is NOT what he is looking for.
He is looking for a "canvas" widget, meaning he wants drawing API.
It is unfortunate that most drawing apis are tied to particular toolkits, so he may have to choose one, but if you are comparing them you have to compare the 2D drawing primitives.
There is also Cairo and OpenGL, which are not really tied to toolkits. Though you still need to jump through hoops depending on the toolkit to get it so the graphics calls draw where you want. Sigh.
I second the parent post. However, in my opinion, OpenGL only is pretty tough to use. It takes a lot of knowledge. (GLUT can help to get you started.)
Where OpenGL would require you to program too much functionality from scratch, I personally recommend QT, using OpenGL only where you need it. QT is easy to learn, easy to code for, provides *tons* of functionality, and it performs great. In fact it performs well enough for very heavy 3D animation software to rely on it. (Maya has now been rewritten to use QT, and it is a big improvement.) You can paint your own custom anything, and even easily integrate 3D into your project. I really can't say enough good things about QT. It is now available under the LGPL, so you can use it for open source or closed sourced projects.
As mentioned above by the parent, QT isn't lightweight, but it isn't a pig either. You can use as much or as little of the toolkit as you like, and it can run very fast and have very low overhead. It is light enough that Nokia is using it as their primary development framework for mobile apps with their upcoming Meego based phones. From my personal experience QT flies.
Also, I've had great results with PyQt and with PySide. PySide is the new, "official" binding for QT on Python. They have examples in their demo folder of custom canvas based applications, and they work great and are easy to follow. You can have your own similar program, written from scratch in Python, up and running in 10 minutes.
It should also be noted that because QT works so well cross-platform, it has a huge advantage over toolkits that are tied to a single operating system. (Particularly those from MS.) In my own work, I won't even consider using something that doesn't run on Windows, Mac, Linux, and potentially more operating systems. I use all kinds of devices, and I don't want to be tied down. QT makes cross platform development straightforward, and software like Autodesk Maya is proof that it works even for highly complex projects.
I know I'm starting to sound like a salesman, but my experiences really have been that positive. About the only downside is that there aren't current C# or Java bindings for it. This doesn't matter to me though, because I've got C++ where I need performance and Python where I want ease of use. (With Cython, you can easily have performance and ease of use at the same time.)
I hope that helps.
I am looking to build a 2D application for personal use and I will need to use a canvas to paint custom objects.
Not enough info, really, but I'm wondering if you've considered making this a web app; then it would be compatible with anything with a modern browser.
I've done a lot of programing but not a lot of UI work outside of the browser (where most of my user interaction has been). However, I've found that the JAVA SWT to be "okay" for desktop GUI apps. Sure, it isn't as flexible as opengl or javascript/html(xml)/css, but it gets the job done for your standard inputs and outputs. If you want to do something fancier than the most basic 2d graphics (or minecraft-like 3d) you won't like it and neither will your users.
Mostly what you should ask yourself is "Can a browser do this?" and if the answer is no (sounds like it is) then ask, "Do I need anything fancy?" Those two questions will drive your decision.
Good luck. Dealing with the GUI is an order of magnitude more fiddly than all the algorithms work you will ever encounter. I should know, I'm marrying a graphics designer ;)
md5sum
d41d8cd98f00b204e9800998ecf8427e
Been using OpenGL and FLTK for a project for a few weeks now. Hope I never have to use anything else.
As you have noted, it does take a commitment to learn any system. For personal projects where you answer to no one else, you should use whatever you think will be useful to know in the future. The factors involved are: what will be used for future projects at work, how important is cross platform programming, and what looks good on a resume.
For cross platform work, Qt is the way to go. Or Java I suppose, but I have found myself moving away from that language. Not for any ideological reason, I've just had a few frustrations with it over time. But you can't argue that it can be handy for the resume.
Alternatively, if you are interested in web programming, then it is amazing what you can do using HTML (especially HTML5 with its new canvas tag). If you are after a full screen application, then you can try the kiosk modes in Internet Explorer or Firefox. IE doesn't support HTML5 yet, so you would either need to limit yourself down to HTML4 can provide (which still isn't bad) or use Firefox.
If you want to learn a language that has a compiler installed by default on the majority of computers in the world, then C# is the way to go. While Visual Studio makes it easy to generate the user interface elements, it is also handy to know how to use the language in straight vanilla code so you can use the command line compiler that comes with the .NET runtime. I have knocked out a few quick hacks on other people's systems just with Notepad and C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe.
Who suggested Java AWT? What is this, 1998? Someone is behind on their homework :).
Java's Swing + Java2D is *fully hardware accelerated* (ever since Java 1.6.0_u10 some time ago), multi-platform, with good multi-thread support (not for rendering, you don't need that, but for the rest of the program), very customizable, and looks fantastic with the Nimbus look&feel (a standard part of Java). Swing is used a lot on the enterprise desktop (and a few shrink wrapped products too - I know I've purchased some as they were best-of-breed tools). Many of the Java Swing ttools are free and there are a lot of them (eg. Matisse in Netbeans makes creating GUIs a snap). Java2D had extensive contributions from Adobe who happen to know a thing or two about presentation. Plus, drawing in Java2D also allows printing relatively simply.
I haven't got a clue what kind of app you want to write, but have a look at Processing.org .
It's an abstraction layer built on top of Java (cross platformity, including web browsers).
It has loads of handy stuff for 2D and 3D, including OpenGL.
Talking about OpenGL, you can use it in it's raw form as well.
In fact, you can just write in Java afaik.
I found it very usefull for making custom ui's.
Its why I said
http://www.tkzinc.org/
http://www.wxart2d.org/
http://www.box2d.org/
There is also
http://antigrain.com/
Heck, depending on his real requirements, a branded copy of firefox3 with plain canvas (or WebGL) might be enough (with jQueryUI/YUI/Google Web Toolkit)
If you want to run on different platforms, my choice would be Java and Eclipse SWT... you have a platform dependent library to send out with your app, but your app code itself is platform independent.
Logic is the beginning of reason, not the end of it.
How about HTML Canvas with Javascript? That way it works on any platform so long as you use a modern web browser...
There are also a few nice JavaScript 2D libraries out there (google it).
Having no clue what you're looking to do, a modern web-browser, or next-gen with graphics accelleration, may be sufficient. I wouldn't suggest it for anything too significant, but between SVG, and general web graphics stuff -- something like imagemagick or yoru favourite command-line image processor -- most interfaces are fairly easy, and a very low learning curve. Heck, in IE you can even transform them with a matrix operation. You'd be using javascript for animation and logic.
I use QT and love it too, but it has some serious drawbacks, from my perspective. The biggest is that it requires a wonky special compilation system. You either have to use the build system they offer (qmake) or you have to manually run their generator yourself (moc - though if you were a masochist you could learn to write out the files moc makes yourself and avoid using it).
I compare every IDE to Eclipse, because that's the best IDE I've seen for any language. But I've never found that CDT, the C++ plugin for Eclipse, is any good. It fails to work out of the box for me and is a pain to configure (but I haven't tried it in a few years). QT Creator, while usable, is really an immature product. There's no support for refactoring, the UI is unintuitive and awkward (for me, at least) and there's lots of little issues with it. Plus you're committed to MingW, which can be a problem depending on what libraries you want to use. Codeblocks is a pretty good IDE, but it doesn't have a QT plugin, so you're left with the problem of dealing with moc files. Visual Studio has a plugin, but it only works with the paid versions.
All of this can be dealt with (and I do) but it's annoying.
Seconded. Windows Forms is easy to learn, powerful enough to use for most GUI work, and if you stick to the classes that work in Mono, it's cross-platform with little if any changes required.
Visual IRC: Fast. Powerful. Free.
Adobe Air -
Easy UI interaction framework, very powerful drawing APIs, runs on windows/linux/mac/android.
http://www.adobe.com/products/air/
Latest version lets you call native apps on windows/linux/mac.
HTML, CSS, JavaScript, jQuery, exCanvas, HTML5.
Sooner or later some potential buyer will demand your app to be on the web. It doesn't matter what kind of app it is. For desktop use, put a browser plugin in an empty windows shell and you are done.
I don't have much time... I write the GUI, and any drawing logic with Tcl/Tk. Easy, portable. Any time critical or extensive logic gets pushed into C or FORTRAN (depending on what it is). Just standard in/standard out. Parse the output with Tcl, and display.
A recent example -- I needed to upgrade some systems for a client (Solaris 6 to 10). We needed to identify the binary parts (non-OS) that needed to move. I wrote a GUI tool (binport) for this. Took 2 days to write, ran on Linux and MacOS X (two of us shared the work). After the job, the tool was essentially discarded.
No time to "debug" really, and I don't typically have time for compile and test cycles. Tcl is an interpreter, with very simple syntax and semantics.
Other examples that have used Tcl/Tk -- the GUI layer for GDB, Redhat Source Navigator, etc.
Yes, it's not "sexy", or even particularly "new", but it works, and works well.
Just another "Cubible(sic) Joe" 2 17 3061
Java/AWT pro: tends to work on all platforms. con: your app generally tends to look bad on every platform.
Java/SWT: pro: tends to work well on all platforms. con: you might have to drink the eclipse kool-aid
Tcl/TK: It is a silly language. You don't want to go there.
OpenGL pro: "gui" portion tends to work on all platforms w/tweaks. con: hard to work with unless you adopt some toolkit.
In practice, however, if you really only care about Windows, write windows native code and allow WINE to take care
of the rest.
Windows GUI stuff is best done in C# .Net.
Cross-platform GUI stuff is best done in either DHTML (with an appropriate widget library like jQuery UI) or in some circumstances, Java Swing or SWT.
That said, if this is personal project then you should probably pick whatever GUI toolkit is most popular for the language that you know best.
The EFL begins with Evas, our canvas library. Because Evas is built on several different selectable engines (Linux FrameBuffer, DirectFB, X11, OpenGL/OpenGL-ES, QTopia, etc) the platform is extremely portable, which translates thru to all of the libraries built on top of it.
Hey, if they were good enough to run a Brazilian fridge, they should be good enough for you. Seriously though, you should take at look at the EFL. They are flexible, powerful and efficient. There will be a learning curve with whatever libraries you choose to use. You might as well get something wonderful in return for your investment of time and energy. You want the efficiency of OpenGL without the limitations? You got it.
We don't see the world as it is, we see it as we are.
-- Anais Nin
If the OP is looking for a Web-based GUI, then consider OpenLaszlo (http://www.openlaszlo.org/).
Fantasy: http://ferrisfantasy.blogspot.com/
Then stick it to your monitor.
I use Adobe AIR. It's got both standard components (buttons, checkboxes, etc), as well as 2d and even 3d APIs for drawing custom components. You can draw stuff programatically or you can use Flash's tools. The exact same code runs on Windows, Linux, and Mac too. I don't know what sort of 2d custom objects you need, but I've really enjoyed working with it.
Tcl/Tk, Swing, and (for mathematics) the Matlab GUI served me well (even if the latter one is single-threaded and awkward, its a productive and stable environment).
Intel has sponsored development of Clutter for MeeGo. List of features from that site:
* Scene-graph of layered 2D interface elements manipulated in 3D space via position, grouping, transparency, scaling, clipping and rotation.
* Animation framework, providing path interpolation, transitions and other custom effects via implicit animations.
* User Interface definition format, based on JSON, for describing layout and animation.
* Advanced input event handling, including multiple pointing devices.
* Custom Pango renderer providing efficient internationalised UTF8 text rendering through OpenGL.
* Support for high end OpenGL features such as Shaders, FBO, VBO and PBO through a low-level, object oriented abstraction API.
* Support for media playback with GStreamer, Cairo graphics rendering, GTK+ embedding, Box2D physics engine, etc.
* Object oriented design via GObject with a familiar GTK+ like API.
* Runs on Linux, Windows and OSX with native backend window system support for GLX, EGL (both on X11 and framebuffer surfaces), WGL and Cocoa.
* Support for mobile devices with fixed point internals and portability across Open GL, OpenGL ES 1.1 and OpenGL ES 2.0
* Developed in C, with language bindings for Perl, Python, C#, C++, Vala and Ruby.
need the final application to work in Windows, check
runs on linux, check
can be used to build 2d apps, check, lots of games and utilities to attest to this
"will need to use a canvas to paint custom objects", i'm truly not sure, i just play the games, could someone else address this point on whether it includes a internal paint app or if you have to import images from another product?
low initial time investment, again not sure though i know there are some tutorials on newgrounds and such, otoh such tutorials are more focused on games
hope it helps
It has only 0.78% market share, just use Windows development tools like the 90%+ of normal people who get laid instead of fleshlighting to tentacle porn.
You may as well. Toolkits are the bane of human interface design. Each one behaves differently.
>80 column hard wrapped e-mail is not a sign of intelligent
>life
Most portable? OpenGL. Has the benefit of not requiring huge libraries ala Qt. Consider sticking to OpenGL ES 2.0. Most useful? Quartz/CoreGraphics. Not a portable choice of course, but a good drawing toolkit none the less.
I have recently begun looking into developing for the iPhone and similar mobile devices, with a desire to be able to draw arbitrary diagrams/images/etc. I honestly did not notice how far the Javascript and HTML stuff had come along in the recent versions of browsers. With the addition of the canvas tag to most popular browsers, lots of useful applications are now feasible without heavily relying on the server-side for much.
While I wouldn't consider myself "old school", the bulk of my HTML coding skills were picked up by extensive use of the "view source" option of Netscape in the mid-90's. Javascript/Livescript were of limited use back then, by comparison. Newer web browsers combined with tools like JQuery and JQueryUI make doing all of the dynamic HTML stuff that was a nightmare only a few years ago, fairly tolerable for web applications.
In summary, unless it is just a horrible fit, I plan on targeting web applications when possible. I'd suggest you at least give it a look....you might be impressed with what is now available and possible.
Personally I prefer Java + Swing. Add Java2D and you have everything you need. If you want it to look native, there's a way to do that. It will run everywhere Java is available and since you say this is a personal application you don't need to worry about end-user problems. Plus, if you ever want to get it to work on Android or Blackberry phones then you'll already have a head start.
I'd also recommend using SpringLayout, it's the simplest way to get things looking right.
It really doesn't matter which one you pick. They all have strengths and weaknesses. Choose one and become an expert.
No matter which one you pick, I promise you it will be the wrong choice, and you will eventually come to understand why it is wrong, and you will pick a different one. Then you will lather, rinse, and repeat. In a decade you will come back to your original choice, and you will understand that it is your best answer because it's the one you know backwards and forwards.
http://cappuccino.org/
http://www.gnustep.org/
http://www.cocotron.org/
All three offer great 2D drawing canvas, NSView/CPView, as well as standard high level GUI objects and rich text. See CoreGraphics or DisplayPFD
HTML, CSS, JavaScript. Turn you app into a webapp. Easier learning curve too. Maybe GWT.
From experience, Qt has a fantastic 2D painting API. You weren't clear as to what you were talking about with respect to 2D, so I assumed widgets are not important.
Qt widgets, on the other hand, suck. HTML + JavaScript has better widget support. In my humble opinion, shipping a commercial Qt app, the lack of polish really gets to you.
Really, its all about QT. Cross platform, extremely functional, easy to use, fast.
OpenGL is portable, but I would think that development effort (less of it) is more important than squeezing out every last bit of performance and exponentially increasing development time with OpenGL.
I would also say that you should only really be looking at Windows, OSX, Linux here, because if you want to develop for Ip*[d,n][$,e] or android that your interface is going to be very specific to the device and that cross platform isnt really an option for the interface. touch on ipad vs ipod vs android vs mouse on Win, Linux, OSX suggests that the interface cannot be good on any if it works on all.
...to get to a psychiatric ward and have them rid you of your delusions of being able to extract the few answers toa question like this on slashdot which:
1) Are actually intelligently given with reasonable knowledge of the subject.
2) Pay attention to what you are looking for.
Just saying...
I usually go for a X-Y rectangular coordinate foundation, though sometimes I try polar, which is pretty cool. Wait, what was the question?
I had the same dilemma, except I also knew I would eventually add 3D graphics as well. I wanted it to be portable to anything, and I needed it to render accurately and with proper anti-aliasing (anti-aliased while drawing, not via a filter after the fact). After mulling over all the options, I came to a difficult conclusion: write it myself. This is more work than I'd like, but it allows me to ensure it will run on anything, anywhere. If something new comes out that I want it to run on, I just port to it; I don't have to beg a vendor for it to be ported for me. Performance isn't paramount to my application, so I can put enough abstraction layers in to make the porting process relatively easy. All frameworks seem to put performance as the highest priority, which gets rid of the ease of portability. If your application will render graphics that sit still most of the time, this may be your best option (assuming you know linear algebra if you want vector graphics, and know graphics programming regardless).
This option worked for me.
Qt has recently introduced Qt Quick, a collection of technologies meant to help you create animation-rich UIs similar to those used on touch phones. The most important part is the QML language, which is used to describe the user interface of a program. QML is declarative and animation-friendly, and makes it easy to create fluid interfaces. On the downside, it is not mature yet and lacks most of the standard UI widgets at the moment (basically, you have text input and clickable areas). I wouldn't have recommended it for general application writing just yet, but the original question was not very specific on the requirements so it might be suitable already in its current form.
Why don't you try the HTML 5 Canvas?
HTML 5 is an emerging technology (or rather a set of technologies), and since it's a personal project anyway, you'll have a good opportunity to learn something new.
Once the technology matures, and your project is finished, you'll be able to disclose your application in most modern browsers (including Safari on iPhone, iPad, etc.)
He wants to draw 2D stuff on a canvas.
What kind of 2D stuff? You want to draw individual pixels? Generate bar charts? Animate anti-aliassed splines? Interactive objects?
If you're after only the most basic without any real need for performance, then use whatever you're already familiar with.
Otherwise please specify what kind of features you want from the 2D framework so you won't have to wade through dozens of replies advising this GUI toolkit over the other GUI toolkit even though the word GUI isn't even mentioned in your question.
Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
It's hands-down my favourite. I've come full-circle back to this one, after going GTK+, Java Swing and others. I was amazed at how much this lovable, small toolkit has advanced in the meantime, without becoming more complicated. Watch the others (e.g. GTK+) going full-bore the way of the XML: they are becoming more and more denial-of-service attacks, towards us and towards our computers.
Tcl/Tk still remains to me an example of good engineering. Definitely worth checking out.
Any new tech is going to require "considerable time investment" to learn. You aren't dodging that bullet either way.
That said, going for something high-level will at least save you some time in the long term, once you get past the "getting started" stage. Which, in my opinion, leads to three practical choices, given your constraints: JS & HTML5 canvas, C++ & Qt, or C# and WPF.
Of those three, WPF is likely the easiest one if you need vector graphics and various transforms, with Qt a close second. You might also want to look into Qt Quick, which is not all that dissimilar to WPF in concept, and uses JS for scripting - though that is very new stuff and there may be few good learning materials about it.
Go ahead, mod me down. You know it's true.
Go for Qt/C++. Your application is then available for Windows, Linux, Symbian and Maemo/Meego. Qt Creator is great tool to make user interfaces and using WRT is something to take a look at also. For a quick start go to http://qt.nokia.com/downloads and see some tutorials.
How about Clutter? It's implemented in C, but has bindings for C++, Perl, Python, and Ruby, among others, and it makes it pretty easy to create custom animations. The documentation looks OK, and it'll work on Windows, OS X or Linux.
Or you could go the web direction and use XUL (based on xulrunner) and SVG to paint. Fast learning curve.
Having used a variety of GUI toolkits under different OS (AWT, .NET, MFC, Qt, OpenGL). In my opinion the most important thing to have is a good GUI builder tool. Most of the IDEs these days come with GUI building tools and also the GUI tools can for the most part be plugged into IDE.
That said, I have found Qt quit good when plugged into Eclipse.
You should be using a HTML canvas with Javascript in Firefox. Firefox is very portable.
If you want to save yourself a huge amount of time choose Qt. Great, comprehensive docs, dedicated IDE with WYSIWYG GUI designer. There is even a type of canvas that lets you write objects that can react to events and be dragged around while not sacrificing the power of plain raster drawing.
I have had good success with wxWidgets on both Windows and Linux. That said, it's the *only* cross-platform GUI development library I have used and I am used to it. Rather than use anchors for placing window components it uses something called sizers which are a lot harder to work with until you get used to them. It can be used with a variety of languages (C++ and Python are the two big ones, though there is support for hooking into Java as well) and the licensing is sane.
Though I do favor wxWidgets (as it's all I really know) I believe QT is a lot more complete as a library. Depending on what you're doing, QT may be a better fit for your needs.
Be excellent to each other. And... PARTY ON, DUDES!
I am very leery of APIs. It takes a lot to sell me. I started using QT just before the move to QT4, and instantly fell in love. At this point, unless I'm writing a game, I won't even touch C++ without using QT.
QT is the most consistent, well-documented, and intuitive API I have ever used.
'm writing a beautiful musical notation app in Java. It runs unmodified on Windows and Mac ( all versions). I have not tested on Linux. On my old Mac tower 867MHz, my program can play, and highlight 32nd notes. http://en.wikipedia.org/wiki/Thirty-second_note The notes are calligraphic WYSIWYG rendered using Java 2D ( not fonts) and fully printable. I chose Java for its vast libraries(packages). The GUI interface was a bonus. Very easy See another example of an app written in Java: http://www.strata.com/products/strata_3d_cx_suite/strata_live_3d_cx/
There are some really simple frameworks that you can use such as OpenFrameworks(C++), and Processing.org (Java) these integrate everything you need to use in 2D graphics , image and video loading and rendering and 3D in OpenGL. These are cross-platform working in Windows, Linux and Mac. It is easy to integrate QT for GUI in OpenFrameworks. Both frameworks use other known libraries such as OpenCV, Poco. They can easily integrate server/client comunications, load 3DS data.
These are great 2D Multimedia frameworks. Use them.
Whether or not you end up using it, you have got to see how ruby/shoes works to appreciate such a simple-to-use toolkit that offers intermingled widgets and the ability to draw anywhere on the window.
https://github.com/shoes/shoes/wiki
It's built upon Cairo for 2D drawing and Pongo for text rendering.
Right now, I'm using C#, Windows.Forms, and Managed DirectDraw for graphics. DirectDraw is very fast at creating and rendering graphics, it does a good job. It's a little tricky to set up, but performance is much better than System.Drawing.
I do get tons of warnings that my code is using classes which are marked as deprecated, and the built in XML documentation is also drowned out with a big long warning about how DirectDraw is deprecated, blah blah, then finally when you look at the last sentence, there's your actual documentation.
Also, the program is made for a Windows XP machine, and refuses to run on another Windows 7 machine. I have no idea which dependency it doesn't like.
For C#, SDL is a non-starter. There is an SDL library available, but you are restricted to only using the single SDL window that's created, you can't make other windows or controls in that window. There is also a SDL panel control for Windows Forms, but it's a bad joke that draws to the screen by assigning System.Drawing.Bitmap objects.
You really should be looking at JavaFX instead of Swing if you're interested in creating rich GUI environments in Java. You can get a good sense of the future of each of these technologies on Amy Fowler's blog. Amy was one of the founding members of the Swing toolkit - she knows what she's talking about. It's not always what Swing developers want to hear, but you know, life goes on.
Looks like Java Swing is still popular. http://stackoverflow.com/questions/422956/java-swing-or-java-qt Now we have JavaFX for many more special graphical effects: http://www.oracle.com/technetwork/java/javafx/overview/index-jsp-139879.html http://javafx.com/
blah blah blah... "even though I'm no Microsoft fan"
The obligatory remark which all Microsoft fans feel obliged to tack on to their Microsoft promotion.
You're not fooling anyone.
you can get it from plan9port if you're not cool enough to run plan9. easiest drawing ever
A different way to do is to decompose your GUI along MVC (Model View Controller) lines and make different View layers for the different OS's/toolkits.
I advocate such a multitier architecture as well where it is practicable. But it breaks once your customers demand ports to platforms that cannot run the language of your application. For example, the publicly available tools for Xbox 360 and Windows Phone 7 devices can run only verifiably type-safe CIL, and standard C++ compiled to CIL[1] is not verifiably type-safe. BlackBerry can't run C++ either; it can run only Java bytecode.
[1] Details: C++/CLI allows mixing managed and unmanaged pointers but uses two incompatible syntaxes. Code using the managed syntax will not compile in a standard C++ compiler, and code using the unmanaged syntax will compile to CIL that fails verification.
Many people are either choosing or bashing Qt.
When I first got into the "GUI Scene", I used windows and built everything with plain old Win32 API. Painful, but worked. Then, as I moved to GNU/Linux, I tried to port my apps with WxWidgets. It might have been because I was new to it, but WxWidgets felt awful, painful, bloated and "unnatural programming". (I'm talking C++, btw). Then I tried Qt and also found it awful, messy and confusing. Thus, I chose FLTK and managed to build many apps around it. It is simple, direct, not bloated (though not "extremely feature rich" either) and pleasing on the eye if you work it out ok.
A year after that, I decided to improve some of my apps to get some new features in. Thus, I re-wrote most of my apps using Qt and I changed my mind about it. Qt is easy to use -- it feels natural --, it isn't bloated (as some people say), it is beautiful and easy to modify, it is the most well documented toolkit I've ever seen, it integrates well with so many OSes and it has the amazing qt-make.
I also had to develop using GTK some time after that. It didn't feel "wrong", but it felt a bit "archaic" and too "functional" -- I prefer OOP.
So, yes, my humble opinion is that Qt is awesome. Then, FLTK is very nice to use, learn, improve, etc...
Have you heard about SoylentNews?
OpenGL is very cross-platform, but based on your description of painting on a canvas, it's probably not what you want.
Have you taken a look at SDL? That framework is also supported on every platform you could imagine, and unlike OpenGL it provides a variety of system level support functions, joystick input, video and audio, and some other helpful basics. SDL is used by a very large number of open source and indie games. I believe PyGame is based on SDL, in case you want to program in Python instead of C/C++.
Also, depending on what sort of interface you want to build, check out WxWindows. I believe that framework is primarily the basic set of common UI elements (window, text field, button, checkbox, etc.), supported on multiple platforms, and you should be able to do a paintable canvas pretty easily. It's programmed in C++.
Or ncurses. Or maybe flat HTML. Most sophisticated interfaces can be done with a bit of thought and caution in flat-text compatible formats that work very well with even the most modest text screens or flat text browsers. This makes them more robust, takes far fewer client resources, makes them more stable, makes them more portable, and avoids sophisticated GUI's with options and features that serve only to gratify the designer's wish to prove their sophistication, rather than actually get any work done. It also makes the tools accessible to visually impaired people, who may have trouble distinguishing sophisticated borders and popups that only work with certain browsers in certain modes. Fancy popups are often illegible to tired staff, and contribute to RSI.
A few years ago, I went through this this with a very expensive, very powerful system configuration tool absorbed thousands of hours in in-house engineering time trying to stabilize it and get it to actually follow our workflow, and was eventually thrown out in favor of Webmin. That project had wonderful plans, and resource allocations, and milestones, and Powerpoint slides, and managerial sponsors, and everything. But it _never worked_.
Use GUI's when you have to. Keep them simple, use well established tools, but don't design your own just because you can. Small changes to an existing tool that is similar will be a lot more stable than starting from scratch, and you can often get your changes implemented upstream to expand the existing tools as needed.
Seems odd that nobody has mentioned JUCE yet.. http://www.rawmaterialsoftware.com/juce
It's a nicely-written Qt-style C++ library. Dr Dobbs actually rated it more highly than Qt in their Jolt awards a couple of months ago: http://www.drdobbs.com/blog/archives/2010/09/jolt_awards_and.html
What you want is Java's BufferedImage class. Nearest thing to a frame buffer where you can set individual pixels. You can map it to a graphics context and draw lines and characters on it. Best thing since the days of raw VGA.
I'd suggest Processing. It's great for putting apps together quickly, has all the basic 2D tools you'll need, plus support for fancy-pants 3D stuff if you want it later. Great community and docs, too. Works on Windows, Linux and Mac.
http://www.processing.org/
A little while ago I needed a 2D physics simulator, and I was using WPF. I used Physics2D.Net as the engine, and WPF for rendering. It uses an MVVM architecture. The whole thing was open-sourced (LGPLv3). If you happen to go down the Windows route, it's worth a look. Here's an article I wrote about it.
"I have never let my schooling interfere with my education." - Mark Twain
I've never seen a gui project that didn't get bogged down in the problem of the PMs and everybody down to the second owner's third wife wanting to repaint the bike shed a different color, and change the workflow at the same time, while all the time confounding the issues they create even further by not knowing the difference between the two.
If the problem is actually somewhat complicated, implement each action as a straight-to-the-shell command line interfaces, invoke them on the server side via python or perl with apache on top -- and let some poor sucker straight out of college do the gee-wiz gui dance.
This way you get your own work done, and can create a solid platform for whatever craptastic client interface they come up with -- and the data can still be maintained, the QA on the actual backend algorithms can be implemented, and at least *you* have accomplished something on time and under budget.
Let the kiddies who made the mistake of getting into GUI at all fight their own way out of it.
It's very easy to get up to speed with Tcl/Tk. I know it has a bad reputation, is seen as old and stodgy and is derided as being ugly.
In reality, Tcl/Tk is implemented with beautiful, clean code. It has excellent geometry management (the packer, gridder and placer are second-to-none for making windows that adapt to changing geometry gracefully.) Its Canvas object is well-implemented and simple to use --- it was the inspiration for the GNOME canvas widget, AFAIK.
If you are doing mainly drawing, and not GUI (ie traditonal GUI widgets on a traditional window with with traditional GUI events) you might want to look into XNA. It is basically a managed version of DirectX. Because it is .NET you can hook into winforms and WPF to create the occasional "traditonal" GUI.
Otherwise, if it is a windows app, there is no better choice than WPF. It is intimidating at first because with WPF you can easily reskin just about any uielement (and create UIelements from any class you create). But once you realize how classes and the actual UI are separate concerns that are joined only through very sophisticated data binding, you will be in love.
Complicated little beast though and if you come from a winforms background be prepared to do some major unlearning as how you bind data and events to the GUI is conceptually different. If you simply bind to "Button_OnClick" like you did in winforms you are doing it wrong. If you find yourself writing this.textbox1.text = myData.price in your code you are doing it very, very wring.
I highly recommend the open-source Java 2D-based Piccolo2D framework. I've been using it for a sophisticated project for several months now. It is well-designed, easy to learn and highly flexible.
I vote against using Qt. Having used and hacked it extensively (up to 4.8, or the master branch in git), Qt is way overboard for any simple project.
1 QtCreator is good as a common-platform IDE vs Eclipse, but cannot be used as a selling point for programming IN Qt
2 the code ISN'T as cross-platform as many would like to lead you to think because most here only did some simple apps in it, not full-blow production and public releases
3 the framework is TOO comprehensive and doesn't have a modular substructure to rip out unnecessary bloat; the MFC class structure lends to that bloat
4 it is easy to learn, but requires wrapping your head around weird idiosyncrasies of core elements that are poorly explained in the documentation and require trolling through the immense amount of source
5 Qt's problem reporting system pretty much buries any bugs or fixes you contribute that they don't personally like
Expanding on #2 and #3: Qt is only truly portable between Linux/MacOSX/MSWindows. It really sucks on embedded/smallMemoryCpu as they stopped supporting their qconfig modularization since 4.5. Ex. For Windows Mobile and other embedded, the smallest footprint is 12MB MINIMUM (Core, Gui, OGLES). That's > 50% of the entirely virtual memory available to a single WM app -- for a hello-world in OGLES.
Qt uses a strict single-tree (MFC) inheritance class hierarchy (instead of recursive templating due to legacy and hard-noses) which means code for everything ends up in the shared library, used or not. It's software rasterization most of the time and then hardware-accelerates the results, so it's not a true opengl renderer. You'll have to rewrite it yourself to clean it up. This means it has some speed but a lot of bloat in code and texture memory.
Their MOC is a nice alternative to ObjC, but it's a flawed design decision that didn't bet on the templating abilities of C++ modernization. Boost and Boost signals2 is a less magical alternative to Qt's signaling system.
If it was truly portable on mobile, why is it used extensively ONLY on Nokia products? There's few to zero examples for Symbian and Windows Mobile, and it's not ported to Android/iOS. This means you're already limited if you invest in Qt.
Their QGraphicsView canvas drawing layer is still immature and is still NOT multi-thread compatible (as much of Qt). This means you have to work your way around it a lot of times, or avoid it completely (and still can't compile out the software renderer) especially if you wanted a fancy multi-threaded renderer, or simply just loading textures in one thread and then drawing it in a master draw thread.
I strongly recommend going with a lighter, less drama foundation such as Clutter (which is MORE portable than Qt), SDL, or the bindings some languages provide such as gtk.
K I S S
Well, I dont think this answer will get much love from the /. crowd -- (if you dont want to spend 10000 hours developing your app) the only reasonable cross platform solution today is Adobe AIR. Its free, its cross platform and it will also work on phones (sans the Apple iPxxx devices)) Eventually HTML5 style solutions will emerge - but not really ready for a deployment today.
If the poster is looking to develop on Windows or OSX, its possible that the most robust solution would be to use the native OS windowing toolkits.
The "big players" on linux, Tcl/Tk, X/Motif, GTK, Qt, OpenGL, or SDL.
I would personally suggest GTK/Cairo for ease of use, Qt for anything more complicated than a widget, and OpenGL if the application is intended to accomplish anything graphically sophisticated.
The choice between these is bounded by several factors, but all of them have perl bindings, which can make development time almost nil compared to writing the actual graphics routine(s).
If portability, speed, or you just love using a strictly typed language, you might look into learning Cairo, writing your routines once, and then trying them out in the various toolkits as buffered images to see which allow any freedoms you might need, and any additional controls/ui functions (need threads?).
but thats just my two sense.
Good old flash, can't beat flash! Does all you need and more, quick and simple for rapid prototyping. Vector graphics and/or bitmap + animation classes. You'd probably find libraries and even tutorials for everything you need.
I use GTK with Cairo for my custom widgets (like these http://zmooc.net/miep/too_many_knob18.png). It works pretty OK and is rather well documented an, but I run into performance issues just about everywhere. Probably mostly due to my incompetent coding, though:P Nevertheless, I would not recommend taking the GTK-path.
0x or or snor perron?!
#include
Nuff said.
I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
Most Java APIs ( Java 2d, Swing, JavaFx, 3D,...) are arranged in Design Patterns ( http://en.wikipedia.org/wiki/Design_pattern_(computer_science) ). I learned them with Head First Design Patterns but there could be a better book out. The APIs are elegant where once they seemed convoluted.
HTML is a great way to write apps these days. You can program widgets the same as with any windowing toolkit for the most part. I hate programming using non-typed languages myself, but there are tools where you can program in Java and compile to Javascript with HTML5 which is better than writing raw Javascript itself in most cases.
.NET development is very nice to do. More because of the clean languages and incredible development environments than anything else. Windows.Forms is actually a pleasure to code for. The only real shortcoming of .NET is the string formatting functions which simply lack a simple model such as an sprintf() member. Instead, you have to use something like StringBuilder which is a mess.
Mono is also a charm. I haven't done anything cross platform with it yet, but
Qt on the other hand is an absolute wonder. I program Qt using both Visual Studio and Qt Creator and frankly, it's an absolute pleasure. For a means of writing cross platform code in C++, it's unmatched on any platform. You get full Visual Studio and Eclipse integration as well as Qt Creator as full IDE for free if you choose to use that.
C and C++ (while being my favorite languages) are terrible languages and they're getting worse all the time. The standard C++ library is almost unusable, and therefore everyone spends there time rewriting the wheel over and over. C has diverged from C++ now and a lot of new C code coming out won't compile in C++ compilers. C++ has added a huge amount of new features to be abused in the latest standard.
If you choose to use a C/C++ route, then Qt is certainly the best way to go as it has the most uniform programming model of any toolkit. By implementing signals and slots through a preprocessor, C/C++ not only gets something looking like C# style delegates, but also gains the ability to handle threading a little easier.
Qt in reality is everything that the standard C++ library should have been.
As to the GTK guys... well, it's nice and all, but it doesn't have any type of IDE integration. The documentation is poor on the best of days, non-existent on the others. When GTK+ needed an object model, someone reimplemented C++ using GObject which might be easy to use for some, but so far as I can tell simply implements something like COM in C using lots of macros. Not a day passes when I'm working on GTK+ that I don't wonder in marvel how much has been able to be written in a set of libraries that are so hard to use.
have you considered Lazarus? It is cross platform and rather interesting.
Qt
If you don't want to invest much time in learning GUI programming I think you'd better use an IDE rather than a GUI library.
If you know a bit of Pascal language, Lazarus (Delphi clone) could be a good choice for example. It's lightweight, produces fast executables (compiled language) and is cross-platform (native GUI on MS Windows, GTK+ on Linux). It also provides a canvas with basic drawing functions, but you can still use OpenGL as a canvas for more complex (and faster) rendering.
I think it's one of the best tools available to rapidely produce simple cross-platform applications.