GTK 3 transparent label with text placed over image - c++

i need to create GTK GUI with image and transparent label (darker) that is placed over the image. The first problem is overlapping. I tried Gtk::Table and Gtk::Fixed container but it behaves strangely. The second problem is transparency. I would like to use CSS styles or transparent background image. Is there anybody who can help me posting some sources or examples? Thanks

You could subclass GtkWidget, or GtkDrawingArea since I think it will be faster than the altenatives. But you could use GtkOverlay, plus GtkImage and GtkLabel to acomplish what you're looking for.
gtk3-demo app that comes with Gtk+-3.0 give some examples of how to use GtkOverlay.

Maybe you could give a look to clutter-gtk ? You can do nice things with it.

Related

Is it possible to use only a portion of QImage for styling?

Let's take the horizontal sprite of images of my previous question:
So, I have 4 images in 1. Let's say that I want to use only the green circle for styling a QComboBox arrow. I know I can style it with a single image with
QComboBox::down-arrow {
image: url(:/downarrow.png);
}
but is it possible (in the stylesheet or by another means) to get only a piece of the image used?
Unfortunately that is not possibile with Qt Style Sheets, since they do not support absolute values for background-position, as stated in the documentation
The answer to the linked question is still the best way to implement this with Qt.

How to flip an image in Qt?

I found that video on Youtube. It shows how to flip something called QML Flipable. I'm completely unfamiliar with QML so I have the following questions:
1) Is it possible to flip an ordinary QLabel like this? If yes how do I do that?
2) If it's not possible then how do I add that Flipable entity to my QMainWindow?
Thanks, everyone
You could use the QGraphicsPixmap with your image , set the rotation center with setTransformOriginPoint and animate the transformation matrix with QProertyAnimation
There's no convenient way to do this. Desktop OS's don't provide this functionality.
One option is to use QGraphicsView. You can add widgets to a QGraphicsScene using QGraphicsScene::addWidget(), for example, and then transform the view the way you want.
Quick google search points me to a blog article where author of the video (Kunal Parmar) describing how this particular effect was done.

what's the best way to display images in qt? also I would like to zoom in to particular areas as well

I've been using label to display images. I'd like to be able to click and create a bounding box then be able to drag the cursor to move around in the image. What would I need to do this? Thanks.
I'm not 100% sure I understand what you are trying to do, but I think the QGraphicsScene is what you are looking for. You can (among many other things):
Render images (QGraphicsPixmapItem, for example)
Change the zoom level when rendering the scene on a QGraphicsView.
Select things using a "rubber band"
Move items around with the mouse (see QGraphicsItem::ItemIsMovable)
etc.
You may need to get familiar with Qt's graphics view framework.

Cross-platform transparent windows in C++?

I'm wondering how to make a window transparent, not cutout holes or the same transparency overall.
Well, just say I want to slap a PNG image of a rose or something and have it blend nicely with stuff behind and allow stuff behind to redraw and have their changes shine through the transparent parts of the picture/window.
I could (or would like to) use something like wxWidgets or OpenGL. But rather not Qt or GTK.
I found out that it's actually pretty simple to throw up a transparent picture on the screen using wxW:
wxScreenDC dc;
wxBitmap bmp(wxT("test.png"), wxBITMAP_TYPE_PNG);
dc.DrawBitmap(bmp, 250, 100, true);
Now I has to find out how to handle updates and such, it has to be ( maybe partially redrawn ) when something beneath updates.
As it is right now it just redraws itself ontop of itself, making it become fully opacue in a while.
There was another version of wxScreenDC::DrawBitmap that took a window as an argument, maybe it's that one solves this?
How about using shaped frames?
wxBitmap m_bmp = wxBitmap(_T("redroseonwhite.png"), wxBITMAP_TYPE_PNG);
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
wxRegion region(m_bmp, *wxWHITE);
bool m_hasShape = SetShape(region);
Look *wxWidgets-2.9.0\samples\shaped* for the full example.
See wxTopLevelWindow::SetTransparent.
If the platform supports it will set the window to be translucent.
So I guess wxWidgets can do it.
If you are willing to do something other than C++, there may be other cross platform options like JavaFx and Adobe AIR.

Simplest way to change listview and treeview colours

I'm trying to find a simple way to change the colour of the text and background in listview and treeview controls in WTL or plain Win32 code.
I really don't want to have to implement full owner drawing for these controls, simply change the colours used.
I want to make sure that the images are still drawn with proper transparency.
Any suggestions?
Have a look at the following macros:
ListView_SetBkColor
ListView_SetTextColor
TreeView_SetBkColor
TreeView_SetTextColor
There are also appropriate methods of the CListViewCtrl and CTreeViewCtrl wrapper classes:
GetBkColor
SetBkColor
You may also want to take a look at WTL's CCustomDraw::OnItemPrePaint (that's if you need to control the drawing of individual items)
A good article that describes this process is here
It's been a while since I've use the win32 API directly, but I believe that if you handle the WM_ERASEBACKGROUND message for your control, you can use FillRect() in your handler to paint the background using whatever color you like.