Drawing on an image which is inside a QScrollArea? - image

If I subclass QLabel and I add a QLabel directly to my QDialog, it works fine. If I add this label inside a ScrollArea, the thing I’m drawing doesn’t show unless I resize the dialog itself. Yes, weird.
I’ve setup compilable example code that indicates what the problem is. What I am trying to do is to select an area of an image with my mouse, by drawing a rectangle on the corresponding area. The images my program is designed to work with can be very large, and thus, I need to have a scroll area so as the dialog to stay at a logical dimension, and not to fill the entire screen (or even multiple workspaces, if we are talking about a linux machine with multiple desktops).
Everything works fine, except that the drawing (selection-rectangle) isn’t visible unless the dialog is resized – manually. I think I have to update something while drawing, but I’m not sure what. Well, here’s the example code: http://paste.ubuntu.com/1151553/
Another issues that I don’t know how to solve (and I want your suggestions there) are (1) when the user is selecting an area, how to set it to automatically scroll when the user actually selects an area by pushing against to a wall of the scroll area (I guess I am understandable here). (2) is there a way to let the user select a rectangle and then, when he left-clicks on a position with holding down the [Shift] button, the bottom right edge of his previous selection to actually go through the point he clicks at?
The documentation indicates that you have to set a Layout somehow somewhere, but I'm not sure how to do this to my occassion.
Thanks in advance for any help.

about problem (1):
just use of Event. i think mouse Enter Event or Leave Event is good for that.
and to do that i think you can use a hidden rectangular that fill the whole of the screen.
and over write the mouse leave Event for that rectangular and tell in that function , to scroll the page.

Related

Making a Mac Popover appear inside the app's area

My app does not fill the entire screen. It is a rectangle, lets say, 1000x500 pixels. When the app is on the middle of the screen and I show a popover it appears like this:
What is ugly, half of popover outside the app area.
But if the app is near the left edge of the screen, then it appears the way I want, like this:
What is pretty, all the popover contained inside the app's area.
Is there a way to force the popover to always appear like this second case, inside the app's area?
As far as I know you have very little control on how a popover is displayed. Apple reserves themselves the right to make changes on how to display popover's and this would not be possible if you were in total control. You can define the preferred edge and the preferred width and pretty much anything else is up to the system. If you need more control yourself, you need to draw the whole thing yourself (which is possible, just a a lot of work) or use some third party framework.

Subview that expands with window using NSAutolayout

I'm trying to learn auto layout so I can set up a moderately complicated display the way I want. I'm starting with a simple version. At least I thought it was simple.
I have a content view containing a NSScrollView, and a zoom slider. The scroll view is, of course, just a window into a larger 'canvas' on which the user can do things.
I'd like the scroll view to be as big as the window allows, with the slider underneath.
I've tried many things none of which work, in some cases when I resize the window smaller, the scroll view goes on up over the window's top bar, obscuring the title and the red yellow, green, dots.. this is just a grumble, I won't attempt to describe how I got it.
I'm working with Visual Format Language.
The immediate problem: I can only get the thing to work at all if I put in a hard size constraint on the scroll view.
I've got constraints like #"V:|[ScrollView]-[ZoomSlider(==35)]-| and
#"|-20#1000-[ScrollView]-|"
With these, nothing shows at all, until I put a hard size on the scroll view:
For example, #"V:[ScrollView(>=70#20)]" and #"[ScrollView(>=140#20)]" results in a little tiny scroll view (as expected) just above the slider.
Window is resizable, all right.
Is there a simple way to make the scroll view resize to occupy the most space possible when I resize the window? The only way I can think of off hand is to produce metrics for the scroll view based on window size, and use a notification to change the constraints when the window size changes. There should be something simpler!
THanks.ee
OOps. Thought I knew the answer until I started to write it.
AT least here is a partial explanation of things that were causing me problems.
You can't add constraints that position or size the Window's content view. But apparently you can mess them up by deleting them programatically. Some of my problems were solved by getting rid of
[self.myContentView setTranslatesAutoresizingMaskIntoConstraints:NO];
and
[self.myContentView removeConstraints:self.myContentView.constraints];
This left me with a lot of conflicting constraints. I fixed this be eliminating all content window constraints that I could in IB, then by marking the rest as placeholders.
I've got a ways to go before I understand how to use auto layout, but doing it in code is easier (for me) than doing it with IB

Mouse events on overlay image interfering

I've added a few overlay images which I'm using as buttons/control for showing / hiding some custom layers and this works fine, however they still trigger the usual drag/move events on the map. This isn't that bad but when you go into street view and you click on on of these (the buttons are on the left of the screen) the camera shifts it's view to the left which is going to be very annoying for the users.
Just wondered if someone has encountered this and have advice? I guess I can move the buttons out of the maps area completely but it looks really nice on the map with the standard controls.
Thanks a lot!

dojo Show/Hide One ContentPane While Another ContentPane Is Liquid

I've been struggling for weeks trying to crack this nut so I'm not sure if it's impossible, or if it's my lack of coding chops... or both. I'm not a programmer and I'm a newbie to Dojo Toolkit.
I have a site using the BorderContainer layout. I'm trying to create an effect where I can use a button to open and close a dropdown type box that will contain controls. I need this dropdown to be hidden on page load, and then open when you click the button.
My problem is that when I open the dropdown, it pushes the content pane below it off the bottom of the browser window. I need the lower ContentPane to stay fit within the remaining space of the browser window when the dropdown opens. Additionally, I want the dropdown to sit outside of the scrollable container for the content below it, which is why I have it set up to sit outside a nested BorderContainer below it.
I've created a simplified version of the code to demonstrate my challenge (see link below). If you load the page you can see the center ContentPane scrolls the content. But, if you then click on the button, a dropdown div expands above the content. Then when you scroll, you'll notice that you can't see the full pane because it's in no-man's-land below the bottom of the browser window. I assume that because the div is set to display:none on load, it's size is not accounted for on page load. Then, when you open it by pressing the button, it's size is additive and the pane below doesn't know how to resize or account for the new element.
I've tried using the visibility attribute, but that leaves a gap for the div when it's still closed. I've tinkered with some code that controls the height that shows promise, but each of my dropdown boxes will be different sizes so I'd prefer that the height be set to "auto" rather than a specified pixel size.
Does anyone have any idea how I can accomplish this so that the lower pane will fit in the space without pushing off the screen?
Here's a sample of the page:
http://equium.com/scaffold.html
(I had some problems trying to insert the full HTML page here as a code sample so if that's a preferable way to handle it, and someone can let me know the best way to embed all of that code, I'd appreciate it.)
Thanks is advance, I'd really apprecaite anyone's feedback.
You might want to take a look at dojox.layout.ExpandoPane (though be warned I think it has only worked properly for top and left regions for a while).
Also, I'd suggest simplifying/altering your layout a bit. See example here:
http://jsfiddle.net/taFzv/
(It'd probably need some tweaking to get exactly what you want.)
The real issue you're having is probably that the BorderContainer has no idea that parts of the view resized. ExpandoPane takes care of that by telling the BorderContainer to re-layout after its animation completes.
It works under IE8.0. When dropdown box open, just keep pressing mouse from page and drag to bottom, you could see the content was pushed to out of page. It looks the browser could not detect it and could not add it to "scroll bar" account.
I would suggest taking out all BorderContainers except your top level one, the one with mainPage as the id.
Place your {stuff here} div into the mainPage BorderContainer, after the ContentPane with the Close/Open button. Make sure you make it dojotype dijit.layout.ContentPane, set up layoutpriority, and set region to top. Set the height to 0/x when clicking the Open/Close button, instead of setting display.
Try your page again. If that doesn't fix it, you probably need, a call to layout, resize, or both to indicate to the BorderContainer that it needs to evaluate all its children and size the "center" pane properly. Something like dijit.byId("mainPage").layout(); Do this any time someone presses the Close/Open button, after you have changed the height of any BorderContainer children.
Maybe the dijit.form.DropDownButton would fit your needs. When click the button a tooltip is displayed that can be filled with any content you want. Just as you specified, the dropdown tooltip is only displayed when you click the button, and it doesn't mess with the underlying layout at all. The tooltip sits "on top" of the page.

GTK# - Problem with components overlapping upon resize

I have a panel containing a form (elements such as labels and textboxes within a table) and 3 buttons (in an hbuttonbox) at the bottom-right. If I shorten the panel by dragging the bottom border upwards, the 3 buttons come with it, and lay on top of the other form components, causing messy graphics. I would like the panel to not resize smaller than the bottom edge of the last component within it. Due to employer restrictions, I am not able to show a screenshot of the GUI. I will try to make any clarifications that are asked.
This probably has something to do with some resizing or general size settings on the components, but there are so many options that I'm not sure where to start.
Any ideas for an easy fix to this without getting down into the complicated nest of components? If not, any ideas on where I should start messing with settings?
Thanks!
UPDATE:
Everything is contained in a VBox with 3 cells. Elements in cells (top to bottom): Table, ScrolledWindow, HButtonBox. The ScrolledWindow bottom edge also moves (resizes) with the bottom edge of the panel when resizing, until the panel bottom goes above the whole ScrolledWindow. Then the buttons keep moving up, staying in relation to the panel's bottom edge.
By "form" do you mean you are using a Gtk.Fixed to contain your table and buttonbox? Then that's probably what's going wrong - you should use vboxes and hboxes for your layout. These will resize properly. Fixed layouts are only for exceptional cases.
EDIT:
Other suggestions:
Perhaps the HButtonBox has pack type 'end' instead of 'start'?
You could try playing with the 'fill' and 'expand' packing properties of the VBox's children.
I ended up adding a Height Request to the container, just slightly longer than the part of the scrolled window. This now stops resizing to where the bottom buttons would overlap the components above it. The problem (before the fix) is shown below:

Resources