I have two elements that are supposed to be laid out in a column, but one of them is supposed to rotate as it is meant to visually depict the orientation changes read by an IMU. Since that rotating element is a rectangle, when it rotates it overlaps with the item below.
I have tried using both Column and ColumnLayout elements to see if the spacing between these elements can be kept constant even if the top element takes more space because of rotation, but no luck. I then removed both items from Column and tried binding the y property of the lower element to be h*cos(rotation) + w*sin(rotation) where h is height, w is width, and rotation is the angle of rotation in degrees of the top-most element. This results in the second item moving up and down pretty wildly on the screen instead of smoothly following the rotation of the first element.
What can I do to achieve the desired effect?
Related
I have an object rotated around point (0,0). I can't change the anchor point. The rotation is done by another system and I can't influence that. All I have control of is the position of the element (and I can access the rotation value).
Now, I'd like to adjust the element position to make it appear like it's rotating around a specific pivot point.
How it is:
How I want it to be:
I could be wrong (your description honestly isn't great) but it looks to me like you just want to have the anchor point (that you have no control over) in the center of your image. So you just need to know the anchor point, and then calculate, probably, the top-left corner of your image based on the center of it being at the same point as the anchor. If the anchor point is (a,b), the width and height of your image are w and h, respectively, then the top-left corner of your image should go at the point (a - w/2, b - h/2). That is you need to subtract off half of both dimensions.
I am looking for a way to draw a node on top of the neighbouring ones in a HBox. Default behaviour means it is drawn on top of the previous one, but that also means the next one is drawn on top of it. For other containers, one could use the Node.toFront(), but changing the position of the node in the list containing a HBox's children also changes the actual position in the HBox, which is unwanted behaviour in my case. I appreciate any help, thank you.
EDIT:
The overlapping occurs when applying a DropShadow effect on an Ellipse and wrapping them in a StackPane along with a Text. It looks like the effect has a weird interaction with the HBox, as it works as intended without it. After adding the effect, it allocates more horizontal space for the ellipse, but not enough to cover the margins of the effect. Also, when clicking anywhere in the whole right half of the black rectangle, the mouse click is dispatched to the stackPane event handler, not to the rectangle's.
This happens
In VBox and HBox, the Node.toFront() and Node.toBack() functions will change the layout, so they are not usable. If you are using JavaFX 9+,you can use the viewOrder commands to change the rendering order of the Node in its Parent:
Node.getViewOrder()
Node.setViewOrder()
The default value of viewOrder is 0, so setting it to -1 will render it above all others. You can customize this to get specific orders. It also has a CSS property -fx-view-order.
I am working on a FLEX / AIR Spark list which lists a collection of images with differing width and height.
I am using a custom layout which works this way:
decide how many images can be fit in the current row based on their widths.
justify them in such a way that first image in the row obeys the "left" margin and the last image in the row obeys "right" margin, so with the "top" and "bottom" as specified by the user, let us say 10 pixels.
As an example, assuming that the current row has 4 images, the images 1 & 4 will have 10 pixels each as "left" margin "right" margin respectively. But the left and right gaps between 1-2, 2-3 & 3-4 will be equally divided based on the varying widths.
now i would like to draw a background that will fill the dynamic area. Please see the image below to get an idea:
Layout requirement Image
** In the image, The grey area is the background I would like to draw, and the colored rectangles represent images of differing widths and heights.**
the "rowHeight" is variable based on the maximum height of individual images within the row.
Issues:
a) Now I would like to draw a background (see the grey area in the pic) that fills the background area of the list. I know the current item's width & height, but I don't know the rowHeight decided by the layout, left and right margins between the images.
Something like:
bgRect:Rectangle = new rectangle ( 0, 0, (imgWidth + (LeftMargin/2) + (Right Margin/2) ), rowHeight)
b) How / where should the background be implemented? if i add the BG area within the item renderer based on the layout, again the layout will be relaid.
Children should be added in the createChildren method. Drawing (painting) the background should happen in updateDisplayList method.
You can pass data to your itemrenderers via an itemrenderer factory. See - Flex - Sending a parameter to a custom ItemRenderer?.
var productRenderer:ClassFactory = new ClassFactory(ProductRenderer);
productRenderer.properties = { showProductImage: true };
myList.itemRenderer = productRenderer;
In a tableview or tablewidget of pyqt (and qt in general), if you resize column cells that have no wrap on them, the right side of the cell value will be clipped (and replaced with ellipses ...) regardless of whether the cell value is left or right aligned.
The effect is as follows:
The long and winding road. => The long and windi...
Is it possible to force the table to resize the cells while clipping the left side of the cell value, instead?
The effect I want is as follows:
The long and winding road. => ...ng and winding road.
I want this so that if I right align a line of text, and then resize the cell, I want to always see what comes at the very end of the line.
Any help would be appreciated.
You can use setTextElideMode to set where the "..." is placed. In your case (using C++):
ui->tableWidget->setTextElideMode(Qt::ElideLeft);
Note that the elide mode affects all columns.
I have a rectangle of any arbitrary width and height. I know X,Y, width, and height. How do I solve the upper right hand coordinates when the rectangle is rotated N degrees? I realized if it were axis aligned I would simply solve for (x,y+width). Unforunatly this doesn't hold true when I apply a transform matrix on the rectangle to rotate it around its center.
It's usually easiest and fastest to let Flash's display code do these kinds of things for you. Create an empty Sprite and put it inside the rectangle's display object at the corner you want to track. Then, find the location of that sprite in the coordinate space of your choice:
var p:Point = new Point(0,0);
myRectangle.myCornerSprite.localToGlobal( p );
someDisplayObject.globalToLocal( p ); // for a coord space besides the stage
This gets you out of making any assumptions about the rectangle's design (i.e. registration point), and works even if the rectangle should be skewed or scaled as well as being rotated. Plus, this will be much easier to implement and maintain then a mess of cosines and whatnot.
(Note that the code above assumes that "upper right" refers to a specific corner - if you want to examine whichever corner happens to upper-rightmost at the moment, I'd simply add do the same thing with a sprite at all four corners, and pick whichever is to the upper right in global coords.)
You just have to calculate the point on a circle for the given radius. The center of your rectangle will be the circle's origin and any corner will be a point on the circle's circumference. You need to use trigonometry to calculate the new point using the rotation. I don't have time right now to explain all this, but here is a link to a decent 2D Javascript library I've used in the past and which should give you everything you need (bearing in mind that the math is virtually the same in Javascript and ActionScript) to work it out for yourself.
http://jsdraw2d.jsfiction.com/viewsourcecode.htm