I have a wxwidgets that I want to add some cool effects. Using GDI would be impossibly hard. Could I use flash or something else? - c++

I have an application that I want add some cool animations to show state changes. However, wxwidgets would be difficult because I'd have to program these animations in straight gdi. What's the best way to add these effect windows? Should I open a flash window and run a flash sequence or is maybe some other technology? Does .net have something I could code into a dll and run from my wxwidgets binary? I need something that is super easy to draw and set up the animation.

It's hard to say what the best approach would be to achieve "cool effects", but in most cases you would want a double-buffered drawing surface. That's what I've used in similar-sounding situations.
In wxWidgets, you would want wxBufferedDC.

You could prepare animation as a bunch of images (wxImage loaded from PNG, GIF, JPG or whatever files), and then use a timer and paint them on a control. Maybe it sounds like too much, you I believe you could do it in 50-70 lines of code.

Perhaps you just could make a single widget that has a custom paint-event that hand-draws the various widgets inside it? Then you could draw them at the appropriate locations/sizes without having to involve wxwidgets at all, it would just be a bunch of line-draw/rectangle-draw/text-draw commands to update the display for each frame of animation.

Related

What Qt widgets should be used for sprite animation viewer

I'm looking to make a sprite animation editor. I have the loading of my custom animation file done but now need to get the actual ui started. I'm really just stuck on what widgets I would use to actually play my animation. I need to be able to go to certain frame, play, pause, loop, etc. Once I'm done with the viewing portion I plan on adding in the editing.
I've seen AnimatedSprite in qt docs but that seems to only allow playback of sprites in the same file. In my situation sprites can be from multiple image files and sometimes doesn't follow a grid like sprite cutter.
First of all, you should decide whether you want to use QML or Widgets. AnimatedSprite is QML related class. All widget-related classes starts with "Q" letter.
If you decide to use Qt Widgets, I would recommend to take a look at Qt Animation Framework in combination with Qt Graphics View Framework. Most likely it will not let you do everything you want out of box, but it should provide you with a rich set of useful tools.
If you need here are some examples.
Hope it helps.
Have a look at QMovie. This class may provide all the methods you need, as long as you only want to use it for viewing. The QMovie can be passed to a QLabel to show the animation.
QMovie however supports only gif out of the box (and there is a third party plugin for apng files). You would probably have to create your own image handle plugin to support your format.
If thats not applicable or to complicated, you will most likely have to create your own custom widget. Have a look at the painter example. Playing an animation is not that hard if you have all the frames. A simple QTimer to change the image to be drawn in a constant rate should work.

Simple library to display 2D images in C++ on Linux

I would like to have a tool to debug 2D planar meshes. I would like to be able to display them and debug to be able to debug certain things.
Is there a widget (for any toolkit on Linux - QT, GTK+Cairo, ...) which would display the images, scroll them and zoom it. Is there any widget which would handle it (without need to implement zooming, scrolling etc. by hand)?
Side requirements:
Needs to work on CentOS 6
I need it for C++. Unfortunately changing the build system in my situation is harder then it sounds.
The Qt Graphics View is certainly a useful tool, it gives you scrolling, zooming, rotating easily. You probably want to learn the basics of Qt before. (and Qt is in C++).
Here's an off the wall suggestion.
This would be fairly easy to implement in a web browser. Web browser engines already have the base functionality for resizing and scrolling over images. You may need a little JavaScript to bind it together, of course.
So why not use WebKit? There are bindings for many of the leading toolkits (e.g. QWebView for Qt), so you could take your pick of which one you're most comfortable with.
Yes, it's overkill. But it's code you don't have to write, and time is money.

Is there a way to customize what a button looks like in C++?

I have programmed in HTML, Java, CSS, C++, VB, an Python.
I'm looking to make button that looks completely the way I want it to look!
Like in HTML+Java+CSS, I can do that very thing!
I'm using Netbeans IDE. I was about to just use OpenGL to do the GUI programming for my programs, since it is so hard to find information on customized GUIs.
I just want to learn how to make the image and give button functionality to it. I want to be able to make the shape, color, and effects (when clicked, hovered over, etc).
Oh, and I program in Ubuntu Linux!
Any help would be appreciated!
Qt is a good idea, but you won't learn how it works, though it's not really important and far easier like that. Using C++ you will have libraries that respect the encapsulation principle, so you won't know at the first sight how do is work, just how to use it.
If you really want to code a button yourself, you can take a 2D drawing library such as SFML, with which you'll draw your button and handle events on it.
When I wrote a custom button class for my app, we (the C++ developers) were given PNG images from the designer department. They are much better with tools like Photoshop then we developers. We just showed image1.PNG by default, image2.PNG when the mouse was over the button ("hover"), and image3.PNG when the mouse was over the button and pressed. Drawing? Not necessary.
Color is trivial for designers. Shape isn't hard either. PNGs are rectangular, but can be transparent. So rounded edges are just a matter of a few transparent pixels there.

