-
Notifications
You must be signed in to change notification settings - Fork 2
optimize multiline entry #25
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
base: GtkMultilineTextEntry140723
Are you sure you want to change the base?
optimize multiline entry #25
Conversation
* works for Gtk.Entry and Gtk.TextView now
* handle sizing using overloads
* mimic Gtk.Entry width behavior (behave like: https://git.gnome.org/browse/gtk+/tree/gtk/gtkentry.c?id=2.24.24#n2904)
@@ -272,9 +272,35 @@ internal static void Dispose (this Cairo.Context cr) | |||
((IDisposable)cr).Dispose (); | |||
} | |||
|
|||
public static void RenderPlaceholderText (Gtk.Widget widget, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your change breaks this feature for PasswordEntry and SearchTextEntry.
I've added specific extensions methods for Gtk.Entry and Gtk.TextView. RenderPlaceholderText should not be applicable on other Gtk widgets (Gtk.Widget) so lets make it private.
int width; | ||
if (!MultiLine && lastHeight != allocation.Height) { | ||
lastHeight = allocation.Height; | ||
XLayout.GetPixelSize (out width, out lineHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing a TextEntry and a PasswordEntry side-by-side shows that the PasswordEntry, still with the Gtk.Entry as backend, is a little taller than the TextEntry.
I sugest add 6 pixels to the lineHeight and set the PixelsAboveLines to 3 pixels... This way they will look alike... at least they did here on my pc (Xubuntu 14.04)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but its a wrong way to set PixelsAboveLines here, cause it remains if MultiLine is changed after initialization. Lets set it together with the MultiLine prop.
Hhm, with this approach we have still inconsistent style compared to Gtk.Entry (and so PasswordEntry and SearchTextEntry). Many Gtk themes style Gtk.Entry differently. On Ubuntu Gnome 14.04 all Entries have rounded frame corners and the frame border has a different color, when the entry is focused. I've tried a dirty approach by using a table (instead of a frame) and adding a Gtk.Entry behind Gtk.TextView (see http://stackoverflow.com/a/17977591). This solves the problem with rounded frame corners, but the Entry in the background needs a focus to draw the colored frame correctly, which steals the focus from TextView. So not really applicable. |
Is there any way to change the Backend widget on the fly? Both Backends implements the same interface, should be no problem |
I've done this already for me that way, but it is really dirty and the code is hard to read, because all methods have an if (MultiLine) .. else. A better solution would be to remove the Xwt.TextEntry.MultiLine completely (or better mark it as Deprecated) and add a Xwt.TextEntryMultiline class, derived from TextEntry, but bind it to a new ITextEntryMultilineBackend interface. For Wpf and Mac TextEntryBckend would implement both (ITextEntryBackend and ITextEntryMultilineBackend). Gtk would register different backends (the old one for ITextEntry and the new one only for ITextEntryBckendMultiline). This would be the cleanest solution, but a massive change of the Xwt API. |
I was thinking more in the way of a 2nd level backend. Most of the complexity will be on the Multiline property setter, It doesn't break the API, and it would be way cleaner than a lot of conditionals. |
oh, yes, this would work of course. But I personally don't really like both ways of switching backends. It makes the backend code much more complex and makes it harder to implement backend specific code on the consumer part (since you have to check what backend is actually used). |
Thanks for your inputs. I'll review it in the next days. |
Hi,
your frame implementation is not very nice, since you draw the frame yourself. You should use a native frame to keep the native feeling and honor users theme settings.