if create WC_LISTVIEW with LVS_REPORT style and set both LVSIL_SMALL and LVSIL_STATE (or with LVS_EX_CHECKBOXES) image lists and heigth of small images is less than heigth of state images - list incorrectly displayed: small images not centered by Y, but on same line with state images, and bottom lines (exactly CY_state - CY_small) is filled by trash. for example on high DPI display, ListView with LVS_EX_CHECKBOXES use 20 pixel heigth for CY_state, if use 15 pixel small icons - will be ~next picture (left side of image). if change state images heigh to <= CY_small will be normal displayed (right side of image)
this is known bug ? or exist ways resolve this ?
yes, this is ListView bug - present in all windows versions, including latest win10 builds.
bug in function
int CLVView::ComputeCYItemSize()
here exist next code:
int CLVView::ComputeCYItemSize() // this -> CLVReportView
{
// CListView* _pListView;
CLVImageListManager* p = _pListView->_pImageListManager;
...
if (p->_himlState)
{
p->_cySmall = max(p->_cyState, p->_cySmall);// bug !! need remove this line
...
}
...
}
if 'nop'
p->_cySmall = max(p->_cyState, p->_cySmall)
under debugger - all begin working ok and have next view:
Related
I am trying to convert a mouse event to pixel coordinates within a video. By pixel coordinates, I mean coordinates relative to the original video resolution.
My video element has object-fit: contain, which means that the top left corner of the video is not necessarily located at position (0,0), as this picture shows:
If I click on the top-left corner of the white section in this video then I want to get (0,0), but in order to do this I need to discover the offset of the video content (white area) relative to the video element (black border).
How can I recover this offset?
I am already aware of width, height, videoWidth, and videoHeight, but these only let me account for the scaling, not the offset.
The offset can be deduced. I think this kind of code should do the trick:
if(videoHeight/height > videoWidth/width){
scale = videoHeight/height;
offsetX = (videoWidth - width*scale)/2;
offsetY = 0;
}
else{
scale = videoWidth/width;
offsetY = (videoHeight - height*scale)/2;
offsetX = 0;
}
I was also interested in getting the actual pixel positions from mouse or touch events when using object-fit, and this is the only result I found when searching. Although I suspect it is probably too late to be helpful to you, I thought I'd answer in case anybody else comes across this in future like I did.
Because I'm working on code with other people, I needed a robust solution that would work even if someone changed or removed the object-fit or object-property in the css
The approach that I took was:
Implement the cover, contain etc algorithms myself, just functions doing math, not dependent on the DOM
Use getComputedStyle to get the element's objectFit and objectPosition properties
Use .getBoundingClientRect() to get the DOM pixel size of the element
Pass the element's current objectFit, objectPosition, its DOM pixel size and it's natural pixel size to my function to figure out where the fitted rectangle sat within the element
You then have enough information to transform the event point to a pixel location
There's more code than would comfortably fit here, but getting the size of the fitted rectangle for cover or contain is something like:
if ( fitMode === 'cover' || fitMode === 'contain' ) {
const wr = parent.width / child.width
const hr = parent.height / child.height
const ratio = fitMode === 'cover' ? Math.max( wr, hr ) : Math.min( wr, hr )
const width = child.width * ratio
const height = child.height * ratio
const size = { width, height }
return size
}
// handle other object-fit modes here
Hopefully this gives others a rough idea of how to solve this problem themselves, alternately I have published the code at the link below, it supports all object-fit modes and it includes examples showing how to get the actual pixel point that was clicked:
https://github.com/nrkn/object-fit-math
I have problems selecting my QGraphicsItem.
I have multiple Items (Line and Ellipse) and Itemgroups (containing lines).
In some cases they are overlaying each other but are still visible because of transparency.
For example: I first create a small circle and later i create a bigger circle around the small one.
How can I select the small circle?
I only want an item beeing selected if i click on a visible nontransparent part of it (maybe with some tolerance for lines of 1px width). How can I do that?
A small example how i create a circle:
circleToDraw = new QGraphicsEllipseItem;
this->addItem(circleToDraw);
circleToDraw->setPen(QPen(Qt::black, 1, Qt::SolidLine));
circleToDraw->setPos(origPoint);
circleToDraw->setRect(origPoint.y() - event->scenePos().y(), origPoint.y() - event->scenePos().y(), (event->scenePos().y() - origPoint.y())*2, (event->scenePos().y() - origPoint.y())*2);
Later i will also implement some QImages with transparent parts. Here the problem will be again, that I want to select Items under the transparent part.
Thank you!
Edit
My code for now:
QList<QGraphicsItem *> items = this->items(event->scenePos());
for each(QGraphicsItem* item in items)
{
if(item->opacity() == 1){
//opacity() does not work as expected
//circle will still be deleted when I click the (transparent) inside of it
//item->setSelected(true); //selects all items while pressing mouse, but only top item after releasing mouse. why?
this->removeItem(item);
delete(item);
}
}
int browserHeight=Window.getClientHeight();
int browserWidth=Window.getClientWidth();
dialog.setPopupPosition(browserWidth-dialog.getElement().getClientWidth(), browserHeight-dialog.getElement().getClientHeight());
dialog.show();
The above code will make the position starts from the very last pixel of the browser (ie bottom=0), which is not what i expect. I don't like css cos browser incompatible problem.
Also there a footer in my website (height=50px) if u can make the dialog to not to lay on the footer like the following pic
so, How to position the GWT dialog to the bottom right corner of the browser?
This is the right way
dialogBox.setPopupPositionAndShow(new PositionCallback(){
#Override
public void setPosition(int offsetWidth, int offsetHeight) {
// TODO Auto-generated method stub
dialogBox.setPopupPosition(parentDockLayoutPanel().getOffsetWidth()- dialogBox.getOffsetWidth(),
parentDockLayoutPanel().getOffsetHeight() - dialogBox.getOffsetHeight()-50);
}
});
It will be simple if we know the exact width & height of dialogbox. We also need to to know the parentPanel / parentLayoutPanel of dialogbox
This code will work but it is not the optimum code
dialogBox.setWidth("300px");
dialogBox.setHeight("300px");
dialogBox.setPopupPosition(parentLayoutPanel.getOffsetWidth()-300,parentLayoutPanel.getOffsetHeight()-300-50);
but how to know the width + height of dialogbox dynamically is another question
I have a spark skinnable component which contains a datagroup with images. The datagroup is scrolled by hovering the mouse over it. Everything works fine except one thing: after I change the datagroup provider, I need to scroll down automatically. The problem is the images are not loaded immediately after I set the provider so (contentHeight - height) does not yet represent the actual maximum scrolling position. Is there an easy way of telling the datagroup to scroll down as its content loads? Because the workaround seems to be not so straightforward.
This is the code for scrolling(thumbnailStrip is my datagroup):
private function thumbnailStrip_mouseMoveHandler(evt:MouseEvent):void {
var fr:Number = (thumbnailStrip.contentHeight - thumbnailStrip.height) / thumbnailStrip.height;
var scroll:Number = fr * evt.stageY - fr * this.y;
var ms:Number = maxScroll();
if(scroll > ms) scroll = ms;
thumbnailStrip.verticalScrollPosition = scroll;
}
private function maxScroll():Number {
return thumbnailStrip.contentHeight - thumbnailStrip.height;
}
Thanks,
Calin
thumbnailStrip.layout.verticalScrollPosition += thumbnailStrip.layout.getVerticalScrollPositionDelta(NavigationUnit.END);
This may have to run a few times to get all the way to the bottom.It's supposed to return the difference between the current scroll position and the "end" of the scroll position. As things load, I'd just keep calling this in a "callLater".
btw, there's a bug for this: http://bugs.adobe.com/jira/browse/SDK-25740 not sure if it's fixed in 4.5, ugly workaround here: http://flexponential.com/2011/02/13/scrolling-to-the-bottom-of-a-spark-list/
I have a several chart components that I have created in Flex. Basically I have set up a special UI that allows the user to select which of these charts they want to print. When they press the print button each of the selected charts is created dynamically then added to a container. Then I send this container off to FlexPrintJob.
i.e.
private function prePrint():void
{
var printSelection:Box = new Box();
printSelection.percentHeight = 100;
printSelection.percentWidth = 100;
printSelection.visible = true;
if (this.chkMyChart1.selected)
{
var rptMyChart1:Chart1Panel = new Chart1Panel();
rptMyChart1.percentHeight = 100;
rptMyChart1.percentWidth = 100;
rptMyChart1.visible = true;
printSelection.addChild(rptMyChart1);
}
print(printSelection);
}
private function print(container:Box):void
{
var job:FlexPrintJob;
job = new FlexPrintJob();
if (job.start()) {
job.addObject(container, FlexPrintJobScaleType.MATCH_WIDTH);
job.send();
}
}
This code works fine if the chart is actually displayed somewhere on the page but adding it dynamically as shown above does not. The print dialog will appear but nothing happens when I press OK.
So I really have two questions:
Is it possible to print flex components/charts when they are not visible on the screen?
If so, how do I do it / what am I doing wrong?
UPDATE:
Well, at least one thing wrong is my use of the percentages in the width and height. Using percentages doesn't really make sense when the Box is not contained in another object. Changing the height and width to fixed values actually allows the printing to progress and solves my initial problem.
printSelection.height = 100;
printSelection.width = 100;
But a new problem arises in that instead of seeing my chart, I see a black box instead. I have previously resolved this issue by setting the background colour of the chart to #FFFFFF but this doesn't seem to be working this time.
UPDATE 2:
I have seen some examples on the adobe site that add the container to the application but don't include it in the layout. This looks like the way to go.
i.e.
printSelection.includeInLayout = false;
addChild(printSelection);
Your component has to be on the stage in order to draw its contents, so you should try something like this:
printSelection.visible = false;
application.addChild(printSelection);
printSelection.width = ..;
printSelection.height = ...;
...
then do the printing
i'm not completely sure, but in one of my application I have to print out a complete Tab Navigator and the only method i have found to print it is to automatically scroll the tabnavigator tab in order to show the component on screen when i add them to the printjob.
In this way they are all printed. Before i created the tabnaviagotr scrolling the print (to PDF) result was a file with all the pages of the tab but only the one visible on screen really printed.