2 ScrolledComposite side by side. - swt

I'm building a welcome editor for my eclipse rcp application. I want to have two ScrolledComposites sit side by side with a label above each.
Label 1 Label 2
Scrollable 1 Scrollable 2
Now I'm stuck in how to box.
This seems right but now I can't get the layouts and listeners right.
Composite A
Composite A1
Label 1
Scrollable S1
Composite A2
Label 2
Scrollable S2
A1 should set the min Size of Scrollable S1 right? But who sets the size of S1 so that it fills the excess space? The examples I found didn't work right.
BTW putting everything in a GridLayout didn't work either since I couldn't get the cell size.

BTW putting everything in a GridLayout didn't work either since I couldn't get the cell size.
Why would you need the cell size? Just set GridLayoutdata for S1 and S2 to fill the cell. It's simplest to use GridLayoutFactory:
import org.eclipse.jface.layout.GridLayoutFactory;
...
GridLayoutFactory.fillDefaults().applyTo(s1);
GridLayoutFactory.fillDefaults().applyTo(s2);
...
UPDATE: See examples at http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/ScrolledComposite.html
Let's say content of s1 is a Composite c1. Then you use s1.setMinSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT)). Size of A1 is irrelevant.

Have a look at the SWT Snippet for "fixed first column horizontal scroll remaining columns" - although this example is for Tables, it can easily be translated to ScrolledComposites.

Related

Resizing Panels in proportion to form

I am developing a Delphi game for my (grade 10) PAT.
I am using an image as a grid for my game and placing individual panels in each grid because I do not know how to use string grids as it's my first year with Delphi. When I place the panels perfectly in each grid of the image and run my code everything looks normal until I go full screen,then all the panels are in each grid but the size is not in proportion with the image as I placed it before.
A solution would be much appreciated.
Thanks in advance.
Use a TGridPanel in place of your image. Each panel goes into one cell of the grid, and with the column widths and row heights set as a percentage (which is the default), and both the grid and the panels in the grid having Align set to alClient, the cells, and therefore the panels, will adjust their size proportional to the entire form.

Desktop flexible grid amount of content in a row

I have problem designing inside a flexible a grid where it can go from 3 item in a row on full screen to be 1 item in a row on the smallest allowed size of the application, is there a widget or guide for this?
use ResponsiveGridList from the package https://pub.dev/packages/responsive_grid.
It is simple and well documented. I used once already, it fitted my needs perfectly.

AgGrid: fixed header with pinned bottom rows

I'm using ag-grid-community v.25.1.0 with 2-rows header and 5 pinned bottom rows.
I want the grid header to be always at fixed position - even when I scroll to the last data rows of my grid (which are often far below the screen bottom).
Unfortunately this forces me to set 'height = 100vh' for the grid - but then the 5 pinned bottom rows also occupy screen area, so there's too small height left for the data rows (about 10 data rows left when I'm using my 13-inch laptop). See demo #1 at https://codesandbox.io/s/aggrid-issue-demo-j9ls9
And if I do not limit grid height with 100vh - then the pinned bottom rows go ouside the screen together with the data rows (because AgGrid's OWN vertical scrollbar is no more shown) which is OK except for... scrolling down the vertical scrollbar of the grid's container (body tag) moves grid's header outside the screen (although "I want header to be always at fixed position" - see this requirement above!). See demo #2 at https://codesandbox.io/s/aggrid-issue-demo-2-52bo3 - it would be OK if header stayed at fixed position.
If there were no pinned bottom rows - the problem would not exist. But these pinned rows are really necessary in my app; however the fact that they occupy ~33% of the grid's height - is a real problem. Yes, I can make row height smaller (together with the font used to paint the cells) - but that's an ugly workaround, not a real solution. I can also provide users with a possibility to show/hide some of the pinned bottom rows (using several checkboxes) - but this "solution" also smells (besides, in most cases all 5 pinned rows are needed).
Is there any solution? maybe I can adjust header's CSS so that it's Y-coordinate stays strictly fixed? in such case removing 'height = 100vh' would solve my problem...
UPD: maybe it makes sense to describe the difference between demos #1 and #2:
App.css:
added this file to override the ".ag-root-wrapper-body.ag-layout-normal" style - because it had height set to zero
App.tsx:
added import for App.css (see above)
removed div style "height: '100vh'"
index.html:
removed body style "overflow-y: hidden;" (to enable vertical scrollbar which is needed to access last rows after we removed '100vh' above)

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.

gtk treeview column resizing and horizontal scrollbar

I have a gtk treeview (inside a GtkScrolledWindow) with two columns.
If I set both columns to the default sizing policy, I have a horizontal scrollbar for the treeview but the columns can't be sized down by the user, which is impractical.
If I set both columns to setSizing Fixed, fixed width 120, I get a nice display and the columns can be resized, but there is no horizontal scrollbar in the treeview (since the columns size down to fit in the width of the treeview I guess).
If I set the first column to setSizing fixed, fixed width 120, the second one to automatic, only the second column is displayed (???).
I would like that by default the first column takes let's say at most 60% of the display, the second column can go all the way and I have a horizontal scrollbar. Certainly I want the user to be able to resize them up or down, not as with the default policy, that you can resize them down!
That's why I tried the first column fixed, the second automatic, it was promessing but I don't understand why the first column is not displayed at all in that configuration.
I add the cell renderers with packstart true, I tried false but it didn't change anything, also I tried setting the expand for the columns to true or false, which didn't have any effect.
Note I'm using the gtk2hs haskell bindings but I'm certain it would be the same in any other gtk binding. Just mentioning if people will ask for code samples.
I'm pretty sure this is a common problem... I'd say nautilus is fixing it the way I'd like to fix it, but I think digging in the nautilus source is going to be quite long...
EDIT well i've discovered the cell renderer's ellipsize setting also has an effect. Setting it to end for the first column and none for the second should be what i want but then the first column is very small and cannot be expanded through resize...
EDIT2 well for now i've moved to word wrapping for the cell renderer, that way i don't have to bother with a horizontal scrollbar... Still curious for the solution to that question though.