How to create custom skin like WinAmp

I guess this question has been ask before, but I have not found sufficient answer to even start poking around. Most answer refers to catching WM_PAINT method directly and do custom rendering, or use a onwer draw object. However, I did not see a centralized place that has the info. to start researching. Hence, the question.
My goal is to create a very simple GUI program with custom look into it. I prefer the way winamp does their custom look that is customizable through "skins". However, I am not interested in using some cross-platform library like GTK+, QT or wxWidget.
I have some experience in system programming, but not much for GUI. I spent most of my time developing console applications, and I just started doing some QT development. If you can point me in the right direction, I'd be very appreciated.
PS: I am interested in both windows and linux environment.
Everybody,
Sorry for the late reply. I had a chance to have a quick talk with the original developer for winamp, and this is the quick answers I have:
Using skins: Artists create skins, developer will render the skins
To the OS (Windows), winamp is just one pretty box, nothing else. There is a container windows, and that's about it
All controls (button, label, list, etc) are implemented by winamp team themselves. All messages and stuffs are passed as relative position to the container window. WinAmp and the GUI engine has to decide if a button is clicked or if the label next to it is the target, etc.
Rendering artists skins created in XML
I do not have the details on if they use any libraries to do all that, but I am suspecting they do hook a window call directly, and do custom rendering themselves.
GUI skin usually using plug-in mechanism
I guess this is exactly what you are looking for:
https://www.linux.com/learn/tutorials/428800:weekend-project-creating-qt-interfaces-with-gimp?utm_medium=twitter&utm_source=twitterfeed
I also interested in creating custom look of window and widgets.
Speaking about widgets it's not hard, just need to create subclass (if you are using C++) or some widget and implement some methods like draw, handle etc. But this solution is good only if you use some high-level library like GTK, QT, etc. If you want to implement all controls by your own, you may get any graphics library, which can create window and do any graphics inside. For example, SDL2 + Cairo. SDL2 for creating window, Cairo for vector rendering controls/widgets. Both of this libraries are for win and linux. Another option is take opengl/vulkan + some lib for rendering window. It could be SDL2, SFML, GLFW.
If you really interested how it works on low level, then search Windows API for Windows and XLib or XCB for Linux/X.Org.
Speaking about window, I still investigate it. However I have one thought: you may create an empty window and then draw whatever you want. Then you need to add handlers for resizing window on the borders. But I am not sure if it's good solution, and if it won't freezes.

Animated graphics implementation dialog based MFC

Could anyone suggest me a particular way to implement animation in my Dialog-based mfc program? The animation that I am intending to add is like a construction digger machine graphic that would read the values of the machine parameters and change the shape of the graphic accordingly. Most of the information is read from a text file in terms of the parameters, so I just need to be able to get the animation working.
Thanks for your help in advance.
Well, GDI is easy but ugly and quite slow, GDI+ is also easy, but nicer although generally slower. OpenGL or DirectX are much, much faster but quite hard to program. Other libraries, such as cairo, are also available.
I'd suggest to start with the easiest (maybe GDI+) and see if it is fast enough for you.
Do do that, just Invalidate() the control where you are drawing in a timer, (or when you receive new data), and paint the whole graphic in the OnPaint() function. A basic improvement is to Invalidate() only the region where the new data affects the picture.
If then you notice that your code is not fast enough, come back and ask how to improve it. A concrete example will make it easier to get a more useful answer.
there are lot of articles. Most of them based on drawing in device context
http://www.codeproject.com/KB/GDI/flickerfree.aspx
http://www.codeguru.com/cpp/g-m/bitmap/article.php/c4879
http://www.codersource.net/mfc/mfc-gdi-plus/animation-control-mfc.aspx