Famo.us Scrollview setPosition with transition - famo.us

Trying to very simply scroll a famous Scrollview to a pixel position with a transition. It looks like Scrollview's setPosition function will set the scroll position in pixels (right?). But how do I add a transition to this.
My first thought was to use a Transitionable to move from the scrollview's getPosition to the end position, but this led to another question: How do I watch a transitionable?
Thanks!

Right now the famous Scrollview does not support setting the position with any kind of transition. There are a number of things you can do to simulate the transition, such as dividing the total difference in position by the length of the transition and then adding that value to the position every render frame. This would give the illusion of a transition.

Related

Osmdroid - Marker - increase selection area to get the InfoWindow

When selecting a Marker an InfoWindow pops up.
Sometimes the selection of a Marker is difficult. Especially when the map is rotating in the direction of navigation.
How can I increase the 'touch circle' so that selection is easier?
Update: I have to change the hitTest() for the Marker by subclassing.
I would like to check whether the 'hit' (or touch) was within a circle of X pixels around the point of the Marker. The icon will rotate while I navigate, so I guess I don't use the icon.
How can I do that?
public boolean hitTest(final MotionEvent event, final MapView mapView){
final Projection pj = mapView.getProjection();
pj.toPixels(mPosition, mPositionPixels);
// Does mPositionPixels contains the x, y of the Marker?
// Should I draw a Rect around this point, or could it be a circle?
// How can I check whether the event.getX(), event.getY() is a hit?
return hit;
}
Method proposed by spy is feasible.
You can also create your icon bitmap with an area of transparent pixels around. This is a very simple way to increase its touch area.
I believe #Mker would say, extend the Marker class and override the method hitTest. That is used for the Marker itself. I'm not sure if you can change this for the InfoWindow itself.

Absolute positioning of child views in a Famo.us ScrollView

I've a ScrollView of images, while clicking on an image (read imageSurface), I would like that one to smoothy scale to an absolute location of the screen (for example a fullscreen) this independently of the scroll state. Here is an example of a similar behaviour.
In my understanding, I should find a way to retrieve the current imageSurface location and apply a modifier with an opposite location in order to virtually detach the surface from the ScrollView. Then I might apply the modifier I would like (for example a full screen modifier).
Another option would be to override the ScrollView's render() function but I'm not sure it is a good/safe idea.
Removing the image from the sequence to quickly add it somewhere else but attached to another modifier (not in the scrollview) is also an alternative but I fear having glitches and not being able to fade it back to the sequence correctly.
Any idea on how to achieve this ?

Infinite parallax scrolling with famo.us

I have a scrollview and an image as a background in different surface with lower z-index. I want to scroll the image with half the speed of the scrollview.
Any ideas on how to implement it ?
I can't give you a COMPLETE solution, but this should take you down a decent path.
1) Famo.us has worked on multiple scrollViews. Each has a slightly different method to get the 'scrollTop' value from it.
The one created earlier only gives you the scrollTop value for the first visible element in the list. So, in this case you can get how many elements have been scrolled away and calculate the actual value yourself. OR if you have a small, and limited number of the elements in the scrollView you should wrap all the elements in a single view and pass a singleView to the scrollView. This way Famo.us has to do calculations for off-screen elements, but if the number of elements is small enough, it can make many animations/calculations much easier.
The second scrollView was call LimitedScrollView internally. I don't have much experience with it yet, but it should give you the correct values anyway.
2) ScrollView fires events on scroll. use that to update the value of a transitionable.
Pseudo Code:
scrollView.on('scroll', function(){
transitionable.set(scrollView.scrollTop)
});
3) You can now bind the transform value for the background to the transitionable.
Pseudo Code:
background.transformFrom(function(){
return Transform.translate(0, -transitionable.get()/2, 0);
});
Now, things should work correctly.
Hope that helps.

How do you make a clickable sprite in SFML?

I've been looking through the SFML documentation for making clickable sprites, but so far I haven't found anything.
Do you guys think you could help me out?
There is nothing like sf::ClickableSprite in SFML so far, and probably there will never be. (Current list of classes in SFML)
However, you can obtain this behavior with the sf::Sprite object and the events. The idea is simple - as soon as you get the sf::Mouse::isButtonPressed(sf::Mouse::Left) event, check if the mouse is in the sprite. If it is, perform the action. You can perform another action (maybe undo) when button is released.
There is sf::Sprite::getGlobalBounds() function which returns you the position and the dimensions of the sprite. There's also sf::Mouse::getPosition() function, which returns the current position of the mouse. You can use sprite.getGlobalBounds().contains(mousePos) to check whether the mouse is in the sprite.
If you're using views, you'll need to add the view's position to sf::Mouse::getPosition(window), since it gets the mouse position relative to window coordinates.
(thanks to Chaosed0 for additional notes.)

How to scale a QGraphicsEllipseItem with the Zoom Level of QGraphicsView

I have a QGraphicsView on a widget which im adding a number of items to.
some of these are polygons and some are ellipses (Both QGraphicsItems) when i zoom the Graphics view
void Test::on_verticalSlider_sliderMoved(int position)
{
ui->graphicsView->scale(1.1,1.1);
}
the ellipses just get bigger and bigger but i want them to shrink so that they basically stay the same shape no matter how far zoomed in i am, so basically i want the polygons to be zoomed in on but not the points i have plotted onto these polygons...if that makes sense
dont know it makes it easier but all of the ellipse points plotted at any one time are within the same QGraphicsItemGroup so there could be a flag i can set on the entire group to do this?
anyway i would be greatful for any help with this
thanks
EDIT ------ CODE SAMPLE
item is the QGraphicsEllipseItem, and m_group_point is a QGraphicsItemGroup
item->setParentItem(m_group_point.get());
then i add the group to a scene
m_scene2->addItem(m_group_point.get());
then add that scene to the view
ui->graphicsView->setScene(m_scene2.get());
they are .get because they are shared pointers
well, ignoreTransformation indeed a proper way to go.
QGraphicsItem::ItemIgnoresTransformations: The item ignores inherited transformations (i.e., its position is still anchored to its parent, but the parent or view rotation, zoom or shear transformations are ignored). This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately. You must call deviceTransform() to map coordinates and detect collisions in the view. By default, this flag is disabled. This flag was introduced in Qt 4.3.
About stay in the middle, you should move ellipses within scene to proper position, so they have proper scene coordinates, and then you instruct to ignore transformation of the view, so they will ignore any zooming/rotation/etc as mentioned in documentation.
The Qt docs states this about the flag QGraphicsItem::ItemIgnoresTransformations: -
The item ignores inherited transformations (i.e., its position is
still anchored to its parent, but the parent or view rotation, zoom or
shear transformations are ignored).
Which is what you want. You've added your items to a QGraphcisItemGroup. For this, Qt help states: -
QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on its
children (i.e., with respect to the geometry of the group item, the
children are treated as if they were transformable).
Reading into this, the QGraphicsItem uses the ItemIgnoreTransformations flag based on its parent, which in your case is the QGraphicsGroup, but this class ignores the flag on its children, which is likely to be causing the issue you're seeing.
Therefore, do not set the flag on the parent group, but on its children.
Try setting the ItemIgnoresTransformations flag on the objects that you want to keep constant-sized.