Select area by dragging mouse in gwt - gwt

I am using gwt with gwt-dnd and I want to do the following:
1. Select rectangle area by dragging the mouse
2. Select all the elements that are in this area
3. drag all selected elements.
Is there any idea?

On MouseDownEvent record the coordinates of the pointer (event.getClientX() and eventGetClientY()).
On MouseUpEvent do the same. If coordinates are different, you have a selected rectangular.
Get the widget which contains all the widgets or elements that are selectable. Loop through its children.
Compare coordinates of each widget with your rectangular (use getAbsoluteTop(), getAbdoluteLeft(), getOffsetHeight(), and getOffsetWidth()). Select widgets that are totally or partially inside the selected area.

I would add to Andrei's answer that if you to provide feedback by displaying the rectangle during selection that what we do is display the rectangle as an instance of com.google.gwt.user.client.ui.HTML with a style that displays the borders. This is updated using onMouseMove using setPixelSize and setWidgetPosition.

The library gwtquery-plugins offers a MultiSelect feature, so I will give it a try.
gwtquery-plugins

Related

Unity3d. UI elements snapping/anchoring

I have canvas with vertical layout and 2 elements within (in fact it's element with only recttransform on it, let's call it container). So these 2 containers take a half of the screen by height and stretched by width, ok. How can I place an text element in above container and snap it to the bottom of this container? I tried press bottom button in recttransform widget (also with shift and alt) and it seems it doesn't affect my transform at all
P.s. May be I can use some free plugin instead of default unity components of UI layout?
There are different ways of placing your UI elements
Simply drag and drop it to the bottom where you want it
Use the anchor widget to set the anchoring to bottom with horizontal stretch and hold shift to also set pivot. Then set Pos Y to 0. Set Left and Right to 0.
Assuming you also want other elements in your containers, place a Vertical Layout Group on each container and make sure that your text element is the last child of the container in the hierarchy.
I would also advise you to seek out tutorials on Unity UI anchoring, positioning, scaling, and layout. You need a deeper understanding of how these things interact than you are likely to get from Stack Overflow. Otherwise you will suddenly find that your UI behaves in unexpected ways when rearranged or displayed on a different aspect ratio.
It's fairly easy with Unity UI system. You just need to get used to it. Here are simple steps to accomplish what you want:
Create Text element as a child of that container.
Select your newly created element and edit its RectTransform component values:
2.1. Set both Y axis anchors (min and max) to 0.
2.2. Set pivot value to 0 as well.
2.3. Set Pos Y value to 0 as well.
Now your Text element is anchored at the bottom of the container and its position (and height) is measured from the bottom of the Text element itself.

Can't get vertical layout group with scrolling working

I've got a panel which sits above my canvas and slides out upon clicking a button. I want to populate this panel with several objects (the number will be determined at runtime). Since the number of objects can exceed the number that would reasonably fit on a single row of the panel, I'd like to be able to scroll down with the mouse to new rows where the remaining objects have been populated.
To achieve this I've put a Scroll Rect and a Mask on the panel, created a child Image with a Vertical Layout Group to hold a series of child panels representing the rows that would hold the objects, and set the Image as the Content of the Scroll Rect.
The issue is that when I try to make one of the row panels a child of the Image object by dragging it to the Image in the Hierarchy, the anchors for the panel coalesce to a single point (the top left of the Image since it is set to Upper Left alignment) and when I try to manually drag the anchors to the appropriate position a box with a red X in it appears and expands in a manner that doesn't seem to correspond to the direction of the mouse.
Is this the right approach, and if so, how can I get this to work?
Thanks!

How to select multiple layers in Photoshop CS6

