mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-29 07:58:28 +00:00
Allow toggling antialiasing inside the Haiku font dialog
* src/haiku_support.cc (struct font_selection_dialog_message): New field `disable_antialias'. (MessageReceived): Handle new message SET_DISABLE_ANTIALIASING. (class DualLayoutView): Rename to `TripleLayoutView'. (class TripleLayoutView): Rename from `DualLayoutView'. (MinSize): Update computations for three views. (class EmacsFontSelectionDialog, UpdatePreview) (EmacsFontSelectionDialog): Add an antialiasing checkbox to control antialiasing. (be_select_font): New arguments `initial_antialias' and `disable_antialias'. * src/haiku_support.h: Update prototypes. * src/haikufont.c (haikufont_pattern_from_object): Set FSPEC_ANTIALIAS. (Fx_select_font): Update accordingly.
This commit is contained in:
parent
c175984e2c
commit
8cf3c3203b
@ -108,6 +108,7 @@ enum
|
|||||||
SET_PREVIEW_DIALOG = 3013,
|
SET_PREVIEW_DIALOG = 3013,
|
||||||
UPDATE_PREVIEW_DIALOG = 3014,
|
UPDATE_PREVIEW_DIALOG = 3014,
|
||||||
SEND_MOVE_FRAME_EVENT = 3015,
|
SEND_MOVE_FRAME_EVENT = 3015,
|
||||||
|
SET_DISABLE_ANTIALIASING = 3016,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* X11 keysyms that we use. */
|
/* X11 keysyms that we use. */
|
||||||
@ -146,6 +147,9 @@ struct font_selection_dialog_message
|
|||||||
/* Whether or not a size was explicitly specified. */
|
/* Whether or not a size was explicitly specified. */
|
||||||
bool_bf size_specified : 1;
|
bool_bf size_specified : 1;
|
||||||
|
|
||||||
|
/* Whether or not antialiasing should be disabled. */
|
||||||
|
bool_bf disable_antialias : 1;
|
||||||
|
|
||||||
/* The index of the selected font family. */
|
/* The index of the selected font family. */
|
||||||
int family_idx;
|
int family_idx;
|
||||||
|
|
||||||
@ -2574,6 +2578,9 @@ class EmacsFontPreviewDialog : public BWindow
|
|||||||
current_font = new BFont;
|
current_font = new BFont;
|
||||||
current_font->SetFamilyAndStyle (name, sname);
|
current_font->SetFamilyAndStyle (name, sname);
|
||||||
|
|
||||||
|
if (message->GetBool ("emacs:disable_antialiasing", false))
|
||||||
|
current_font->SetFlags (B_DISABLE_ANTIALIASING);
|
||||||
|
|
||||||
if (size_name && strlen (size_name))
|
if (size_name && strlen (size_name))
|
||||||
{
|
{
|
||||||
size = atoi (size_name);
|
size = atoi (size_name);
|
||||||
@ -2615,26 +2622,32 @@ class EmacsFontPreviewDialog : public BWindow
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DualLayoutView : public BView
|
class TripleLayoutView : public BView
|
||||||
{
|
{
|
||||||
BScrollView *view_1;
|
BScrollView *view_1;
|
||||||
BView *view_2;
|
BView *view_2, *view_3;
|
||||||
|
|
||||||
void
|
void
|
||||||
FrameResized (float new_width, float new_height)
|
FrameResized (float new_width, float new_height)
|
||||||
{
|
{
|
||||||
BRect frame;
|
BRect frame;
|
||||||
float width, height;
|
float width, height, height_1, width_1;
|
||||||
|
float basic_height;
|
||||||
|
|
||||||
frame = Frame ();
|
frame = Frame ();
|
||||||
|
|
||||||
view_2->GetPreferredSize (&width, &height);
|
view_2->GetPreferredSize (&width, &height);
|
||||||
|
view_3->GetPreferredSize (&width_1, &height_1);
|
||||||
|
|
||||||
|
basic_height = height + height_1;
|
||||||
|
|
||||||
view_1->MoveTo (0, 0);
|
view_1->MoveTo (0, 0);
|
||||||
view_1->ResizeTo (BE_RECT_WIDTH (frame),
|
view_1->ResizeTo (BE_RECT_WIDTH (frame),
|
||||||
BE_RECT_HEIGHT (frame) - height);
|
BE_RECT_HEIGHT (frame) - basic_height);
|
||||||
view_2->MoveTo (2, BE_RECT_HEIGHT (frame) - height);
|
view_2->MoveTo (2, BE_RECT_HEIGHT (frame) - basic_height);
|
||||||
view_2->ResizeTo (BE_RECT_WIDTH (frame) - 4, height);
|
view_2->ResizeTo (BE_RECT_WIDTH (frame) - 4, height);
|
||||||
|
view_3->MoveTo (2, BE_RECT_HEIGHT (frame) - height_1);
|
||||||
|
view_3->ResizeTo (BE_RECT_WIDTH (frame) - 4, height_1);
|
||||||
|
|
||||||
BView::FrameResized (new_width, new_height);
|
BView::FrameResized (new_width, new_height);
|
||||||
}
|
}
|
||||||
@ -2644,19 +2657,24 @@ class DualLayoutView : public BView
|
|||||||
MinSize (void)
|
MinSize (void)
|
||||||
{
|
{
|
||||||
float width, height;
|
float width, height;
|
||||||
|
float width_1, height_1;
|
||||||
BSize size_1;
|
BSize size_1;
|
||||||
|
|
||||||
size_1 = view_1->MinSize ();
|
size_1 = view_1->MinSize ();
|
||||||
view_2->GetPreferredSize (&width, &height);
|
view_2->GetPreferredSize (&width, &height);
|
||||||
|
view_3->GetPreferredSize (&width_1, &height_1);
|
||||||
|
|
||||||
return BSize (std::max (size_1.width, width),
|
return BSize (std::max (size_1.width,
|
||||||
std::max (size_1.height, height));
|
std::max (width_1, width)),
|
||||||
|
std::max (size_1.height, height + height_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DualLayoutView (BScrollView *first, BView *second) : BView (NULL, B_FRAME_EVENTS),
|
TripleLayoutView (BScrollView *first, BView *second,
|
||||||
|
BView *third) : BView (NULL, B_FRAME_EVENTS),
|
||||||
view_1 (first),
|
view_1 (first),
|
||||||
view_2 (second)
|
view_2 (second),
|
||||||
|
view_3 (third)
|
||||||
{
|
{
|
||||||
FrameResized (801, 801);
|
FrameResized (801, 801);
|
||||||
}
|
}
|
||||||
@ -2665,13 +2683,14 @@ class DualLayoutView : public BView
|
|||||||
class EmacsFontSelectionDialog : public BWindow
|
class EmacsFontSelectionDialog : public BWindow
|
||||||
{
|
{
|
||||||
BView basic_view;
|
BView basic_view;
|
||||||
|
BCheckBox antialias_checkbox;
|
||||||
BCheckBox preview_checkbox;
|
BCheckBox preview_checkbox;
|
||||||
BSplitView split_view;
|
BSplitView split_view;
|
||||||
BListView font_family_pane;
|
BListView font_family_pane;
|
||||||
BListView font_style_pane;
|
BListView font_style_pane;
|
||||||
BScrollView font_family_scroller;
|
BScrollView font_family_scroller;
|
||||||
BScrollView font_style_scroller;
|
BScrollView font_style_scroller;
|
||||||
DualLayoutView style_view;
|
TripleLayoutView style_view;
|
||||||
BObjectList<BStringItem> all_families;
|
BObjectList<BStringItem> all_families;
|
||||||
BObjectList<BStringItem> all_styles;
|
BObjectList<BStringItem> all_styles;
|
||||||
BButton cancel_button, ok_button;
|
BButton cancel_button, ok_button;
|
||||||
@ -2707,6 +2726,9 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
message.AddInt32 ("emacs:family", family);
|
message.AddInt32 ("emacs:family", family);
|
||||||
message.AddInt32 ("emacs:style", style);
|
message.AddInt32 ("emacs:style", style);
|
||||||
|
|
||||||
|
if (antialias_checkbox.Value () == B_CONTROL_ON)
|
||||||
|
message.AddBool ("emacs:disable_antialiasing", true);
|
||||||
|
|
||||||
message.AddString ("emacs:size",
|
message.AddString ("emacs:size",
|
||||||
size_entry.Text ());
|
size_entry.Text ());
|
||||||
|
|
||||||
@ -2834,6 +2856,11 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
rq.size = atoi (text);
|
rq.size = atoi (text);
|
||||||
rq.size_specified = rq.size > 0 || strlen (text);
|
rq.size_specified = rq.size > 0 || strlen (text);
|
||||||
|
|
||||||
|
if (antialias_checkbox.Value () == B_CONTROL_ON)
|
||||||
|
rq.disable_antialias = true;
|
||||||
|
else
|
||||||
|
rq.disable_antialias = false;
|
||||||
|
|
||||||
write_port (comm_port, 0, &rq, sizeof rq);
|
write_port (comm_port, 0, &rq, sizeof rq);
|
||||||
}
|
}
|
||||||
else if (msg->what == B_CANCEL)
|
else if (msg->what == B_CANCEL)
|
||||||
@ -2859,6 +2886,11 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
if (preview)
|
if (preview)
|
||||||
UpdatePreview ();
|
UpdatePreview ();
|
||||||
}
|
}
|
||||||
|
else if (msg->what == SET_DISABLE_ANTIALIASING)
|
||||||
|
{
|
||||||
|
if (preview)
|
||||||
|
UpdatePreview ();
|
||||||
|
}
|
||||||
|
|
||||||
BWindow::MessageReceived (msg);
|
BWindow::MessageReceived (msg);
|
||||||
}
|
}
|
||||||
@ -2881,6 +2913,7 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
|
|
||||||
font_family_pane.RemoveSelf ();
|
font_family_pane.RemoveSelf ();
|
||||||
font_style_pane.RemoveSelf ();
|
font_style_pane.RemoveSelf ();
|
||||||
|
antialias_checkbox.RemoveSelf ();
|
||||||
preview_checkbox.RemoveSelf ();
|
preview_checkbox.RemoveSelf ();
|
||||||
style_view.RemoveSelf ();
|
style_view.RemoveSelf ();
|
||||||
font_family_scroller.RemoveSelf ();
|
font_family_scroller.RemoveSelf ();
|
||||||
@ -2897,12 +2930,15 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
EmacsFontSelectionDialog (bool monospace_only,
|
EmacsFontSelectionDialog (bool monospace_only,
|
||||||
int initial_family_idx,
|
int initial_family_idx,
|
||||||
int initial_style_idx,
|
int initial_style_idx,
|
||||||
int initial_size)
|
int initial_size,
|
||||||
|
bool initial_antialias)
|
||||||
: BWindow (BRect (0, 0, 500, 500),
|
: BWindow (BRect (0, 0, 500, 500),
|
||||||
"Select font from list",
|
"Select font from list",
|
||||||
B_TITLED_WINDOW_LOOK,
|
B_TITLED_WINDOW_LOOK,
|
||||||
B_MODAL_APP_WINDOW_FEEL, 0),
|
B_MODAL_APP_WINDOW_FEEL, 0),
|
||||||
basic_view (NULL, 0),
|
basic_view (NULL, 0),
|
||||||
|
antialias_checkbox ("Disable antialiasing", "Disable antialiasing",
|
||||||
|
new BMessage (SET_DISABLE_ANTIALIASING)),
|
||||||
preview_checkbox ("Show preview", "Show preview",
|
preview_checkbox ("Show preview", "Show preview",
|
||||||
new BMessage (SET_PREVIEW_DIALOG)),
|
new BMessage (SET_PREVIEW_DIALOG)),
|
||||||
font_family_pane (BRect (0, 0, 0, 0), NULL,
|
font_family_pane (BRect (0, 0, 0, 0), NULL,
|
||||||
@ -2917,7 +2953,8 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
font_style_scroller (NULL, &font_style_pane,
|
font_style_scroller (NULL, &font_style_pane,
|
||||||
B_FOLLOW_ALL_SIDES,
|
B_FOLLOW_ALL_SIDES,
|
||||||
B_SUPPORTS_LAYOUT, false, true),
|
B_SUPPORTS_LAYOUT, false, true),
|
||||||
style_view (&font_style_scroller, &preview_checkbox),
|
style_view (&font_style_scroller, &antialias_checkbox,
|
||||||
|
&preview_checkbox),
|
||||||
all_families (20, true),
|
all_families (20, true),
|
||||||
all_styles (20, true),
|
all_styles (20, true),
|
||||||
cancel_button ("Cancel", "Cancel",
|
cancel_button ("Cancel", "Cancel",
|
||||||
@ -2946,6 +2983,7 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
split_view.AddChild (&font_family_scroller, 0.7);
|
split_view.AddChild (&font_family_scroller, 0.7);
|
||||||
split_view.AddChild (&style_view, 0.3);
|
split_view.AddChild (&style_view, 0.3);
|
||||||
style_view.AddChild (&font_style_scroller);
|
style_view.AddChild (&font_style_scroller);
|
||||||
|
style_view.AddChild (&antialias_checkbox);
|
||||||
style_view.AddChild (&preview_checkbox);
|
style_view.AddChild (&preview_checkbox);
|
||||||
|
|
||||||
basic_view.SetViewUIColor (B_PANEL_BACKGROUND_COLOR);
|
basic_view.SetViewUIColor (B_PANEL_BACKGROUND_COLOR);
|
||||||
@ -3007,6 +3045,9 @@ class EmacsFontSelectionDialog : public BWindow
|
|||||||
sprintf (format_buffer, "%d", initial_size);
|
sprintf (format_buffer, "%d", initial_size);
|
||||||
size_entry.SetText (format_buffer);
|
size_entry.SetText (format_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!initial_antialias)
|
||||||
|
antialias_checkbox.SetValue (B_CONTROL_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -5096,7 +5137,8 @@ be_select_font (void (*process_pending_signals_function) (void),
|
|||||||
haiku_font_family_or_style *style,
|
haiku_font_family_or_style *style,
|
||||||
int *size, bool allow_monospace_only,
|
int *size, bool allow_monospace_only,
|
||||||
int initial_family, int initial_style,
|
int initial_family, int initial_style,
|
||||||
int initial_size)
|
int initial_size, bool initial_antialias,
|
||||||
|
bool *disable_antialias)
|
||||||
{
|
{
|
||||||
EmacsFontSelectionDialog *dialog;
|
EmacsFontSelectionDialog *dialog;
|
||||||
struct font_selection_dialog_message msg;
|
struct font_selection_dialog_message msg;
|
||||||
@ -5106,7 +5148,7 @@ be_select_font (void (*process_pending_signals_function) (void),
|
|||||||
|
|
||||||
dialog = new EmacsFontSelectionDialog (allow_monospace_only,
|
dialog = new EmacsFontSelectionDialog (allow_monospace_only,
|
||||||
initial_family, initial_style,
|
initial_family, initial_style,
|
||||||
initial_size);
|
initial_size, initial_antialias);
|
||||||
dialog->CenterOnScreen ();
|
dialog->CenterOnScreen ();
|
||||||
|
|
||||||
if (dialog->InitCheck () < B_OK)
|
if (dialog->InitCheck () < B_OK)
|
||||||
@ -5135,6 +5177,7 @@ be_select_font (void (*process_pending_signals_function) (void),
|
|||||||
memcpy (family, family_buffer, sizeof *family);
|
memcpy (family, family_buffer, sizeof *family);
|
||||||
memcpy (style, style_buffer, sizeof *style);
|
memcpy (style, style_buffer, sizeof *style);
|
||||||
*size = msg.size_specified ? msg.size : -1;
|
*size = msg.size_specified ? msg.size : -1;
|
||||||
|
*disable_antialias = msg.disable_antialias;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -703,7 +703,8 @@ extern bool be_replay_menu_bar_event (void *, struct haiku_menu_bar_click_event
|
|||||||
extern bool be_select_font (void (*) (void), bool (*) (void),
|
extern bool be_select_font (void (*) (void), bool (*) (void),
|
||||||
haiku_font_family_or_style *,
|
haiku_font_family_or_style *,
|
||||||
haiku_font_family_or_style *,
|
haiku_font_family_or_style *,
|
||||||
int *, bool, int, int, int);
|
int *, bool, int, int, int,
|
||||||
|
bool, bool *);
|
||||||
|
|
||||||
extern int be_find_font_indices (struct haiku_font_pattern *, int *, int *);
|
extern int be_find_font_indices (struct haiku_font_pattern *, int *, int *);
|
||||||
extern status_t be_roster_launch (const char *, const char *, char **,
|
extern status_t be_roster_launch (const char *, const char *, char **,
|
||||||
|
@ -492,6 +492,14 @@ haikufont_pattern_from_object (struct haiku_font_pattern *pattern,
|
|||||||
pattern->specified |= FSPEC_WIDTH;
|
pattern->specified |= FSPEC_WIDTH;
|
||||||
pattern->width = haikufont_lisp_to_width (val);
|
pattern->width = haikufont_lisp_to_width (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = assq_no_quit (QCantialias,
|
||||||
|
AREF (font_object, FONT_EXTRA_INDEX));
|
||||||
|
if (CONSP (val))
|
||||||
|
{
|
||||||
|
pattern->specified |= FSPEC_ANTIALIAS;
|
||||||
|
pattern->use_antialiasing = !NILP (XCDR (val));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1232,6 +1240,7 @@ in the font selection dialog. */)
|
|||||||
int rc, size, initial_family, initial_style, initial_size;
|
int rc, size, initial_family, initial_style, initial_size;
|
||||||
struct haiku_font_pattern pattern;
|
struct haiku_font_pattern pattern;
|
||||||
Lisp_Object lfamily, lweight, lslant, lwidth, ladstyle, lsize;
|
Lisp_Object lfamily, lweight, lslant, lwidth, ladstyle, lsize;
|
||||||
|
bool disable_antialiasing, initial_antialias;
|
||||||
|
|
||||||
f = decode_window_system_frame (frame);
|
f = decode_window_system_frame (frame);
|
||||||
|
|
||||||
@ -1241,6 +1250,7 @@ in the font selection dialog. */)
|
|||||||
initial_style = -1;
|
initial_style = -1;
|
||||||
initial_family = -1;
|
initial_family = -1;
|
||||||
initial_size = -1;
|
initial_size = -1;
|
||||||
|
initial_antialias = true;
|
||||||
|
|
||||||
font = FRAME_FONT (f);
|
font = FRAME_FONT (f);
|
||||||
|
|
||||||
@ -1254,6 +1264,11 @@ in the font selection dialog. */)
|
|||||||
haikufont_done_with_query_pattern (&pattern);
|
haikufont_done_with_query_pattern (&pattern);
|
||||||
|
|
||||||
initial_size = font->pixel_size;
|
initial_size = font->pixel_size;
|
||||||
|
|
||||||
|
/* This field is safe to access even after
|
||||||
|
haikufont_done_with_query_pattern. */
|
||||||
|
if (pattern.specified & FSPEC_ANTIALIAS)
|
||||||
|
initial_antialias = pattern.use_antialiasing;
|
||||||
}
|
}
|
||||||
|
|
||||||
popup_activated_p++;
|
popup_activated_p++;
|
||||||
@ -1263,7 +1278,8 @@ in the font selection dialog. */)
|
|||||||
&family, &style, &size,
|
&family, &style, &size,
|
||||||
!NILP (exclude_proportional),
|
!NILP (exclude_proportional),
|
||||||
initial_family, initial_style,
|
initial_family, initial_style,
|
||||||
initial_size);
|
initial_size, initial_antialias,
|
||||||
|
&disable_antialiasing);
|
||||||
request_sigio ();
|
request_sigio ();
|
||||||
popup_activated_p--;
|
popup_activated_p--;
|
||||||
|
|
||||||
@ -1283,6 +1299,12 @@ in the font selection dialog. */)
|
|||||||
? intern (pattern.style) : Qnil);
|
? intern (pattern.style) : Qnil);
|
||||||
lsize = (size >= 0 ? make_fixnum (size) : Qnil);
|
lsize = (size >= 0 ? make_fixnum (size) : Qnil);
|
||||||
|
|
||||||
|
if (disable_antialiasing)
|
||||||
|
return CALLN (Ffont_spec, QCfamily, lfamily,
|
||||||
|
QCweight, lweight, QCslant, lslant,
|
||||||
|
QCwidth, lwidth, QCadstyle, ladstyle,
|
||||||
|
QCsize, lsize, QCantialias, Qnil);
|
||||||
|
|
||||||
return CALLN (Ffont_spec, QCfamily, lfamily,
|
return CALLN (Ffont_spec, QCfamily, lfamily,
|
||||||
QCweight, lweight, QCslant, lslant,
|
QCweight, lweight, QCslant, lslant,
|
||||||
QCwidth, lwidth, QCadstyle, ladstyle,
|
QCwidth, lwidth, QCadstyle, ladstyle,
|
||||||
|
Loading…
Reference in New Issue
Block a user