From 7c50fb248d83ac02331fa717ebad96f1d56d5575 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 1 May 2022 08:53:51 +0000 Subject: [PATCH] Improve display of Haiku font dialog * src/haiku_support.cc (EmacsFontSelectionDialog) (class EmacsFontSelectionDialog, FrameResized): Set minimum size based on individual view dimensions and add label to size control. (BWindow_set_min_size): Delete function. * src/haiku_support.h: Update prototypes. * src/haikuterm.c (haiku_update_size_hints): Stop setting min size, since that doesn't work correctly on Haiku. --- src/haiku_support.cc | 35 +++++++++++++++++++---------------- src/haiku_support.h | 1 - src/haikuterm.c | 16 ++++------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index d8a064ccac5..67b7e143bfb 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2565,7 +2565,7 @@ public: : BWindow (BRect (0, 0, 500, 500), "Select font from list", B_TITLED_WINDOW_LOOK, - B_NORMAL_WINDOW_FEEL, 0), + B_MODAL_APP_WINDOW_FEEL, 0), basic_view (NULL, 0), font_family_pane (BRect (0, 0, 10, 10), NULL, B_SINGLE_SELECTION_LIST, @@ -2584,14 +2584,15 @@ public: cancel_button ("Cancel", "Cancel", new BMessage (B_CANCEL)), ok_button ("OK", "OK", new BMessage (B_OK)), - size_entry (NULL, NULL, NULL, NULL), + size_entry (NULL, "Size:", NULL, NULL), allow_monospace_only (monospace_only) { BStringItem *family_item; int i, n_families; font_family name; - uint32 flags; + uint32 flags, c; BMessage *selection; + BTextView *size_text; AddChild (&basic_view); @@ -2638,12 +2639,20 @@ public: font_family_pane.AddItem (family_item); } } + + size_text = size_entry.TextView (); + + for (c = 0; c <= 47; ++c) + size_text->DisallowChar (c); + + for (c = 58; c <= 127; ++c) + size_text->DisallowChar (c); } void FrameResized (float new_width, float new_height) { - BRect frame = Frame (); + BRect frame; float ok_height, ok_width; float cancel_height, cancel_width; float size_width, size_height; @@ -2658,6 +2667,10 @@ public: max_height = std::max (std::max (ok_height, cancel_height), size_height); + SetSizeLimits (cancel_width + ok_width + size_width + 6, + 65535, max_height + 64, 65535); + frame = Frame (); + basic_view.ResizeTo (BE_RECT_WIDTH (frame), BE_RECT_HEIGHT (frame)); split_view.ResizeTo (BE_RECT_WIDTH (frame), BE_RECT_HEIGHT (frame) - 4 - max_height); @@ -2673,7 +2686,8 @@ public: ok_button.ResizeTo (ok_width, ok_height); cancel_button.ResizeTo (cancel_width, cancel_height); - size_entry.ResizeTo (BE_RECT_WIDTH (frame) / 6, + size_entry.ResizeTo (std::max (size_width, + BE_RECT_WIDTH (frame) / 4), size_height); } @@ -4405,17 +4419,6 @@ be_get_display_screens (void) } /* Set the minimum width the user can resize WINDOW to. */ -void -BWindow_set_min_size (void *window, int width, int height) -{ - BWindow *w = (BWindow *) window; - - if (!w->LockLooper ()) - gui_abort ("Failed to lock window looper setting min size"); - w->SetSizeLimits (width, -1, height, -1); - w->UnlockLooper (); -} - /* Synchronize WINDOW's connection to the App Server. */ void BWindow_sync (void *window) diff --git a/src/haiku_support.h b/src/haiku_support.h index c9b408589f9..5522468fb38 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -468,7 +468,6 @@ extern void BWindow_change_decoration (void *, int); extern void BWindow_set_tooltip_decoration (void *); extern void BWindow_set_avoid_focus (void *, int); extern void BWindow_zoom (void *); -extern void BWindow_set_min_size (void *, int, int); extern void BWindow_set_size_alignment (void *, int, int); extern void BWindow_sync (void *); extern void BWindow_send_behind (void *, void *); diff --git a/src/haikuterm.c b/src/haikuterm.c index 1dbe3598ffd..bdec82db7ab 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -144,23 +144,15 @@ get_string_resource (void *ignored, const char *name, const char *class) static void haiku_update_size_hints (struct frame *f) { - int base_width, base_height; - eassert (FRAME_HAIKU_P (f) && FRAME_HAIKU_WINDOW (f)); - if (f->tooltip) return; - base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); - base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); - block_input (); BWindow_set_size_alignment (FRAME_HAIKU_WINDOW (f), - frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f), - frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f)); - BWindow_set_min_size (FRAME_HAIKU_WINDOW (f), base_width, - base_height - + FRAME_TOOL_BAR_HEIGHT (f) - + FRAME_MENU_BAR_HEIGHT (f)); + (frame_resize_pixelwise + ? 1 : FRAME_COLUMN_WIDTH (f)), + (frame_resize_pixelwise + ? 1 : FRAME_LINE_HEIGHT (f))); unblock_input (); } -- 2.39.2