confine rendering to cclayer frame - cocos2d-iphone

Is there any way of confining the rendering of CCSprites and such onto a CCLayer in a way that anything beyond the frame of the CCLayer gets clipped (ie. doesn't display past the frame of the CCLayer)?
Why do I need this? I'm working on a roguelike and want a modal box to appear to select spells, wands, potions or scrolls. I place a CCSCcrollView on top a CCLayer to scroll through the lists but I need to confine the display to just the region I want.

Related

What is the difference between a Viewport and a View?

Why would you need a viewport? Isn't a View engough? What is the difference?
I have one viewport in my program created so long ago that I forgot it was even there... And now that I want multi-staged rendering and I wonder if I need another one. And the Viewport mdocs page doesn't get into how and why (or maybe I'm blind).
A viewport is how much of the window a view takes up.
A view is what should be visible in that viewport.
A good scenario of having many viewports would be in a splitscreen game.
In a splitscreen game, each player has their own section of the screen. The game can not render one players view inside another players viewport.
Many viewports can also be useful in singleplayer games, like to render a minimap.
Many viewports can also be useful outside of games, like in a text editor. You could have one viewport for the text, and the other for a toolbar.
Think of each window on your computer as being a viewport. You could be in an application that has scrolling, but that is the view moving, not the viewport. When you resize the window, or move the window, you are moving the viewport on your screen - not the view.

How to clear existing content before redrawing QGraphicsItem?

I have a drawing that is built inside a QGraphicsScene with several layers of QGraphicsItem derived objects.
I am repositioning the QGraphicsItem objects based on some parameters and have noticed that there are some "ghost" trails left unless I call graphicsArea->viewport()->update(). I am repositioning the QGraphicsItem objects quite frequently (i.e. when a slider is moved) and updating the viewport only works if I call it manually some time after drawing is finished (e.g. on a button click).
One possible solution that I found was to fill the background of each QGraphicsItem to be a neutral colour. This doesn't work when I have overlapping items though, as the underlying items can get overwritten.
Does anyone have any suggestions?
Thanks,
Alan

Stringray Grid transparent background

In Stringray grid, there is the ability to use a transparent background which allows the background of the dialog to be shown through the grid.
In the documentation it states:
But be careful; you should disable scrolling or you have to redraw the grid each time it is scrolled (by overriding DoScroll).
I have a scrollable gird and override the DoScroll and make sure I call Redraw and also tried Invalidate, however the grid is still not completely erasing and redrawing.
I also tried using the old drawing method by setting m_bForceOldDrawing to TRUE.
How can I create a grid that has a transparent background that paint correctly after a scroll without leaving artifacts?
Yes you have to redraw the grid by overriding DoScroll because it is no longer using ScrollWindow to scroll contents because the background is transparent.
However you now have artifacts of the grid over your background.
This is because the background behind the grid is not getting redrawn.
Do you have clipchildren set for the parent?
Another potential problem is that the background is not being drawn because it doesn't realize it has been exposed.
Try calling the parent with the following.
Parent.Invalidate();
Parent.UpdateWindow();
before calling...
Invalidate();

How do I create a rotating cube effect in Qt?

I have a QGraphicsView and a slide show of QGraphicsScenes, at the moment when the user switches to the next slide I just change the Scene that the View is looking at and it changes instantly to reflect that.
What I would like to do it create some transition effects, such as the rotating cube or the slide in/out.
However looking at the QPropertyAnimation class it seems to be about moving an object not transitioning from one to another.
As in I would need a view for each scene and then transition between each view.
What other strategy could I employ?
Instead of changing the scene that the view sees, you could use property animations to slide graphic items in and out of the view from a single scene. That would give you the slide in/out transition without too much effort. The rotating cube effect would be trickier but I think a reasonable facsimile could be produced with property animations.
You could also simulate other effects by subclassing the view widget and adding some custom properties that you could animate and use to direct background or foreground painting.

Displaying a popup widget in QT over application border

Let's say that I have an application frame, and I want to show a popup QCalendarWidget over on the right side of the frame. Normally, QT will clip the edges of the QCalendarWidget, cutting it in half and not displaying the rest, as it would be over the right side border.
Is there a way to work around this limitation without resorting to implementing a QDialog?
I want the widget to be visible outside the bounds of it's container.
If you'd show your Calendar, let's say, after a button click, as QDateTimeEditor does, it's contents will not be clipped, cause it do not belong to frame. It will be just a widget, that shows in a dialog manner. And maybe you should even place it in QDialog, that is modal and provides some convenience methods, rather then simple QWidget.
Btw, why don't you want to use QDatetimeEditor?