Skip to content
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

DRAFT: File Dialog example #396

Draft
wants to merge 1 commit into
base: skia_2024
Choose a base branch
from

Conversation

klytje
Copy link
Contributor

@klytje klytje commented May 3, 2024

I added a new example of a file dialog using the external nativefiledialog_extended library. The main features of the example is a reusable file dialog element, a simple text autocompleter, and the manipulation of background colors of input_boxes.

@klytje klytje changed the title File Dialog example DRAFT: File Dialog example May 3, 2024
@klytje
Copy link
Contributor Author

klytje commented May 3, 2024

Questions:

I don't like using the link_libraries(nfd) in the CMakeFiles. It would be way nicer to use target_link_libraries, targetting only the executable itself. But since it is constructed in a different project, CMake doesn't accept this. Is there a better way of doing this linking?

I'm having some issues making the new file dialog element look nice - ideally I'd like the x button to be right next to the
input_box, sharing a single frame. I'm not super sure how to create a negative space between these two elements though. Any ideas beyond modifying the input_box element itself?
image

Comments on the autocompleter are welcome! I'm not sure if we should have it in this example or not - I already had it implemented for my own project, so I thought why not. It is meant to autocomplete parts of, or the full path to, input files when it can be deduced. E.g. for the .txt input files, when the user enters a / it'll search the folder for .txt files; if only a single match is found it'll automatically be entered; if there are multiple matches, the longest common prefix is found and entered. I have some additional questions/thoughts regarding this should we decide to keep it.

The code itself is still missing comments and a minor refactoring away from using static elements.

@djowel
Copy link
Member

djowel commented May 4, 2024

I'm having some issues making the new file dialog element look nice - ideally I'd like the x button to be right next to the
input_box, sharing a single frame. I'm not super sure how to create a negative space between these two elements though. Any ideas beyond modifying the input_box element itself?

I think we need to add D and reverse D buttons, instead of just the usual round rect buttons. Something similar to those used in Bootstrap's input groups (example):

image

Square buttons too for those in the middle of groups:

image

@klytje
Copy link
Contributor Author

klytje commented May 6, 2024

Oh yeah that'd be perfect for this example. I can take a shot at it when I find some spare time. Perhaps the best interface would be an overload of the existing button, but with an additional parameter describing the amount of curving? Taking values between 0 (sharp corners) and 1 (half-circle)?

@djowel
Copy link
Member

djowel commented May 6, 2024

Oh yeah that'd be perfect for this example. I can take a shot at it when I find some spare time. Perhaps the best interface would be an overload of the existing button, but with an additional parameter describing the amount of curving? Taking values between 0 (sharp corners) and 1 (half-circle)?

I think an enum for the shape would be sufficient.

Please study the button_styler code which demonstrates a way to pay for only the things that you need using template magic.

https://github.com/cycfi/elements/blob/master/lib/include/elements/element/gallery/button.hpp

@klytje
Copy link
Contributor Author

klytje commented May 6, 2024

I think the amount of curvature is a matter of personal taste, so hard-coding it in through a limited number of enums wouldn't be sufficient. Especially if we want to support half-circular edges as well, in which case we've essentially covered the entire range of values we would have to support anyway.

Example of half-circular edges:
image

Regarding the cost, we could just leave the current implementation as it is, and have the overloaded method return a specialized button supporting this feature.

@djowel
Copy link
Member

djowel commented May 6, 2024

I think the amount of curvature is a matter of personal taste, so hard-coding it in through a limited number of enums wouldn't be sufficient. Especially if we want to support half-circular edges as well, in which case we've essentially covered the entire range of values we would have to support anyway.

Example of half-circular edges: image

Regarding the cost, we could just leave the current implementation as it is, and have the overloaded method return a specialized button supporting this feature.

Please study the code. There is actually already an option for the curvature. It's the corner_radius.

@djowel
Copy link
Member

djowel commented May 6, 2024

Regarding the cost, we could just leave the current implementation as it is, and have the overloaded method return a specialized button supporting this feature.

Please study the code I linked to above. It's not your typical OOP. There's some template magic happening there. The code has zero overhead already. You pay for a feature only if you need it.

@djowel djowel force-pushed the skia_2024 branch 2 times, most recently from d57375f to 793c02f Compare May 22, 2024 04:07
@djowel djowel force-pushed the skia_2024 branch 2 times, most recently from ca324af to 486128b Compare July 18, 2024 10:43
@djowel djowel force-pushed the skia_2024 branch 2 times, most recently from 4a45224 to d5000b2 Compare October 27, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants