Flex Slider full height and width without stretching - height

I need Flex Slider to occupy the entire page, like the one on this website: http://webfire.co.uk/
I've set both height and width to 100%, but when I re-size the page, it causes the image to distort and stretch. However, setting the height to auto leaves a white space underneath the slider, so it doesn't fill up the full page. The same thing happens with background-size:cover - the width becomes responsive but the height stays the same.
On the website above, they manage to sort of re-center the image when the window is re-sized.
Any suggestions? :)

Related

Draw.io autosize by keeping width fixed, and expanding height if needed

Is there a way in draw.io, to autosize a text container, keeping it's width fixed, and telling draw.io to only adjust the height if neccessary?
I tried out almost all options in the properties of the text box, but when I apply the autosize, it always overwrites my set width and height, by making the width larger, and the height smaller.
I am putting these texts inside a swimlane, and what I would like to achieve is, either:
when I add text to these text rectangles, the rectangle and the swimlane should expand automatically, but only vertically, ie, only the height of it should change (this would be the best for me, so that it is automatic)
if the automatic solution is not achievable, I would be happy with something like manually pressing the autosize button, and draw.io should keep my width fixed, and change the size of the height only.
Couldn't find any documentation anywhere. But I notice that the behaviour of auto wrap is different depending on the object type that you choose. For example,
The above one is a "Rectangle". it won't resize the width when auto-sizing. The bottom one is a "UML/Object". It will resize both the width and height.

MFC - CPropertyPageEx and scaling (4K monitor)

I'm upgrading an old MFC app to support 4K monitors. According to what information I can find, CPropertySheetEx 'implements Wizard97 style functionality'. It's a dialog with Previous and Next buttons and a banner.
Now MFC has done a poor job of scaling this dialog and I'm not sure what control I have over it.
4K is usually 200% scaling. The banner height is unchanged at 59 pixels (so is too small on a 4K monitor). The rest of the dialog seems to have scaled to about 150% (width, height).
I've tried SetWindowPos on the banner. This doesn't resize it and causes other dialog issues.
There's this note in the code, which makes me think the banner is dynamically constructed with the property sheet.
// If the page has a header, we need to paint the area above the border.
// By inspection (Spy++), the border is a static control with ID 0x3027
CWnd* pTopBorder = GetDlgItem(0x3027);
Any suggestions or guides would be appreciated.
The app is DPI aware. Many MFC components scale properly (some need some work)
Question - How can I get CPropertyPageEX dialogs to support scaling?
Here's an image ![Scaling Issue]https://imgur.com/a/Ww8SLnU
Edit -
The icon and the text in the banner can be resized and repositioned, only the height of the banner seems stuck at 50 pixels.
CPropertyPageEx is defined as CPropertyPage in MFC 11. It's derived directly from CWnd.
Having a look at the sources for CPropertyPage (atlmfc\src\mfc\dlgprop.cpp) there's no constructor where it creates buttons or banners (so I may be looking in the wrong place).
A PropertySheet seems to consist of
a graphic (user supplied),
a horizontal bar (static control),
a dialog resource from the Property Page currently displayed
another horizontal bar
a series of buttons (Prev , Next etc)
Have a look at my high def screenshot https://imgur.com/a/yR97H96
The dialog and controls have rescaled
The vertical position of the horizontal bar and the property page are both unchanged from the unscaled version, leading to the ugly overlap you can see.
.

GTK Treeview fixed width

I have a window structured in the following manner:
Window>VBox>Scrolled Window>Tree View>Columns
My issue arises when I label the last column (it must be a dynamic assignment). If the label winds up being too long, the containing window gets stretched horizontally. Instead, I would like a scroll bar to appear at the bottom of the Scrolled Window to deal with it, leaving the window at its original width.
However, it looks like the closest I can come is fixing the height of the Tree View. Surely there's a way to fix the width?
Do you have some code to look at? I have done this many times in python and never had any trouble. Also, you link to the fixed height property of the Tree View rows, you actually need the requested width property of the scrolled window. That link also has a link to set the size of the window.

QScrollArea vertical sizePolicy - Fit contents up to maximum height

I've had a real challenge getting QScrollArea to take the minimum space possible up to a maximum height.
My GUI model is as follows: A QScrollArea contains a vertical layout which is populated with a widget of class TableRow. I want this class TableRow to take up the minimum height possible. It has a widget at the top which is always visible, and a QScrollArea below which has a label inside it whose visibility can be toggled. The label is for notes which may be 0 characters or may be infinite in length (hardware limitations aside).
I've found that for a label in class TableRow setting the vertical sizePolicy to Fixed will actually take up exactly how much it needs to fit all the contents (see: Qt Layout, resize to minimum after widget size changes). However this doesn't appear to work with QScrollArea. In fact every sizePolicy I've tried keeps the QScrollArea at a fixed height; except for Ignore, but then the QScrollArea goes to a height of 0, regardless of its contents.
I've created a git branch producing a simplified version of this problem.
Here is the result of applying a fixed vertical sizePolicy:
What I'm expecting from this test case:
The first widget's height should be almost 30px (the height of the upper widget) only showing the borders for the QLabel and QScrollArea
The second widget's height should be shorter than 130px (the maximum height of the QScrollArea being 100px) but large enough to show the label without scrolling
The third widget's height should be 130px, and the scrollbar should appear (this part is correct in every case I've tried except for when the vertical sizePolicy is set to Ignored )
I understand I may need to override some things to make this work, as by itself it's not obvious why a QScrollArea's height might be dependent on its child widgets (which is probably why it was not designed to make this easy, or at least it seems like it wasn't).
However, I think the case I'm trying to make is common enough, and my current approach is justifiable. If there's another/better way to make an individual widget scroll after it reaches a maximum height I'm open to that as an answer, provided it meets the three conditions I'm expecting.
This feels more like a hack than a solution, but it does work for me, at least in the short term. Because the text for lblNotes does not change runtime, I was able to add the following code in the constructor of my TableRow widget:
// Hack to resize QScrollAreas
ui->lblNotes->adjustSize(); // Otherwise lblNotes will think its height is still ~0px
int height = ui->lblNotes->height() + 12; // Borders and margins add up to 12px
if (height > 100) { height = 100; } // Cap the height at desired maximum value
ui->scrollArea->setFixedHeight(height);
Should I have to deal with the case of dynamically set text, I could wrap this in a function to be called anytime the text of lblNotes is set.
I'm still open to solutions that involve using the layout features Qt has natively as I believe that would be preferred if a solution exists. Some QScrollArea contents may not be as straight-forward to determine the height from in the future.

Scaling graphics in Qt

I am writing a scheduling-type application using Qt/C++ and want to display weekly schedules in one part of the window, and have this rendering scale as the window size increases. The renders will be composed of rectangles with text in them, and as the display area increases the rectangles should scale nicely while the text should remain the same size.
I have experimented with QGraphicsScene and QGraphicsView and I can make rectangles and text scale; however, the rectangle scaling seems ugly (stretches the outline) and I don't want text to scale at all.
I suspect that I might want to resize the scene to the display area and re-draw the rectangles and text; however, I am not sure how to do this - QGraphicsScene doesn't seem to respond to resizeEvent. Is this even the right approach?
I'm not sure what the ugly rectangle scaling is about (a screenshot might help me understand better what you meant there), but if you don't want the text parts to scale, you can accomplish that by calling setFlag(ItemIgnoresTransformations, true) on your QTextGraphicItem objects.
As far as automatically rescaling the rectangles in response to a window resize, you might take a look at the documentation of the QGraphicsView::fitInView() method:
Scales the view matrix and scrolls the scroll bars to ensure that the
scene rectangle rect fits inside the viewport [...] It's common to
call fitInView() from inside a reimplementation of resizeEvent(), to
ensure that the whole scene, or parts of the scene, scales
automatically to fit the new size of the viewport as the view is
resized. Note though, that calling fitInView() from inside
resizeEvent() can lead to unwanted resize recursion, if the new
transformation toggles the automatic state of the scrollbars. You can
toggle the scrollbar policies to always on or always off to prevent
this (see horizontalScrollBarPolicy() and verticalScrollBarPolicy()).