-
Notifications
You must be signed in to change notification settings - Fork 262
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
Discrepant behaviour between Fl_Choice and Fl_Input_Choice #978
Comments
Right, so first the low hanging fruit: attaching a v1 patch to solve the default fltk scheme case, which seems straight forward enough. To support the other schemes, hmm, there's a few things I need to ask the other devs about, as there's some squirrely stuff that should be sussed out first, namely:
|
Attaching a simple choicetest_v1.cxx program for testing. |
@erco77: I took a look but it's too late here for details, so just a few thoughts.
My potential patch: $ git diff -- src/
diff --git a/src/Fl_Choice.cxx b/src/Fl_Choice.cxx
index 66bd57ab6..dbde71c9a 100644
--- a/src/Fl_Choice.cxx
+++ b/src/Fl_Choice.cxx
@@ -36,9 +36,13 @@ void Fl_Choice::draw() {
// Arrow area
int H = h() - 2 * dy;
+#if (0)
int W = Fl::is_scheme("gtk+") ? 20 : // gtk+ -- fixed size
Fl::is_scheme("gleam") ? 20 // gleam -- fixed size
: ((H > 20) ? 20 : H); // else: shrink if H<20
+#else
+ int W = 20;
+#endif
int X = x() + w() - W - dx;
int Y = y() + dy;
@erco77 Thanks for taking care of this. |
@erco77: > Right, so first the low hanging fruit: attaching a v1 patch to solve the default fltk scheme case, which seems straight forward enough. Applied this patch and it does what I want. @Albrecht-S: If I understand your patch correctly with the widget height set to 20, the menu button height will be 18 and the width 20. I was thinking earlier, could the Fl_Choice be considered a variant of the Fl_Input_Choice with the Fl_Input widget configured as an Fl_Output (i.e. setting its type to FL_NORMAL_OUTPUT. |
@pvrose Yes, maybe (or maybe 16), and what exactly is your question? I don't consider scheme specific sizes of (parts of) widgets a good solution. In ADDED later: a constant width, independent of the scheme and widget height would IMHO look good and could be easily maintained for both widgets in question. My patch doesn't yet consider the different inset mentioned elsewhere though which is one reason why I wrote it may be incomplete. This should obviously be added to harmonize the view of both widgets.
@erco77 I didn't want to "take over" this issue, just try to help with my thoughts and a possible patch. Looking forward to your comment(s) and suggestions. |
@Albrecht-S : No question just a comment.
Fair enough, It was just an idea. I'm happy the way I have it patched at the moment, so I'll shut up await the final version. |
@erco77 The problem with your screenshot is that the InpChoice button looks too big by 1 px at the top and the bottom, but this is obviously caused by the Fl_Input using a DOWN box whereas the button uses an UP box. I don't think this can be avoided (easily) and I don't want to complain ;-) |
I believe that looks "good enough", even with the small border issues in the previous comment (screenshot). Are you ready to post a patch? |
No, not yet, and I'm unfortunately also busy as #!@$ on paying work, lol.. thought this would be easy but it's not. To get that "consistent look" I had to cheat and draw the button larger than its xywh is, which is a bad/illegal hack. To do it right I either need to (a) make the button larger so it can either draw over the border box, or (b) change the border box for the widget to an FL_UP_BOX (in non-default schemes, which makes the gradient) and have the input area draw over that, and have the "button" draw() method just draw the arrows and vert divider. That might look nice, haven't tried it yet. I'm thinking the latter (b) approach is the better way, and more like what Fl_Choice does.. just not sure how the input field will look drawn over that; might have to fl_push_clip() off its border to not clip the input field's character area. It's squirrely drawing business to get it right. |
Thanks for the update. Looking forward to whatever you find when real work permits. |
Finally had some time to come back to this. Here's a input_choice_v2.patch.txt which ends up looking like this in the various schemes: The goal being to keep it looking as much like Fl_Choice as possible, but with an input field. In that patch I applied the scheme chooser Albrecht added in his example to the test/input_choice program so that it can be used for testing. I'm happy enough with the look and the code. Give it a test and see what you think. |
Update: Here's input_choice_v3.patch.txt which is a code cleanup of the above v2 patch; removal of unused vars and such. |
@erco77 Thanks for your work on this and your latest "v3" patch. The patch is IMHO good and works well but I still found a few border cases where the look of
You can see all these remaining issues if you use this reworked demo program choicetest_v3.cxx if you use it with your patch but w/o my Fl_Choice patch. Change schemes and resize the window, particularly to smaller heights. Finally, here's my additional patch: Fl_Choice.diff.txt From my POV your patch together with mine are good to go. The layout is now pretty consistent. The only remaining issue is that some arrow sizes don't match at very low widget heights, i.e. heights lower than 20 which are - more or less - pathological and IMHO negligible. Please let me know if you want to commit both our patches together or if you commit yours and I commit mine independently. My PS: I'd appreciate if you changed the copyright year of all concerned files in your patch as well. |
PS: my latest PPS: in the future we might want to combine |
OK, I'll apply the two patches as separate commits:
Once done and everything builds, I'll close the issue. |
Differences in size of arrows and overall look varies with different schemes applied for issue raised by Philip Rose first on fltk.general: Subject: Discrepancy between Fl_Choice and Fl_Input_Choice
This addresses some border case issues in Fl_Choice wrt erco's recent Fl_Input_Choice modifications. As Albrecht writes in issue #978: - The width of the (simulated) menu button in Fl_Choice is shrunk if the height of the widget is lower than 20 for some schemes. This (a) is inconsistent, (b) doesn't look good, and (c) doesn't match the better layout of the Fl_Input_Choice widget after your patch. - The constant height (+/- 8) of the divider line in some schemes would overlap the border of the widget if the widget's height is smaller than about 19. You fixed this in your patch and I "stole" your [erco's] fix for Fl_Choice. - The divider line and the box borders of Fl_Choice and Fl_Input_Choice didn't align properly. I fixed this in my Fl_Choice patch as well (IMHO this is the right place to fix it).
OK, both patches applied - closing this. (EDIT: applied the copyright date updates as separate commits - I was focused on the code commits working properly) |
- add Fl_Choice widget for layout comparison - rewrite button callbacks - improve layout and other details This is a follow-up to issue #978, "merging" the existing input_choice demo with "choicetest_v3" as mentioned.
FTR: I wrote
Done in commit 64cd50c |
The appearance of Fl_Choice and Fl_Input_Choice differs in the width of the menu button and the size of the arrow displayed in the button.
See https://groups.google.com/d/msgid/fltkgeneral/ecb54cd1-2c8c-4af6-9324-42dd0442397fn%40googlegroups.com for further information.
The text was updated successfully, but these errors were encountered: