I have a controller on which I would like to have a view where I e.g. draw a circle, and then and a textfield and button which can control the size of the circle.
To start with I have created a controller which contains the button & textfield. I have then created the Drawing view (UIView) and added it as this.View.AddSubview(drawingView), but this doesn't seem to work. If I remove the button and textfield from the controller and add the drawing view by this.Add(drawingView) it displays the circle, but then I don't have the button & textfield to control the circle.
How should I create a screen, which both contains the button+textfield and the circle, which I have drawn. I would like to somehow separate the drawing view from the button+textfield, but I don't know if it is possible?
Did you set the drawingView.Frame?
Related
I have a Vaadin 8 application with several views.
public class ViewName extends Panel implements View {
There is a VerticalLayout as main layout in the panel.
public ViewName() {
setSizeFull();
VerticalLayout mainLayout = new VerticalLayout();
setContent(mainLayout);
Then I have many different layouts (HorizontalLayout, GridLayout) or Components such as Label being added as components to the mainLayout. For the HorizontalLayouts I often do the following to use the full width of the screen:
hLayout.setWidth("100%");
I have a lot of icons, grids etc. Everything is OK as long as I don't resize the window.
When I resize the window to a small size I get a mess (icons, text etc. on top of each other) and no horizontal scrollbar. (However, the grids get horizontal scrollbars.) I have tried many things to fix this. If I add
mainLayout.setSizeFull();
or
mainLayout.setWidth("100%");
I have a mess on the big screen already. I also tried the CSS for the mainLayout as described here. I get several scrollbars but none for the window itself!
The only component that resizes correctly is a Label added to the mainLayout, e.g.:
Label title = new Label("Some text",ContentMode.HTML);
title.setWidth(100, Unit.PERCENTAGE);
mainLayout.addComponent(title);
mainLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER);
I also noticed that anything in a GridLayout seems to stay in place after resizing but is not vissible since I have no scrollbar. However, icons in a HorizontalLayout get on top of each other.
What is wrong? Please, I need a general instruction on which layout I should use as main layout for my view panel, how to size the components and how to get ONE horizontal scrollbar for the main window if necessary.
The problem is that you are setting the width of your mainLayout to the width of your view. This means, that your mainLayouts width will never be bigger than your views width. So no scroll bar will appear.
According to the information you posted, changing your mainLayouts width to undefined should fix the problem.
mainLayout.setWidth("-1px");
I have an SVG map with some pins on it that need to be clickable. Furthermore, a small animation is activated whenever the user hovers over one of the pins on desktop. My issue is that it is only the actual shape that receives the event, which is problematic, as the pins have a little "hole" in its center, so if the user hovers or clicks in the center of the pin nothing happens. Is there a way to make the event trigger whenever the user clicks or hovers over the bounding box of the shape, ie. the area is outlined when the element is viewed in the inspector, or would I have to extend the actual SVG with an invisible box or some other "hacky" solution"?
Yes, you'll need to add an invisible rectangle on top. You'll want to set that rectangle to pointer-events: fill, so it gets click events even though it is invisible.
I am working on an android app for which I have been provided with design images. All the UI elements need to be custom designed.
Following are the images for the EditText view and Spinner that I have to implement
EditText
Spinner
I have implemented the EditText using a custom shape and leftDrawable for the icon, however I am not sure how to do the same for the spinner, because as I see it, it requires a custom shape for the background and stroke on focus, left icon and the right dropdown arrow.
I tried using a list layer to combined these three drawables, however it did not work, everything just comes on top of each other. and I am not able to provide the padding like the EditText.
In short, I want that the spinner should look like the EditText along with the right dropdown arrow.
I have:
self.setScene(QtGui.QGraphicsScene(self))
self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
where self is QGraphicsView. I am opening my svg in QGraphicsWebView() because of it's interactivity like this:
s = self.scene()
s.clear()
self.resetTransform()
self.webview = QGraphicsWebView()
self.webview.load(QtCore.QUrl(path_to_my_svg))
self.webview.setFlags(QtGui.QGraphicsItem.ItemClipsToShape)
self.webview.setCacheMode(QtGui.QGraphicsItem.NoCache)
self.webview.setZValue(0)
s.addItem(self.webview)
Zooming works fine, but when I click over webview item in order to drag it, nothing happens except cursor is changed to text cursor. I can drag svg only when I open it like self.svgItem = QtSvg.QGraphicsSvgItem(path_to_my_svg) but in that case it's rendered as static image so I lose interactivity in svg(mouseover, mouseout in svg elements)...
EDIT based on xndrme's comment:
As he suggested SHIFT+mouse left click works well, but it drags the whole SVG which is inside self.webview. Apparently I've thought that when I zoom with mouse scroll svg gets zoomed, but actually self.webview is the one that gets zoomed and scroll bars appears. So, what I've actually need to know is how to drag the whole self.webview within its scroll bar boundaries (with left mouse click)
There is a panel with anchor layout used for vertical sizing.
Inside the panel there is a horizontal buttongroup.
Is there a way to set fixed width or better make the width depend on buttons?
In my case it is always stretched to the size of the window.
There is the same problem with the grid inside the panel.
Thank you.
Making the width dependent on the buttons is handled by the layout itself. If you have an hbox layout, each of the items inside the container (say, buttons) will automatically occupy the width.