I am trying to change the size of the UI Elements within a UWP Window on the change of the size of the window itself, such as clicking the edge of the window and dragging right. However, on increase of size, there seems to be Bounds set on the creation of the Window for the maximum size of the content, is there anyway to bypass this Bounds?
Try setting the UI Element's HorizontalAlignment and/or VerticalAlignment to "Stretch". Alternatively, if you want to scale it too, you may put the whole thing in a ViewBox. There are really quite a few options to achieve what you want.
Related
To keep things simple, let's say I have a window containing a single view, which has auto layout constraints binding all 4 sides to the window container view with offset 0. And assume that this view also has a constraint setting its aspect ratio to a constant value. If I resize the window manually, then then window nicely maintains the desired aspect ratio. But if I click the little green zoom widget, then the window fills up the whole screen, regardless of the aspect ratio, with part of the view being above the top of the screen. Is there some way I can make zooming resize the window as big as it can be, without violating auto layout constraints?
I couldn't very well detect this problem in the delegate method windowWillResize:toSize:, because that doesn't tell me which screen it's thinking about putting the window on. I could try to fix the window size in the windowDidResize: delegate method, at which time I do know what screen it's on, but I'm not sure exactly how to do that without reinventing Auto Layout's wheel.
Apparently someone thinks I wasn't explicit enough, so I'll try again. Steps to reproduce:
In Xcode, create a new macOS App project using XIB interface.
Open MainMenu.xib and select the window.
Reshape the window to be approximately square.
Using the Attribute Inspector, set the Full Screen behavior for the window to Auxiliary Window.
Drag an Image View from the library and drop it in the window.
In the Attributes Inspector, set the image view to show the NSComputer image and scale axes independently.
Expand the image view to fill up the window content area.
With the image view selected, click the button to add new layout constraints.
Add 5 constraints, binding the 4 sides to the container, and setting the aspect ratio. (see screen shot)
Build and Run.
Observe that if you resize the window by dragging an edge or corner, the aspect ratio remains fixed.
Click the green zoom widget in the title bar of the window, and observe that the window expands without regard for the aspect ratio constraint, cutting off part of the image.
I just set up a test project exactly as you specified, and when I invoke the window zoom widget, the window expands and retains its aspect ratio i.e. it works as expected. The only thing I can think of that might be causing your issue: maybe your content hugging and content compression resistance priorities are at odds with your constraints? Mind you, I just left them at the default values and it worked fine. Unfortunately Mac/AppKit development (esp. when using IB) is rife with these kind of odd bugs and weird behaviour, probably because Apple has not given it any love in years, so bugs creep in/fester and they are clearly so DONE with developing UI the 'old fashioned way'. (Using SwiftUI to make a Mac app is just as frustrating, in different ways, so I'll stick with what I know). FYI, I used Xcode 13.4.1 to create this test project. Good luck!
I'm trying to create an application that would be as standard as possible in terms of style.
An image is worth a thousand words: I can't figure out how to make my buttons the same size as in Apple's programs such as Safari or Finder.
As you can see, the sizing I've set in interface builder don't seem to match the size the buttons get when I run the app, but maybe that part doesn't speak in pixels but in points or something? Also, textured rounded button has only width editable, but not height.
In this case, these are NSButtons, but I guess I'll have a similar problem with other control types...
I found it out! The problem was with neither of these two parts outlined in the screenshot, but in the "Toolbar" item, higher in the hierarchy.
There is a Size attribute in the Attributes inspector which defaults to Small, but you can set it to Regular instead, and then the buttons get the same sizing as in Finder and all.
I have a Window and a WrappingTextField.
I want the WrappingTextField to always fill the entire Window. Even when the user is resizing the Window, and when it is in full screen.
No matter which options or constraints I choose in Auto Layout, it only resizes with the Window horizontally, but its height remains the same, even if the height of the Window grows.
How do I make it fill the entire Window, and stay that way?
By WrappingTextField I'm assuming you mean an a standard NSTextField object with it's Layout set to Wraps within Interface Builder.
The resizing behaviour of an NSTextField is influenced by its Content Hugging Priority. By default Interface Builder sets this at 750 for the control's Vertical dimension, and this is probably what's preventing your text field from resizing the way you want it to. Give it a smaller value - like say 100 - and the problem should resolve.
Like the topic said I'm having problem with window resizing event. Basically I want to my content fit window size. However not everything works like it should. Changing window mode for instance maximizing or resizing is handled by client event listener. The problem is that when I'm resizing everything works ok, but maximizing/restoring only changes window size and the content doesnt fit at all. What is the solution for this type of behaviour?
ps. Changing browser's window size fire the content to update.
Normally you don't need to use resize listener to do layouting in Vaadin Window, usually full size layouts (width and height are 100%) and expand rations are the concepts you need.
If you really need to use window resize listeners, you need to use a WindowModeChangeListener. That's fired when window mode is changes. There is a method called addWindowModeChangeListener in Window.
Using visual studio C++ 2010.
Currently in a window in MFC code I have a grid. I want the grid to "become smaller" if I resize the window (drag the corners manually), but as I resize the window the grid actually is completely static, so e.g. resizing the window to a very small size will cause the edges of the grid to become outside of the window's visibility.
I noticed that the other "objects" within this window (notably, the MFC buttons I have such as "cancel") do scale with the window and don't go out of sight when I resize the window to a smaller size. They follow the window's edges as if they were given smart relative coordinates instead of absolute coordinates that my grid follows.
Currently I am using the grid here http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27 although I highly suspect it is not the source of the problem (there is an example code that uses it, and the resize behaves as expected; I cannot compile it but I ran the exe example). I recently switched from MSFlexGrid (because it doesn't support 64 bit) but in the previous version when I used to use MSFlexGrid, it didn't have this problem either.
I thought it might be some sort of window property or object property in the .rc file but I compared the files and found no leads.
There is no such a thing like a window property that tells window to adjust the size to the size of the parent.
If buttons change size and position, you are probably using some kind of class that takes care of resizing of the child controls.
Follow the same for your grid, or notify grid about the parent size change and adjuxt grid size accordingly.