Gdk Screen and add_provider_for_screen - gtk

What exactly is Gdk Screen represent?
My guess was that Screen represent whole display area of the pc and Window represent display area of certain application.
Then what is the meaning of adding provider to the screen in code shown below.I think i m interested in styling only current application window.
css_provider = Gtk.CssProvider()
css_provider.load_from_data(css.encode())
context = Gtk.StyleContext()
screen = Gdk.Screen.get_default()
context.add_provider_for_screen(screen, css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Adds a global style provider to screen, which will be used in style
construction for all Gtk.StyleContexts under screen
this is in the documentation of add_provider_for_screen().
Am i not understanding What screen is properly?

Yes Gtk.screen is the system screen and it handle all the physical screens(multiple monitors). This is that there is one screen for all the monitors(or is the common case); with this in mind, monitors doesn't need to have the same dimensions and, once the application is running it cannot change the style by itself, so this is the screen job. This prevents the application to display annoying sizes along the screen.
So, since 5 pixels are not always 5 pixels, style is something that needs be managed by the screen and not by the window, and all of that without considering the color management.

Related

How can I change the screen size in Unity?

Currently I am working on a Unity project. I started it on version 2018.3.6f1. The other day I installed version 2019.3.0a2 and this changed the screen size so now I have a white background at each side.
If I try going back to the size I had using the scale tool, it does not work so what do you recommend to change my screen size correctly or change it to its original one?
Here is a representation of my problem:
https://imgur.com/a/QKl9kVr
This is related to a setting you can change from the top bar of the Game window, it effectively sets the screen size emulation within the editor to different values, it looks like you want to have 'Free' mode, but you can also check behaviours in any other resolution

Unity grid system woes (How to make grid that auto-collapses to column in portrait mode

My problem is very difficult to describe, so hopefully (with the pictures I provide) someone can help me figure this out. If you are confident you can fix it, I'm willing to pay if I have to. I need this fixed.
I cannot for the life of me figure out how to work with the Unity canvas/layout groups. I have a series of canvases that only show one at a time (think of them as screens). Inside each canvas are components (the first one is a graph and timer, and then a data panel and some buttons.
Here is an image of what I'd like each of the panels to look like (only one of these will be open at a time):
Essentially, I just want each sub-canvas (the dark gray boxes) to inhabit ~50% x 50% of the screen, and when the orientation is horizontal/vertical, tile them accordingly.
Each Child panel (the dark gray) only needs to change. The children inside of the panel can stay and scale relative to the parent canvas.
I have tried EVERYTHING, dug through the documentation, and have run out of options.
Have you tried adding a Layout Element to all of those gray panels with a Flexible Width or Height setting? The screenshot below shows how to have two panels that are side by side, both occupying half the width of their container. (Both have a Flexible Width setting of 1.)
The two Panels are children of the Canvas that has a Horizontal Layout group like this:

Unity - interface buttons "dislocated" from graphics on phones with notches

We're having this weird problem with a game we're porting to mobile: All UI elements work fine, except when you run it on a phone with notches (iPhoneX for instance). When that happens the interface gets rescaled to fit the device's safe area, which creates two black bars on the extremes (which is ok for now). Then, the area in which you have to click to activate any buttons doesn't correspond to the button graphics themselves anymore.
It's as if the input detection area is stretched to cover the entire area of the phone, but the graphics are scaled down, "dislocating" the input touch areas.
The picture below shows the problem:
Notice the red scribbles showing the area that's outside the safe areas, and the green circle showing where the input for the button actually went.
Additional info: for the levels to work properly we have to force the resolution to 1080 using Screen.SetResolution(). Could this have anything to do with the problem?

Keep Graphical Outline when Screen Size Changes

Beginner...
I suppose somewhat related to the question below, I would like the view controller to appear the same on each device with only the size of the graphics changed, (storyboard iPhone 8 vs iPhone 4s)
I've tried my best to read about and understand the Constraints, but with no luck. I add a constraint, then click away from the "Add New Constraints", and when I select the object again to view constraints it appears as if nothing is set anymore, (Constraints added & Constraints gone)
Even if they are sill there, but this isn't how you see them, the image still moves when I check the storyboards or the simulators of two different sized devices.
Any recommendations on how to fix either issue or just somewhere else to look for answers would be well received!
I would like to automatically align all the graphics I've placed in the "View Controller", (Unaligned Storyboard),
and have those graphics resize themselves to maintain their placement when loaded onto a device with a different size screen, (Main Storyboard of two devices)
I've decided I want most of the graphics to only be in the center of the controller.
EDIT
this has been solved
I've discovered how to align the graphics as I desire by clicking the Align "Horizontally in Container"
I'm not sure how or why I didn't see this sooner.
Unfortunately, the graphics still become distorted when on a different sized screen.
I've discovered how to align the graphics as I desire by clicking the Align "Horizontally in Container"
I'm not sure how or why I didn't see this sooner.
Unfortunately, the graphics still become distorted when on a different sized screen.

Resolution issue when building the game

I am using the ViewportHandler script for Unity(https://github.com/dfsp-spirit/way2close/blob/master/Way2Close/Assets/Scripts/ViewportHandler.cs), to allow for my UI to appear the same in different resolutions. I am pretty sure that it was looking just fine and pretty much the same in all resolutions(with different quality graphics due to stretching, but that is fine).
I have opened up my project after a while and I am now noticing that while the game scene looks fine inside the editor, the UI elements change position for all resolutions when building the game.
I am attaching two screenshots to show the difference. The Editor one is the proper one where elements are aligned properly. The other one is when I am building the game and running it full screen.
The weird thing is that when building the game, every resolution displays the wrong way (as in picture 1). So the elements are actually resizing properly, but they are just in the wrong place for some reason and I really can't see why. Any ideas ?
(My Canvas is Screen Space - Overlay, Scale with Screen Size, Ref resolution is 2560/1440, Match width and height and ref pixels 100).
You don't need 3rd party scripts to achieve a constant size on different resolutions. Use the Canvas Scaler component on your canvas and set it to 'Constant Physical Size'. Unity should handle all the rest.
If images/sprites change position, try to change the anchor point to fit your needs.