I have PSD file with about thousand layers. And I have one selected shape area. And 0 layers are selected. Now my question is how to select only those layers that are in selected shapes. Layer is in selected shapes if part or all layer is in selected shape. Selected shape is non rectangle.
I think it is possible with the ctrl - click. You can hold ctrl and then select layers you want to have selected.
If you are wanting a way to do this by shape area ,either a path or a selection, automatically that is not possible. (There might be a script or plug-in but not one I can think of off-hand.
A possible workaround:
If you select the move tool and check "Auto Select" and "Layer" in the options bar you can click an area of an image and Photoshop will automatically select a layer that contains the content you clicked.
If you hold down the shift key you can select multiple layers (shift-clicking a layer you already selected deselects that layer.) If there is a layer behind another layer it will always select/deselect the front-most layer. To get around this right-click the area that contains both layers, a list of layers in order will appear and you can select the layer you want by name. (see image)
Using this method you should be able to capture all of the layers within a certain area by hand in a fairly efficient manner.
After you have all the layers you want selected you can either group them (which is the best method but doesn't work if you need to maintain their current layer order in relationship to all of the other layers in the document) or you can link them which will allow you to select or move them together in the future.
Not sure if this solves your problem, hope it helps.
Good luck.
Holding Shift key & select your multiple objects
For Single selection:
Click Control(ctrl) button and select your layers.
For multiple selection:
Use Shift and then click your layers.

tkinter listbox drag and drop

I'm trying to make a listbox with the ability to do drag and drop onto a canvas. I've done drag and drop before, but it was only between canvas.create_text loosely based on the code for a this checkers program I found here. I've seen a couple of questions about drag and drop listboxes but they only deal with changing the order of elements in the listbox. What I'm dealing with is a listbox which has a list of names, and a canvas with some create_text objects on the canvas, and I want to be able to drag a name from the listbox onto the canvas. If figure I'd need to make a Listbox subclass, but I'm unsure of where to go from there.
So I've got a DialogWindow (subclass of Toplevel), and have my canvas and listbox in the DialogWindow. I've conjured up a way of getting a name from the listbox: when I click on a name, I convert it to a canvas.create_text object and then drag that. My issue is the drop. I try to use the canvas.canvasx to convert to canvas coordinates but it hasn't worked for me. x and y are still in listbox coordinates.
def onRelease(self, event):
x = self.canvas.canvasx(event.x)
y = self.canvas.canvasx(event.y)
print(event.x, event.y)
print(x, y) #Prints the same thing as the previous line
The key to drag and drop boils down to needing to do three things:
bind on <ButtonPress-1> to select the item to be dragged
bind on <B1-Motion> to do the drag
bind on <ButtonRelease-1> to do the drop
None of this requires any subclassing. All of these bindings are on the listbox widget. You'll probably want to create an instance of Toplevel with a text label in it and the window decorations removed (using wm_overrideredirect(True)) to represent the item being dragged.
On the drop, you'll need to convert the coordinates of the mouse to canvas coordinates using the canvasx and canvasy methods of the canvas. Instead of starting with event.x and event.y (which are relative to the listbox), use the winfo_pointerxy method to get the screen coordinates of the mouse, then do a little math.
Here's an example of how you could do the drop:
def _on_drag_drop(self, event):
i = self.listbox.curselection()[0]
text = self.listbox.get(i)
wx, wy = self.canvas.winfo_rootx(), self.canvas.winfo_rooty()
x,y = self.winfo_pointerxy()
cx = self.canvas.canvasx(x-wx)
cy = self.canvas.canvasy(y-wy)
self.canvas.create_text(cx,cy,text=text, anchor="sw")
self.canvas.configure(scrollregion=self.canvas.bbox("all"))

Evenly aligning things in IB

I have ten labels on a view positioned vertically. I need to evenly space them. Does IB have any type of setting that will do this?
If you select individual labels and drag them around the view, they should "snap" to certain guides around the interface. If you drag an element close to another element it should snap to about 8 pixels away, and that's the standard spacing between elements on the iPhone.
If you want more precise control, you can select an element and use the arrow keys to move it around one pixel at a time.
You can also use the Align Horizontally/Vertically in Container menu items from the Layout menu.
Do the math and then type in the X,Y coordinates. Unfortunately, I think that is the easiest way.
If you are OK using Apple's guideline spacing, dragging one label near another will generate a dashed line at a certain point. Do this for each label below the next, and they will be evenly spaced.