-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor!: migrate to pango and cairo usage #98
base: main
Are you sure you want to change the base?
Conversation
I'm sure that for compilation requires |
add these to the book noti-rs/notibook#2 and to the example cfg in readme |
Now added
|
Motivation
Last time I found that it's hard to track all low-level details of drawing and deal with widgets which are high-level together. I've spend a lot of time to write much code which can perfectly work with any case, especially ellipsization which is hard part I've had dealt. And new widgets will make more frictions to further development of notification system because of low-level details.
I wanted to save widgets logic, but delegate the drawing to libraries pango and cairo. They will be helpful to make unique widgets without any frictions. Furthermore, these libraries may have more effective and generic code than my, so I don't have any reason to avoid these libraries.
Breaking Changes
I need to mention that some config properties now works differently:
display.text.justification
renamed todisplay.text.alignment
and have only three values instead of four:left
,right
orcenter
. To justify them I added new config propertydisplay.text.justify
which accepts boolean value.display.text.ellipsize_at
renamed todisplay.text.ellipsize
and now accepts only four values instead of two:start
,middle
,end
ornone
. Instead of cutting words they cuts a part of text.Except them, all available config properties should work as expected.
Changes in code
crates/render/src/font.rs
,crates/render/src/text.rs
crates/render/src/border.rs
Drawer
struct to usecairo
libraryDrawer
usage in widgetsWText
to usepango
logicFlexContainer
will exists even if there is no children (at least render a rectangle instead of empty space)PangoContext
instead ofFontCollections
Image
logic to store PNG instead of raw RGBA bytesRectSize
,Offset
andBgra
to store generic type instead of concrete for flexibilitycrates/filetype/src/converter.rs
instead of using question mark to avoid useSend + Sync
auto-traits for simplicity of codeError
type for backend which allows us to handle various errors and currently possible only two errors:Vec<Notification>
andFatal
. The first one allows us handle a case when some notifications not drawn because of various reasons. The second, as described by name, is unrecoverable and should stop application. Now the application drops the unrendered notifications because there's no history to which can be placed notificationWhat about performance?
It's not surprising that library shows more effective CPU and memory usage because it's optimized by smart (I hope lol) developers. Especially the application now is not eagerly eats the available memory.
The binary size is smaller now than previously and the compilation time is faster.