I've been running into a pretty consistent problem with how views inside HStack work, with a simplified screenshot to exemplify the issue.
My expectation would be for the width of the green to basically be (expressed like an equation):
Section.width - Image.width
The section width is fluid, and the image width is explicit. Surely that means the green should be correctly calculated?
Any help with what seems to be a basic misunderstanding on my part would be hugely appreciated.
Actually you're right, but there are just default List/Form insets, which can be either changed or removed.
So all you need is
that gives on Xcode 13.4 / iOS 15.5
The height property in your frame for the image is messing with width dimensions. By setting the maxHeight to be infinity, the height property will expand the image to the max possible height, meaning the height of the section, even if it changes the width. You can think of it as, in a way, overriding the ability of the text to stretch its full width.
To fix this, consider changing the maxHeight property by adding a set height, or play around with different types of frames dimensions.
I know this doesn't talk about HStack's specifically, but feel free to check out this video to learn more about layout: https://www.youtube.com/watch?v=zczHBLtpRZo
If you want to launch an app on the app store, you may want to consider learning Geometry Reader to have dynamic dimensions across different screen sizes. This is a tutorial from a really good website, hacking with swift: https://www.youtube.com/watch?v=WNO1b58k7zg&t=505s
Related
I’m a big fan of Firefox’s mini grid view in the web inspector, which provides
a small version of the currently overlaid grid, which is in proportion to the real thing.
Hovering over the different areas of the mini grid causes the equivalent area on the grid overlay to also highlight, along with a tooltip containing useful information such as the dimensions of that area, its row and column numbers, etc. [my emphasis]
It bugs me to no end, though, that the tooltip emphasised in the quote does not appear if the highlighted grid row/column is too close to the viewport’s edge. Instead of adjusting for this by moving the tooltip into view, the behaviour seems to be just to not show it at all, which rather defeats the purpose – especially when, as far as I know, this tooltip is the only way to see the calculated size of empty grid tracks.
I can’t find any bugs regarding this on Bugzilla, but then I can virtually never find anything on there, so there’s a decent chance I’m just bad at searching.
Is there some setting I can’t find that will allow me to see the tooltips even for edge rows/columns? Or if this is just a bug, has it been addressed?
I've tested this in Firefox 98.0 and could reproduce it. As this is definitely a bug in the Firefox DevTools and I couldn't find one either in Bugzilla, I now created a bug report for it.
I need to create multiple charts, where the graph area is exactly the same height (but other chart element heights can vary).
What kind of method could be used to achieve this functionality?
By default Chart.js aims to fill the canvas height when drawing elements which makes the graph area height dependent on the canvas height and other chart elements like the title height and legend height.
This problem has been discussed on Chart.js GitHub (https://github.com/chartjs/Chart.js/issues/3458), the devs seem to agree that this fuctionality should be handled by a custom plugin and not by the core library anyway.
I'm a bit lost. So far I've tried to modify the y-scale height, maxHeight, padding, margin etc. in beforeFit and afterFit -hooks, but those don't seem to do anything. I just don't seem to grasp how the height setting is handled in the source code and how to go about overriding it.
I have a CListCtrl control (or a ListView in Win32) that is created with LVS_REPORT style.
I am intending to display icons in its items as such:
But the question is what size of icons do I need to make and load?
Let me explain. From the old Win32 samples, I can see that everyone creates image lists with 15x15 pixel icons. But the issue with those is that it looks horribly pixelated on any modern PC with higher DPI settings. Thus I was looking for a dynamic way to determine the appropriate size of image lists for the CListCtrl.
And also the first part of the question, what icon size should I make originally?
EDIT
PS: Since DPI scaling came up, how do you find it out? I'm currently using the following approach:
//No error handling for brevity
HDC hDC = ::GetDC(hAppsMainWindowHandle);
int nCx = ::GetDeviceCaps(hDC, LOGPIXELSX);
int nCy = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hAppsMainWindowHandle, hDC);
//I technically get horizontal & vertical scaling --
//can those be different?
double scalingCx = (double)nCx / 96.0; //1.0 = 100%
double scalingCy = (double)nCy / 96.0;
Is font scaling something different?
A list view uses a "small" or "large" image list depending on its mode. In report mode, it uses the "small" image list. You can use GetSystemMetrics() to get the dimensions of "small" images using the SM_CXSMICON and SM_CYSMICON metrics (use SM_CXICON and SM_CYICON for "large" images).
Note that the returned values will be virtual/scaled if your app is not DPI-aware, so to get accurate values, make sure it is DPI-aware via SetProcessDPIAware(), SetProcessDpiAwareness(), or a DPI manifest.
Update: I just ran across this function, might be useful for you when writing a DPI-aware app:
LoadIconWithScaleDown()
Make larger images and let the API scale them down to smaller sizes.
The report style list view wants small icons, that is icons with SM_CXSMICON by SM_CYSMICON metrics. Assuming your app is high DPI aware, then the actual value of these metrics depends on the user's chosen font scaling or DPI setting. So up front you cannot know what size icons should be used. You have to query the system metrics at runtime, and use appropriately sized icons.
Now, what size icons you include in your executable depend on what DPI settings you wish to support. Back in XP days you could reasonably expect to encounter 100% and 125% font scaling. These days, high density display panels are common and you really need to support larger ratios. At least 150% and 200%, and quite probably 175%.
The closest I can find to guidelines is in this MSDN article: http://msdn.microsoft.com/en-US/library/windows/desktop/dn742485.aspx
This article was written around the Vista time frame and already shows its age. I think you have to use these articles as a guide and adapt to the hardware of the day.
You will also find that people run their machines at font scaling values in between the round numbers listed above, and in the article I link to. One of my colleagues runs at 120%. Interestingly this has highlighted various bugs in our code so it's always useful to have someone dog-fooding your program.
When you build your image lists at runtime, size them according to system metrics. And try to avoid scaling icons. For instance, if system metrics suggest an 18px icons, and you only have 16px and 20px icons, then make a new 18px icons. Fill the image with transparent pixels, and blit the 16px icon into the middle of this 18px image. Make the icon out of that. This approach will avoid aliasing problems.
When I use iCarousel type linear, and wrap is true. I am getting an UI like below:
The problem, I am facing is at the top the number 998 UI is broken, but I want visible 998 number without increasing iCarousel height. So, how can I achieve this? and one more thing I don't bother about UI might break for number 2, if I want a visible 998 number.
There are two reasons why your carousel item is cut off:
1) Your carousel view is not vertically centered in the window. If you center it, 0 will be dead centre and 998 and 2 will both be cut off, but equally
2) You need to set the item view size to exactly fit your view. You're currently using the default images that come with the example project which are 200x200 pixels in size. Presumably you will eventually replace these with your own views. When you do, make sure the size of those views is an exact division of the height of your window, so for example if your windows is 1024 pixels high, and you want to show 5 views, then they need to be 1024/5 pixels high (204.8 px). Obviously that's not a nice number, but you can make them a bit smaller so that they are a nice round number and then adding some spacing between them using the carousel delegate method.
I'm thinking like text fade in and slide effects. I imagine implementing this would be rather trivial and plan to do so myself, but wanted to make sure I'm not reinventing the wheel first. If it doesn't exist then I'm looking on advice on the best way to implement these.
The 2 things I'm looking to do are fade in text and have the window slide down when resizing, eg if I show a label that was previously hidden it would slide down ~20 pixels instead of just instantly growing 20 pixels larger.
The way I was thinking to implement the first one is, assuming it's possible, get the window/bg color and start it at that and transition it to the font color, if there's alpha channel support that would be even simpler to do (I'm not sure if there is since I haven't messed with colors yet). To do this I'd just choose a transition time period and process it with a for loop or something once the color increments have been determined.
Similarly to do the window transitions I would get the height of the change (not sure how to do that yet), determine the increments of change based on the transition time and in a for loop gradually adjust the size. Sorry if I didn't explain those very clear, I'm trying to get this in before I go to work and figure most of you will know what I'm trying to explain. As always thanks for the help!
For window resize transition effect, QPropertyAnimation may be the easiest to do since height is a widget property. Fading text might work the same way if the foreground color can be coerced into a property.