Random thoughts/suggestions/questions #74
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I think my application is in a pretty good state!
Here just some random notes that I collected over the weeks...
Double vs Int
SwiftUIis using Double for a lot of stuff..frame,.paddingetc. GTK does not. When calculating sizes I have toIntthem. Could there be an overload forDouble?Paddings
We can use
.padding()or.padding(10, .leading)but not.padding(.leading). The default is 10 and a new overload with just the edge should give 10.I like that, because if the default will change, the overload will do as well.
FlowBox
I use a
FlowBoxto display chord variations. Even though I don’t have a selection-binding, I can still select elements. I was expecting a plain view. I have to addselection: nilspecifically. A small detail.EitherView
This View seems to loose the state of its
Bindingswhen switching? I use a directif/elsenow. I have more issues withBindings. They don’t aways bound.ForEach
It would be nice to have the
homogeneousfunction added to this struct. GTK_BOX supports it. I bluntly copied thestruct, renamed it and added it. Works like a charm!Its
widgets+gridin my source.Conditional CSS
I can’t use a conditional css declaration:
.style(correct ? .green : .red)If
correct(a Bool) is changed; the style does not. It seems GTK does not update the style for some reason.(I use
Enumsfor style definitions, an extension, I loveEnums!)View ID’s
To force
SwiftUIto refresh a View, I can give it an unique ID:.id(chord.definition)So it forgets the previous version. GTK has the memory of a dinosaur, haha! Is it possible to do something like that?
Reason: when a chord is changed and I look at its diagram, I see the old version for a moment.
Performance
While all working well; my application becomes sluggish when opening a very long song. After I close the song and open a short new one, it is still sluggish. I’m not familiar with GTK but it seems to ‘remember’ a lot of stuff :-)
I tried to
Debouncethe parsing of a song, but so far no luck. Investigating...Any suggestions?
Document based
To be able to open song document from
FilesI have a smelly hack... Every instance of Chord Provider has an unique ID. This is smelly (and I can’t use the sqlite storage). But it works.Custom widgets
Learned a lot about the internals of
swift-adwaitaandGTK. Even a bit ofC:-) Wrote some custom stuff...Chord Diagrams and strum patterns
I’m very proud of them! Draw them with
cairo. But, to be honest, did that with ‘try and error’...Columns
I use
adw_wrap_boxto show a song in columns. It would be nice to have that widget in your package :-)Pictures
Two custom widgets to display images from the application bundle. Hacked code; still learning
GTKstuff...Empty
Sometimes I like to show nothing; like when going to all
enumcases. I’ve added an emptyAdwaitaView. Seems to work well but feels smelly...Like
SwiftUIsEmptyView()All in all
It is great fun to use your
swift-adwaitaand I’m still surprised how well it works with my previousSwiftUIknowledge.I want to release a
flatpaksoonish. My main concerns are that the application can become sluggish and mydocumentshack.And for later:
makefileto make a macOS package. I maintain the macOS version of the official ChordPro implementation and wrote aSwiftwrapper for that.GTK.Gitso I can contribute code to your project. Still aGithub Desktopuser...Are there any other Open Source projects based on your project?
Thanks for the suggestions (and sorry for my late answer)!
I see your point, however, as GTK uses integers everywhere, I don't think it makes a lot of sense to add "implicit" double conversion to specific parts of Adwaita for Swift.
Thanks for reporting! Could you maybe provide an example for bindings that do not work, as I haven't experienced this. Actually, I would recommend using
if/elsedirectly, as this gets mapped to anEitherViewbehind the scenes.There might be some issue with a widget not freeing the memory of its children correctly or something similar. However, I couldn't find the exact problem. Using the newly added
idmodifier to completely erase and rebuild the preview when switching to a new song might be the best solution for now.I can't help you with that unfortunately 😅
This is something I plan to change quite a bit in order to make it more "sqlitey" (maybe based on Point-Free's sqlite-data once Linux support is fixed) anyways :)
Congratulations on how your app looks and feel, I really like it! It got very sophisticated very fast :)
I think this is a perfectly valid alternative to SwiftUI's
EmptyView. It is equivalent to[]orVStack { }.Not too many. Here are some I found:
Happy new year David!
Thanks for your commits. I’ve updated my source.
Double vs Int
Why not? Just round the double? Just a convenient init? Or am I missing something?
EitherView
Yeh, I should make a sample application with my issues. I’ll do that; easier to debug.
if/elseis working fine.Performance
Problem is (was) on my side. My custom widgets (especially for chord diagrams) was leaking.
Cis new to me and not as forgiven asSwift. I think its better now.However, using the
idmodifier is often smelly coding :-) Learned that in mySwiftUIdays. I use it now for inline chord diagrams (small stuff) and the rendering of the song with its own unique ID.GTKSourceView still becomes sluggish sometimes even thought I rewrote it completely. Work in progress!
Talking about that; I pushed
swift-adwaitato the limits I think. So cool! The editor has its controller with a lot of fancy stuff. Bridging it all! Snippets, markers, autocomplete brackets. Passing chances and line numbers back to Swift`.Document based
I think its fine how I do it now. Not natural on macOS but ok on Linux.
and I can’t use the sqlite storage
My
structsaving is ok for now. It would be nice if your change does not involve an external package. An not the ID of the application because I misuse that a bit, haha!Next
Thanks! Next I have to find-out how to add it to
flathubonce I got my last issues solved. Details are important for me:Swiftcode is pretty ok; I know what I’m doing :-)Ccode works by good luck; it is a mess...C!)It will be soon a true
Swiftapplication build for Gnome!Very cool :-)
While coding my next challenge: adding a

chord definition dialog, I found a couple of new issues/ideas to keep you entertained...CSS
.cssAnyViewmodifier will always add the style because it is not storing its new value when there is a new String..cssmodifier is called many (many, many, many times) even thought it is only added in theMain View.providerinstead of replacing the old one. I don’t know how GTK is dealing with it; merging?lighttodark(and visa versa) the style does not change. It needs aViewrefresh. I tried real hard to debug. In The GTK Inspector its working well.css dark modedeclarations. The declarations are completely ignored... But not in the GTK Inspector.So I changed my code to do its own
csshanding with a notification on theme change. Smelly as usual :-) You know where to find my code for review.AnyView extensions
Added some simple extensions:
Make a round button:
Use
orientationto make a widget vertical.Override
ToggleGroupYeh, this might be very specific for my needs but I brutally copied
ToggleGroupto adjust it. See screenshot. Problem is that I cannot just add another extension (Like yourToggleGroup+) because the auto-generatedappearFunctionsandupdateFunctionsinToggleGroupare not public. Should they be public? Then I can add extensions to my needs and maybe contribute them back when not too specific?Your
ToggleGroup+is very strict about having Self as ID while I use description, requiring conformance to CustomStringConvertible.ID
In a SwiftUI
ForEach, I can make a ID self:That would save a lot of code! Now I have to wrap a lot of stuff.
All in all, progress!
Well, learned new stuff again!
Made my code much more Swifty...
storage.notify(..)for style changes.Swiftclasses to pass data toCfunctions without conversion.With the new knowledge I will update the
GTKSourceViewcode (that is already not sluggish anymore) and then it should be ready for a release :-)Fun!
Well, happy new year (a month later, sorry) 🎉
I'm so excited about your project and it's amazing to see the rapid progress!
Thanks for the updates and suggestions/reports!
Oh this was very bad! Thanks for noticing, this is fixed by now :)
I can't reproduce this?
I spent some hours experimenting and researching, and I couldn't get it working with CSS only :(
I introduced the Swift package trait
exposeGeneratedAppearUpdateFunctionsto do exactly that, so you can activate this trait and interact with those properties.Also, I restructured quite some logic of this package yesterday, so if you find something suddenly not working, please report!
You can actually overwrite this behavior:
But MetaSQLite will definitely see some changes at some point...
Next, I will look into the id stuff (I'll probably add keypaths) and I definitely see your double/int point, so I'll find a solution for this as well :)
Thanks for the updates David!
I've updated the packages and a quick looks showed me my application still works well :-) Going to update my code with the new stuff and I will report back.
Only thing; it does not compile under macOS anymore because the
CSQLitepackage cannot be resolved on that platform.I looked at
https://github.com/stephencelis/CSQLite/blob/master/Package.swiftand it does not have:On Linux, all is fine.
Thanks! I think it should work now on macOS as well (I'm writing from Linux, so I'd be glad if you could confirm this). The SQLite.swift project has undergone some major changes recently.
Yes, all fine on macOS now as well!
I added support for keypaths throughout the whole package, so now e.g. toggle groups are much more flexible (see https://git.aparoksha.dev/aparoksha/adwaita-swift/src/branch/main/Sources/Demo/ToggleGroupDemo.swift). So you probably won't have to write an extension for
ToggleGroupanymore :)That's great! Updated my 'easy' Enums and it works like a charm without
ToggleGroupextensions.I tried to update my custom
MyToggleGroup+override and while appear and update are available now, theinit()from the base (generated)ToggleGroupis not because that is still internal. Could that also be added to the trait?I think (didn't try yet) I can replace my whole custom implementation with the keypath init; but it would still be nice to have the applicability to add custom extensions to all the generated base Structs :-)
While updating my code I found-out that the Preferences dialog is partly broken now (it was fine) when you have more than one page. I've added a second page in the Demo app and in the tabs is shows a broken image and no title:
The tabs itself are still working well.
Thanks for the tip! I use sqlite now for settings storage :-)
Found one more issue with the Preferences; search is broken now too. Initial, the Window is empty, except some shadow, and when you enter a search it shows No Results Found. This is both for a Preference dialog with tabs as well a single page.
You can see the behaviour in the Demo app as well.
Should work now - thanks for the report :)