-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/exp/shiny: no API to change a window size #13339
Comments
Given there is the What if that type were simply |
cc @nigeltao First off, adding a Size method will have to wait until https://golang.org/cl/17055 is done and is more about how much state the Window object should track and make available. I'd like to punt that to another issue if you don't mind. As for Resize, having a way to do it is reasonable. But there are several other related options and I'd like to think through how those work in an API. For example:
Do all of these have to have their own methods? Can (or should?) they be combined into an Options struct? Additionally, there's going to be a lot of overlap between these features and NewWindowOptions. Is there any overlap that can be reused? |
The first issue that comes to mind with a combined options struct is what zero values mean. If I have a window specifically sized at 400x300 and I simply want to update the window transparency, I might expect |
for this, the functional-options idiom is probably best: // ----------------
package screen
var (
WindowSize func(Window)
WindowTransparency func(Window)
)
// -----------------
package mydriver
func (s *screenImpl) NewWindow(opts ...func(w screen.Window)) (screen.Window, error) {
// ...
}
func windowSize(width, height int) func(w screen.Window) {
return func(w screen.Window) {
xw := w.(*windowImpl)
xw.width = width
xw.height = height
}
}
func windowTransparency(v uint16) func(w screen.Window) {
return func(w screen.Window) {
xw := w.(*windowImpl)
xw.setTransparency(v)
}
}
func init() {
screen.WindowTransparency = windowTransparency
screen.WindowSize = windowSize
}
// -------------------
package main
func foo(s screen.Screen) {
w, err := s.NewWindow(
screen.WindowTransparency(0xCC),
screen.WindowSize(600,600),
)
//...
} (except "of course" when |
@sbinet I believe a simple version of the gymnastics required for the driver packages would be to make each option a data type instead of a function;
Each driver can switch on the concrete type of each WindowOption and do what it sees fit with each value. WDYT? |
SGTM |
Drive-by comment: |
As @crawshaw hinted at, I'd like to avoid incrementally adding a dozen odd SetThis and SetThat methods to the Window interface, one by one in an ad hoc manner. The NewWindowOptions type already lists things like fullscreen, title, icon, cursorHidden in its TODO comments. There are undoubtedly more we could add. I'd like to have some sort of principled approach to where we draw the line. One consideration is that not all systems support programmatic resizing. For example, on mobile, the app has no say in its window size. Also, on X11, strictly speaking, the app can only make a request, and it's perfectly valid for the window manager, a separate program, to set the app window's size to be something different, such as what tiling window managers do. |
CL https://golang.org/cl/18740 mentions this issue. |
What's the status on this? Additionally an option to fullscreen windows would be huge. |
I'd definitely like to know, too. If it's still a syntax issue, then I'd like to cast a vote for the functional parameters style. Also, congratulations, @belak. You're the first person I've run into on here with a Quote avatar. No prizes. Sorry. |
No status update since my previous comment. It's not just a syntax issue. To quote my previous comment: "I'd like to avoid incrementally adding a dozen odd SetThis and SetThat methods to the Window interface, one by one in an ad hoc manner... I'd like to have some sort of principled approach to where we draw the line." |
It could be a single GetWindowProps and SetWindowProps. This would avoid a ton of GetThis and SetThis methods to the interface and would have a clear way to extend it in the future. Also, same for me @DeedleFake. Not an extremely common avatar. |
it seems there is no way to programmatically change a
screen.Window
size.currently, a
screen.Window
size can only be changed from outside the program (e.g. using the mouse).I'd propose to extend
screen.Window
as such:The text was updated successfully, but these errors were encountered: