forked from AuroraMiddleware/gtk
gtk4-demo: Polish the font features demo
This commit is contained in:
parent
d6dde63074
commit
508ceccb66
@ -43,6 +43,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
guint32 tag;
|
||||
GtkAdjustment *adjustment;
|
||||
double default_value;
|
||||
} Axis;
|
||||
|
||||
typedef struct {
|
||||
@ -135,6 +136,25 @@ basic_entry_activated (GtkEntry *entry,
|
||||
gtk_adjustment_set_value (adjustment, value);
|
||||
}
|
||||
|
||||
static void
|
||||
font_features_reset_basic (void)
|
||||
{
|
||||
gtk_adjustment_set_value (demo->size_adjustment, 20);
|
||||
gtk_adjustment_set_value (demo->letterspacing_adjustment, 0);
|
||||
gtk_adjustment_set_value (demo->line_height_adjustment, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
update_basic (void)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
|
||||
|
||||
gtk_adjustment_set_value (demo->size_adjustment,
|
||||
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
|
||||
}
|
||||
|
||||
static void add_font_variations (GString *s);
|
||||
|
||||
static void
|
||||
@ -888,6 +908,19 @@ entry_activated (GtkEntry *entry,
|
||||
|
||||
static void unset_instance (GtkAdjustment *adjustment);
|
||||
|
||||
static void
|
||||
font_features_reset_variations (void)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
Axis *axis;
|
||||
|
||||
g_hash_table_iter_init (&iter, demo->axes);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)NULL, (gpointer *)&axis))
|
||||
{
|
||||
gtk_adjustment_set_value (axis->adjustment, axis->default_value);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_font_variations (GString *s)
|
||||
{
|
||||
@ -966,6 +999,7 @@ add_axis (hb_face_t *hb_face,
|
||||
axis = g_new (Axis, 1);
|
||||
axis->tag = ax->tag;
|
||||
axis->adjustment = adjustment;
|
||||
axis->default_value = ax->default_value;
|
||||
g_hash_table_add (demo->axes, axis);
|
||||
|
||||
adjustment_changed (adjustment, GTK_ENTRY (axis_entry));
|
||||
@ -1249,6 +1283,7 @@ done:
|
||||
G_MODULE_EXPORT void
|
||||
font_features_font_changed (void)
|
||||
{
|
||||
update_basic ();
|
||||
update_script_combo ();
|
||||
update_features ();
|
||||
update_font_variations ();
|
||||
@ -1261,7 +1296,7 @@ font_features_script_changed (void)
|
||||
update_display ();
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
static void
|
||||
font_features_reset_features (void)
|
||||
{
|
||||
GList *l;
|
||||
@ -1355,6 +1390,9 @@ do_font_features (GtkWidget *do_widget)
|
||||
scope = gtk_builder_cscope_new ();
|
||||
gtk_builder_cscope_add_callback (scope, basic_value_changed);
|
||||
gtk_builder_cscope_add_callback (scope, basic_entry_activated);
|
||||
gtk_builder_cscope_add_callback (scope, font_features_reset_basic);
|
||||
gtk_builder_cscope_add_callback (scope, font_features_reset_features);
|
||||
gtk_builder_cscope_add_callback (scope, font_features_reset_variations);
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
|
||||
demo = g_new0 (FontFeaturesDemo, 1);
|
||||
|
@ -2,26 +2,26 @@
|
||||
<interface>
|
||||
<object class="GtkAdjustment" id="size_adjustment">
|
||||
<property name="lower">7</property>
|
||||
<property name="upper">100</property>
|
||||
<property name="value">14</property>
|
||||
<property name="step_increment">0.5</property>
|
||||
<property name="page_increment">10</property>
|
||||
<property name="upper">100</property>
|
||||
<signal name="value-changed" handler="basic_value_changed" object="size_entry" swapped="false"/>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="letterspacing_adjustment">
|
||||
<property name="lower">0</property>
|
||||
<property name="lower">-1024</property>
|
||||
<property name="upper">8192</property>
|
||||
<property name="value">0</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">512</property>
|
||||
<property name="upper">10240</property>
|
||||
<signal name="value-changed" handler="basic_value_changed" object="letterspacing_entry" swapped="false"/>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="line_height_adjustment">
|
||||
<property name="lower">1</property>
|
||||
<property name="value">1</property>
|
||||
<property name="lower">0.75</property>
|
||||
<property name="upper">2.5</property>
|
||||
<property name="value">1.0</property>
|
||||
<property name="step_increment">0.1</property>
|
||||
<property name="page_increment">1</property>
|
||||
<property name="upper">3</property>
|
||||
<signal name="value-changed" handler="basic_value_changed" object="line_height_entry" swapped="false"/>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
@ -35,7 +35,9 @@
|
||||
<property name="receives-default">1</property>
|
||||
<property name="tooltip-text">Reset</property>
|
||||
<property name="icon-name">view-refresh-symbolic</property>
|
||||
<signal name="clicked" handler="font_features_reset_basic" swapped="no"/>
|
||||
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
|
||||
<signal name="clicked" handler="font_features_reset_variations" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@ -59,7 +61,7 @@
|
||||
<object class="GtkFontButton" id="font">
|
||||
<property name="receives-default">1</property>
|
||||
<property name="font">Sans 12</property>
|
||||
<property name="level">family|style|size|variations|features</property>
|
||||
<property name="level">family|style</property>
|
||||
<signal name="font-set" handler="font_features_font_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
@ -240,87 +242,93 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">label</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="wrap">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selectable">1</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">entry</property>
|
||||
<property name="child">
|
||||
<object class="GtkEntry" id="entry">
|
||||
<property name="text">Grumpy wizards make toxic brew for the evil Queen and Jack. A quick movement of the enemy will jeopardize six gunboats. The job of waxing linoleum frequently peeves chintzy kids. My girl wove six dozen plaid jackets before she quit. Twelve ziggurats quickly jumped a finch box.
|
||||
|
||||
Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика. Наш банк вчера же выплатил Ф.Я. Эйхгольду комиссию за ценные вещи. Эх, чужак, общий съём цен шляп (юфть) – вдрызг! В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!
|
||||
|
||||
Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός</property>
|
||||
<signal name="activate" handler="font_features_stop_edit"/>
|
||||
<property name="valign">start</property>
|
||||
<property name="width-chars">50</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="settings">
|
||||
<property name="wrap">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="width-chars">50</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<style>
|
||||
<class name="monospace"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="vscrollbar-policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="margin-start">20</property>
|
||||
<property name="margin-end">20</property>
|
||||
<property name="margin-top">20</property>
|
||||
<property name="margin-bottom">20</property>
|
||||
<property name="spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="description">
|
||||
<object class="GtkStack" id="stack">
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">label</property>
|
||||
<property name="child">
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="wrap">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="selectable">1</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">entry</property>
|
||||
<property name="child">
|
||||
<object class="GtkEntry" id="entry">
|
||||
<property name="text">Grumpy wizards make toxic brew for the evil Queen and Jack. A quick movement of the enemy will jeopardize six gunboats. The job of waxing linoleum frequently peeves chintzy kids. My girl wove six dozen plaid jackets before she quit. Twelve ziggurats quickly jumped a finch box.
|
||||
|
||||
Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика. Наш банк вчера же выплатил Ф.Я. Эйхгольду комиссию за ценные вещи. Эх, чужак, общий съём цен шляп (юфть) – вдрызг! В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!
|
||||
|
||||
Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός</property>
|
||||
<signal name="activate" handler="font_features_stop_edit"/>
|
||||
<property name="valign">start</property>
|
||||
<property name="width-chars">50</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="settings">
|
||||
<property name="wrap">1</property>
|
||||
<property name="wrap-mode">char</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="width-chars">50</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<style>
|
||||
<class name="monospace"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="edit_toggle">
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<signal name="toggled" handler="font_features_toggle_edit"/>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="description">
|
||||
<property name="wrap">1</property>
|
||||
<property name="wrap-mode">char</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="width-chars">50</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="hexpand">1</property>
|
||||
<style>
|
||||
<class name="monospace"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="edit_toggle">
|
||||
<property name="icon-name">document-edit-symbolic</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">end</property>
|
||||
<signal name="toggled" handler="font_features_toggle_edit"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
Loading…
Reference in New Issue
Block a user