-
Notifications
You must be signed in to change notification settings - Fork 583
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
Custom Window Title bar and Frame API proposal. #2521
Comments
Thank you for your proposal. I've marked this issue with the I quite like the idea of being able to customise all the way to a custom frame. In terms of API, currently we don't support properties that can take enum values (like In the spirit of the So for example:
would re-use the existing API to say: Don't show a system provided frame, but instead draw my own custom window frame. Or should we deprecate |
Hi, I see the issue with the Enum/Components. But what if I suggested that NoFrame and NoTitleBar were actually pre-defined children of Frame and TitleBar included with Slint. For example: I'm afraid I haven't used the |
Why do we even need |
My main reason is for reusability. You might have different type of windows that all have a frame but different title bars. Sure you could have a single object that combines the two, but if you then decided that you wanted to update the frame to be different you would have to change all your custom frames to match. This way you only have to define the frame once per style of frame you intend to use (which I expect to be 1 in most applications) and then when you update it, it updates all windows using that frame.
Very true, but I do feel there is still value in being able to have the same title bar across all OSes. I know I personally prefer when software I use on multiple OSes looks the same visually. That way I don't have to learn where things are per platform. I know that might seem like a small thing, but it can really make an application more approachable when you work on multiple platforms |
Title bar and Frame Proposal
I noticed that there have been several tickets related to custom title bars, being able to resize a frameless window, etc. for example #610, #613 and #2367. But I haven't seen a detailed proposal for an API that could address these missing features. So here is my proposal for an API that will hopefully cover all scenarios for custom title bars and frames so users can easily customise their windows. I should point out that I am relatively new to Slint, so my .slint API usage may not be perfect, but so far have been really enjoying the API and think that these improvements would really push it ahead for GUIs in Rust.
The customisation would be broken down into a
TitleBar
andFrame
on theWindow
element. If the user doesn't manually set these then they will have native style and behaviour to that platform. If the user defines a customTitleBar
orFrame
then they can set it on the Window to create a custom Window class.TitleBar
The title bar contains a property for the height of the title bar and is the width of the Window. The title bar would automatically provide similar behaviour to
TouchArea
that when clicked moves the window like a standard title bar would. The user would then be able to define custom buttons that replace the standard window decorations (either left or right), or even create something like a tab line as well.Example:
Frame
Similar to the title bar the user would define a custom frame with some basic properties and the behaviour would me aligned to match those properties. For the frame this would be the border width, colour, corner overlap, etc. that would be used to automatically create resizing logic that matches the border the user creates. Also similar to the custom title bar, the width of the top and bottom border and the height of the left and right borders would be sized to match the window and wouldn't need to be defined by the user. If the user wanted to they could create a border that has resize logic, but is otherwise invisible by making the background transparent. The border would then be turned off whenever the window is maximized to match standard window behaviour.
Example:
Example use cases
Here are some example use cases for how one could use the API. It's not fully detailed but it should be enough to get the gist of how the user is expected to use it. I tried to use bright colours on a black background to make the differences more noticeable, mainly for the frame.
Frame: Native
Resizable: True
}
Frame: None
Resizable: False
frame: NoFrame;
}
Frame: Native
Resizable: True
title-bar: NoTitleBar;
}
Frame: Custom
Resizable: True
frame: CustomFrame;
}
Frame: Native
Resizable: True
title-bar: CustomTitleBar;
}
Frame: Custom
Resizable: True
title-bar: CustomTitleBar;
frame: CustomFrame;
}
I would have really like to have also presented maybe an example implementation, but when it comes to windowing APIs, especially native ones, I don't really have enough knowledge/experience to provide one. Hopefully my proposal is detailed enough that someone better than me could validate the idea.
I'm open to questions and discussions about the proposal
The text was updated successfully, but these errors were encountered: