Unity3D. How to move elements inside Vertical Layout Group? - unity3d

I want to create chat window, and the messages must appears from side. So now I have the system with messages that placed inside of UI element with Vertical Layout Group, but I can't move the messages in horizontal axis, because position of messages is driven by Vertical Layout Group.
I had tried to do it by changing paddings but it works very ugly and I can't add messages into chat window and move them at the same time.
So is there a way to create custom appearance of messages in chat window that driven by Vertical Layout Group?

Instead of putting the labels directly into the VerticalLayoutGroup, put each of them into a seperate container, called ChatLine. ChatLine is just an empty GameObject with a RectTransform. Those ChatLines you put into the VerticalLayoutGroup.
VerticalLayoutGroup
ChatLine
Label
ChatLine
Label
VerticalLayoutGroup will arrange the ChatLine objects, putting one below the other. How you arrange the Labels contained in each of the ChatLines is up to you. You can move them horizontally as you please to create the effect your want.

Vertical Layout Group has its limitations. You can look for more properties in VerticalLayoutGroup class via scripting but most likely you just have to create your own layout so you will have full control on position of every element.

Related

What should I look out for when combining Autolayout and positioning in iOS?

I am working on an iOS project that uses auto layout to set up a view with a scroll view and a stack as the scroll view's content.
All works well, and I can add UIViews until the cows come home to the stack and it does what is expected.
However the question now arises when I am about to implement the user-definable layouts for the reporting view.
The stack holds a view dedicated to user defined layouts.
The user will define the data output (for example "benefits") and the origin (top left corner) and that view will be placed there. They can place as many or as few views and pieces of data that are made available to them in this manner. They will have no understanding of auto layout and hence will solely rely on the exact positioning of these views via the top left corner and their size.
Is there anything I should be aware of before starting this phase of the project? My concern is the mixing/matching of auto layout in the global layout and exact positioning inside this one specific view.
Looking for input on caveats, code that I MUST include (for example any flags that should be set) and so forth.
Thanks for any sort of help,
D
Thanks for all the suggestions.
My concept was a little to involved for the suggestions given, however I did develop a solution that allowed the user to position the widgets by origin (top left corner) while still using AutoLayout.
For those interested, I created a "dummy" UIView to hold all of the user positioned widgets and then created Autolayout constraints based on the top and left anchors of this view.
Since the widgets are created by reading the layout from a Dictionary, if they make changes to the layout, I simply remove/refresh the layout if they make a change.
Thanks once again for the nuggets, without which I would not have thought of this solution.
D

Adjusting height of GWT Panels based on content

We have many screens where different types of GWT panels are used.
One common problem across many screens is that, content size is derived at runtime. So, if I define a height for a panel(Vertical/Horizontal/DockPanel) and when any new components are getting added within panel or content is more, panel height remains the same. So we are not able to see the contents. UI look and feel becomes worst.
How do we handle the height problems? Do we have to manually code to adjust every panel/widget height when something gets changed in screen. Is it not a very bad way of coding?
Also, now we have datagrids at some places, if no of records are very less, we see a huge space left out below datagrid, not sure how do we handle these cases?
Updated below with few examples as per the comment:
Do you mean to say that whenever we know that content grows vertically, we can always choose FlowPanel. Because, some of the screens we have used Vertical panel/Horizontal Panel and inside that when user clicks something a new fields getting added and shown. So Vertical Panel/Horizontal Panel height automatically not getting adjusted. One more example is that we have main Vertical Panel within a Dock Layout Panel content area and inside that there are some widgets whose content may vary. So now if I use a FlowPanel to the content which varies in size, what about outer panels? Will get it adjusted? Again to say the kind of panels we have used - Dock Layout Panel is used with fixed header, footer, left menu and Content area. A scroll panel is used within Content area. All our different widgets go inside this which is mix and match of horizontal/vertical/datagrids..etc.
In GWT (and HTML) you can either set the height of a panel or let it expand naturally. In general, once you set the height of something, you lose the ability to let it expand naturally.
Some Panels in GWT implicitly set their own height (or require that you set their height) and so are never good choices for dynamically sized content. LayoutPanels and ScrollPanels, for example, can never adjust dynamically, and expect you to provide size information programmatically. FlowPanels and HTMLPanels, on the other hand, are great for dynamic heights and would rather you not set their height explicitly.
If you want a scrolling panel, of course you have to define how high it should be - how else could it know when to scroll and when to just get bigger? But, you can put a FlowPanel (which expands automatically) inside a ScrollPanel (which you have set at 800px or whatever). Then, as you add content to the FlowPanel, it will expand inside the ScrollPanel. Users can then scroll to see different parts of the FlowPanel.
Trouble-shooting tips:
Make sure you aren't setting the height on panels that you want to expand naturally
Make sure you ARE setting the height on panels that should always be the same size
Try using FlowPanels instead of Horizontal/VerticalPanels
*LayoutPanels and AbsolutePanels always need explicit sizes and can never grow dynamically as you add more content. Anything you want to grow with content should probably be a FlowPanel or HTMLPanel.

How to Make Container Fill The Form in LWUIT

I have a Form that take a BoxLayout, to be able to add different custom controls one after the other in the Y-AXIS
but there is a Component that I need to add in the bottom of the screen, but as I'm using the BoxLayout so I can't fix it size to bottom of the screen
So I think that I can set that Container of the control to fill the parent Form
So the question is how to make Container fill the parent Form in LWUIT
Thanks in Advance
Why don't you try to put a BorderLayout in the Form?
You can put Containers in CENTER and SOUTH positions, and they let you place your controls as you want (BoxLayout Axis Y in the center).
Is that what you want?

Impossible custom layout in gwt?

I want to create a custom panel/layout and it's seeming pretty impossible at this point. I need the components to start in the upper left corner and stack downward until they fill the panel vertically, then wrap to the top of the next column and so on until they eventually fill the screen and create a horizontal scrollbar. After an entire day of trying I've decided it's only possible by abusing GWT (and I assume the whole web browser) adding crippling complexity and terrible performance. Please let me know if I'm missing something and layout like this is possible. Thank you!
Lame solution: Have a small (almost invisible) AbsolutePanel where every string is displayed within a div and measured (getClientWidth/height()). Then each panel can calculate it's size based on the strinsg, borders, padding, etc. it contains. Once each panel knows it's size, they can be layed out relative to the sizes of the other panels in the contianer.
Check out FlexTable, which allows you to specify the row,column for the widget to be added

Vertically add elements to a scrollview: diffs between Java and iPhone SDK?

Folks,
coming from the Java/Swing world, I am sometimes puzzled by the UI programming on the iPhone. I've spent the last hours with Googling for information but it seems that I asked the wrong questions by thinking too much in Java. Could you please point me to resources to get more familiar with the GUI concepts to be able to achive the following functionality:
Basically, I want to create a vertically scrollable view that represents structured text (for example, a recipe). Each step consists of a title and a textual description. As I want to fold and unfold such steps, the title would be somehow interactive and by clicking it the description would be displayed or hidden.
In Java, I would create a component that renders one such section. The layout manager would compute the components preferred height (with or without description being displayed).
Then, in Java, I would create a panel with a vertical layout manager and sequentially add my components. This panel would be placed in a scroll pane; the scroll pane would ask the panel to layout itself and then show a viewport on it, if for example the height is bigger than the scroll pane's height.
What Java provides me is:
layouting of elements (computing their preferred height and width), thus no need to deal with coordinates and dimensions
dynamic creation of UIs by creating and adding components during runtime
What I understood on the iPhone:
I can dynamically add views as subview to a view, e.g. a scrollview by calling addSubview
I can even remove that stuff using removeFromSubview (as explained here Clear content of UIScrollView)
What I don't understand on the iPhone:
does one view always correspond to a visible screen (I did use tab and navbar navigation so far and there whenever I set a new view, it fills the current visible screen minus the space needed for the two bars)?
or is it possible to define a view that contains a label on top ("north") and a text in center; if so, could such a view automatically determine its height?
can I realize my example in a similar way like in Java or would I need to calculate all dimensions and coordinates of the individual components on my own? (This example seems to touch on that topic: iPhone scrollView add elements dynamically with id)
Alternatively, could I use a WebView and render my stuff as local HTML using JavaScript to show or hide nodes?
Thanks for any hint or link!
There are no layout managers in Cocoa, views are being reposition according to their struts and springs settings. For information on that read the documentation: http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html
To create a "view that contains a label on top and a text in center" you create a view with subviews - one being a label at the top, second the textview in center. If you configure struts/springs for all of subviews properly, they will autoresize when the container view is resized.
You should also get accustomed to Interface Builder, creating views in code is real pain in the ass.