Skip to content

Commit 7165615

Browse files
Merge pull request #85 from SubhadeepJasu/auto_button_size
Scale button fonts with app width
2 parents 041f259 + abd80f5 commit 7165615

11 files changed

+198
-24
lines changed

data/Application.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
.Pebbles_Buttons_Memory {
9898
color: #333;
99-
text-shadow: 0 1px alpha (#000, 0.0);
99+
text-shadow: 0 1px alpha (#000, 0.2), 0 0 0 2px #000;
100100
-gtk-icon-shadow: 0 1px alpha (#000, 0.0);
101101
border-color: alpha(#000, 0.5);
102102
background-image: linear-gradient(#ffe16b, #f9c440);
@@ -442,4 +442,4 @@ scrolledwindow overshoot.left {
442442
border: 1px solid alpha(#000, 0.5);
443443
border-radius: 4px;
444444
background-color: alpha(@accent_color, 0.2);
445-
}
445+
}

data/com.github.subhadeepjasu.pebbles.appdata.xml.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@
9393
<content_attribute id="money-gambling">none</content_attribute>
9494
</content_rating>
9595
<releases>
96+
<release date="2021-09-19" version="2.0.2">
97+
<description>
98+
<p>Fixed:</p>
99+
<ul>
100+
<li>[Converter] Fix multiple errors in the converters</li>
101+
</ul>
102+
<p>Improved:</p>
103+
<ul>
104+
<li>[UI] Scale button font with app width (a11y)</li>
105+
</ul>
106+
</description>
107+
</release>
96108
<release date="2021-09-08" version="2.0.1">
97109
<description>
98110
<p>Improved:</p>

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
project (
33
'com.github.subhadeepjasu.pebbles',
44
'vala', 'c',
5-
version: '2.0.1',
5+
version: '2.0.2',
66
)
77

88
# GNOME module

src/Application.vala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace Pebbles {
4141
.pebbles_h1 { font-size: %dpx; }
4242
.pebbles_h2 { font-size: %dpx; }
4343
.pebbles_h4 { font-size: %dpx; }
44+
.pebbles_button_font_size { font-size: %dpx; }
45+
.pebbles_button_font_size_h3 { font-size: %dpx; }
4446
";
4547

4648
public PebblesApp () {
@@ -54,9 +56,12 @@ namespace Pebbles {
5456
Timeout.add_seconds (1, () => {
5557
if (this.get_active_window () != null) {
5658
int height = this.get_active_window ().get_allocated_height ();
57-
if (((MainWindow) (this.get_active_window ())).previous_height != height) {
59+
int width = this.get_active_window ().get_allocated_width ();
60+
if (((MainWindow) (this.get_active_window ())).previous_height != height ||
61+
((MainWindow) (this.get_active_window ())).previous_width != width) {
5862
((MainWindow) (this.get_active_window ())).previous_height = height;
59-
adjust_font_responsive (height);
63+
((MainWindow) (this.get_active_window ())).previous_width = width;
64+
adjust_font_responsive (height, width);
6065
}
6166
return true;
6267
}
@@ -131,12 +136,19 @@ namespace Pebbles {
131136
private double map_range (double input, double input_start, double input_end, double output_start, double output_end) {
132137
return output_start + ((output_end - output_start) / (input_end - input_start)) * (input - input_start);
133138
}
134-
private void adjust_font_responsive (int height) {
139+
private void adjust_font_responsive (int height, int width) {
135140
try {
136141
var target_size_h1 = (int)map_range (double.max((double) height/600, 1), 1, 2, 40, 120);
137142
var target_size_h2 = (int)map_range (double.max((double) height/600, 1), 1, 2, 20, 50);
138143
var target_size_h4 = (int)map_range (double.max((double) height/600, 1), 1, 2, 10, 20);
139-
var css = DISPLAY_FONT_SIZE_TEMPLATE.printf(target_size_h1, target_size_h2, target_size_h4);
144+
var target_size_button = (int)map_range (double.max((double) width/1000, 1), 1, 1.5, 12, 22);
145+
if (target_size_button < 12) target_size_button = 12;
146+
if (target_size_button > 28) target_size_button = 28;
147+
var css = DISPLAY_FONT_SIZE_TEMPLATE.printf(target_size_h1,
148+
target_size_h2,
149+
target_size_h4,
150+
target_size_button,
151+
target_size_button + 4);
140152
font_size_provider.load_from_data (css, -1);
141153
} catch (Error e) {
142154
Process.exit(1);

src/MainWindow.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ namespace Pebbles {
125125
bool initialized = false;
126126

127127
public int previous_height = 0;
128+
public int previous_width = 0;
128129

129130
public MainWindow () {
130131
settings = Pebbles.Settings.get_default ();
@@ -607,6 +608,7 @@ namespace Pebbles {
607608
if ((this.common_view.get_visible_child () == this.scientific_view && this.scientific_view.button_leaflet.folded) ||
608609
(this.common_view.get_visible_child () == this.calculus_view && this.calculus_view.button_leaflet.folded) ||
609610
(this.common_view.get_visible_child () == this.programmer_view && this.programmer_view.button_leaflet.folded) ||
611+
(this.common_view.get_visible_child () == this.statistics_view && this.statistics_view.button_leaflet.folded) ||
610612
(this.common_view.get_visible_child () == this.date_view && this.date_view.get_allocated_width () < 540) ||
611613
(this.common_view.get_visible_child () == this.conv_length_view) ||
612614
(this.common_view.get_visible_child () == this.conv_area_view) ||

src/Views/CalculusView.vala

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ namespace Pebbles {
176176
// Make buttons on the left
177177
all_clear_button = new StyledButton ("AC", _("All Clear"), {"Delete"});
178178
all_clear_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
179+
all_clear_button.get_style_context ().add_class ("pebbles_button_font_size");
179180
del_button = new Gtk.Button.from_icon_name ("edit-clear-symbolic", Gtk.IconSize.BUTTON);
180181
del_button.set_tooltip_text (_("Backspace"));
181182
del_button.get_style_context ().remove_class ("image-button");
183+
del_button.get_style_context ().add_class ("pebbles_button_font_size");
182184
if (display_unit.input_entry.get_text () =="0" || display_unit.input_entry.get_text () == "") {
183185
del_button.sensitive = false;
184186
} else {
@@ -191,27 +193,41 @@ namespace Pebbles {
191193
del_button.sensitive = true;
192194
});
193195
variable_button = new StyledButton ("𝑥", _("Variable for linear expressions"), {"X"});
196+
variable_button.get_style_context ().add_class ("pebbles_button_font_size");
194197
divide_button = new StyledButton ("\xC3\xB7", _("Divide"));
195-
divide_button.get_style_context ().add_class ("h3");
198+
divide_button.get_style_context ().add_class ("pebbles_button_font_size_h3");
196199
seven_button = new StyledButton ("7");
200+
seven_button.get_style_context ().add_class ("pebbles_button_font_size");
197201
eight_button = new StyledButton ("8");
202+
eight_button.get_style_context ().add_class ("pebbles_button_font_size");
198203
nine_button = new StyledButton ("9");
204+
nine_button.get_style_context ().add_class ("pebbles_button_font_size");
199205
multiply_button = new StyledButton ("\xC3\x97", _("Multiply"));
200-
multiply_button.get_style_context ().add_class ("h3");
206+
multiply_button.get_style_context ().add_class ("pebbles_button_font_size_h3");
201207
four_button = new StyledButton ("4");
208+
four_button.get_style_context ().add_class ("pebbles_button_font_size");
202209
five_button = new StyledButton ("5");
210+
five_button.get_style_context ().add_class ("pebbles_button_font_size");
203211
six_button = new StyledButton ("6");
212+
six_button.get_style_context ().add_class ("pebbles_button_font_size");
204213
subtract_button = new StyledButton ("\xE2\x88\x92", _("Subtract"));
205-
subtract_button.get_style_context ().add_class ("h3");
214+
subtract_button.get_style_context ().add_class ("pebbles_button_font_size_h3");
206215
one_button = new StyledButton ("1");
216+
one_button.get_style_context ().add_class ("pebbles_button_font_size");
207217
two_button = new StyledButton ("2");
218+
two_button.get_style_context ().add_class ("pebbles_button_font_size");
208219
three_button = new StyledButton ("3");
220+
three_button.get_style_context ().add_class ("pebbles_button_font_size");
209221
plus_button = new StyledButton ("+", _("Add"));
210-
plus_button.get_style_context ().add_class ("h3");
222+
plus_button.get_style_context ().add_class ("pebbles_button_font_size_h3");
211223
zero_button = new StyledButton ("0");
224+
zero_button.get_style_context ().add_class ("pebbles_button_font_size");
212225
decimal_button = new StyledButton (Utils.get_local_radix_symbol ());
226+
decimal_button.get_style_context ().add_class ("pebbles_button_font_size");
213227
left_parenthesis_button = new StyledButton ("(");
228+
left_parenthesis_button.get_style_context ().add_class ("pebbles_button_font_size");
214229
right_parenthesis_button = new StyledButton (")");
230+
right_parenthesis_button.get_style_context ().add_class ("pebbles_button_font_size");
215231

216232
button_container_left.attach (all_clear_button, 0, 0, 1, 1);
217233
button_container_left.attach (del_button, 1, 0, 1, 1);
@@ -240,37 +256,53 @@ namespace Pebbles {
240256
// Make buttons on the right
241257
pow_root_button = new StyledButton ("x<sup>y</sup>", _("x raised to the power y"), {"Z"});
242258
pow_root_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
259+
pow_root_button.get_style_context ().add_class ("pebbles_button_font_size");
243260
memory_plus_button = new StyledButton ("M+", _("Add it to the value in Memory"), {"F3"});
244261
memory_plus_button.get_style_context ().add_class ("Pebbles_Buttons_Memory");
262+
memory_plus_button.get_style_context ().add_class ("pebbles_button_font_size");
245263
sin_button = new StyledButton ("sin", _("Sine"), {"S"});
246264
sin_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
265+
sin_button.get_style_context ().add_class ("pebbles_button_font_size");
247266
sinh_button = new StyledButton ("sinh", _("Hyperbolic Sine"), {"H"});
248267
sinh_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
268+
sinh_button.get_style_context ().add_class ("pebbles_button_font_size");
249269
memory_minus_button = new StyledButton ("M\xE2\x88\x92", _("Subtract it from the value in Memory"), {"F4"});
250270
memory_minus_button.get_style_context ().add_class ("Pebbles_Buttons_Memory");
271+
memory_minus_button.get_style_context ().add_class ("pebbles_button_font_size");
251272
cos_button = new StyledButton ("cos", _("Cosine"), {"C"});
252273
cos_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
274+
cos_button.get_style_context ().add_class ("pebbles_button_font_size");
253275
cosh_button = new StyledButton ("cosh", _("Hyperbolic Cosine"), {"O"});
254276
cosh_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
277+
cosh_button.get_style_context ().add_class ("pebbles_button_font_size");
255278
log_mod_button = new StyledButton ("Mod", _("Modulus"), {"M"});
256279
log_mod_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
280+
log_mod_button.get_style_context ().add_class ("pebbles_button_font_size");
257281
memory_recall_button = new StyledButton ("MR", _("Recall value from Memory"), {"F5"});
258282
memory_recall_button.get_style_context ().add_class ("Pebbles_Buttons_Memory");
283+
memory_recall_button.get_style_context ().add_class ("pebbles_button_font_size");
259284
tan_button = new StyledButton ("tan", _("Tangent"), {"T"});
260285
tan_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
286+
tan_button.get_style_context ().add_class ("pebbles_button_font_size");
261287
tanh_button = new StyledButton ("tanh", _("Hyperbolic Tangent"), {"A"});
262288
tanh_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
289+
tanh_button.get_style_context ().add_class ("pebbles_button_font_size");
263290
perm_comb_button = new StyledButton ("<sup>n</sup>P\xE1\xB5\xA3", _("Permutations"), {"P"});
264291
perm_comb_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
292+
perm_comb_button.get_style_context ().add_class ("pebbles_button_font_size");
265293
memory_clear_button = new StyledButton ("MC", _("Memory Clear"), {"F6"});
266294
memory_clear_button.get_style_context ().add_class ("Pebbles_Buttons_Memory");
295+
memory_clear_button.get_style_context ().add_class ("pebbles_button_font_size");
267296
fact_button = new StyledButton ("!", _("Factorial"), {"F"});
268297
fact_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
298+
fact_button.get_style_context ().add_class ("pebbles_button_font_size");
269299
constant_button = new StyledButton (constant_label_1, constant_desc_1, {"R"});
270300
constant_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
301+
constant_button.get_style_context ().add_class ("pebbles_button_font_size");
271302
last_answer_button = new StyledButton ("Ans", _("Last answer"), {"F7"});
272303
last_answer_button.sensitive = false;
273304
last_answer_button.get_style_context ().add_class ("Pebbles_Buttons_Function");
305+
last_answer_button.get_style_context ().add_class ("pebbles_button_font_size");
274306

275307
// Make integration section
276308
var integration_grid = new Gtk.Grid ();
@@ -280,6 +312,7 @@ namespace Pebbles {
280312
integration_button = new StyledButton ("\xE2\x88\xAB", _("Definite Integral (Upper limit 'u' and Lower limit 'l')"), {"I"});
281313
integration_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
282314
integration_button.get_style_context ().add_class ("suggested-override");
315+
integration_button.get_style_context ().add_class ("pebbles_button_font_size");
283316
integration_button.margin_top = 5;
284317
integration_button.margin_start = 2;
285318

@@ -341,6 +374,7 @@ namespace Pebbles {
341374
derivation_button = new StyledButton ("dy/dx", _("Derivative (at a point x)"), {"D"});
342375
derivation_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
343376
derivation_button.get_style_context ().add_class ("suggested-override");
377+
derivation_button.get_style_context ().add_class ("pebbles_button_font_size");
344378
derivation_button.margin_top = 5;
345379
derivation_button.margin_start = 2;
346380

src/Views/CommonKeyPadConverter.vala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,32 @@ namespace Pebbles {
4747
del_button = new Gtk.Button.from_icon_name ("edit-clear-symbolic", Gtk.IconSize.BUTTON);
4848
del_button.set_tooltip_text (_("Backspace"));
4949
del_button.get_style_context ().remove_class ("image-button");
50+
del_button.get_style_context ().add_class ("pebbles_button_font_size");
5051
all_clear_button = new StyledButton ("AC", (_("Clear Entry")));
5152
all_clear_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
53+
all_clear_button.get_style_context ().add_class ("pebbles_button_font_size");
5254
seven_button = new StyledButton ("7");
55+
seven_button.get_style_context ().add_class ("pebbles_button_font_size");
5356
eight_button = new StyledButton ("8");
57+
eight_button.get_style_context ().add_class ("pebbles_button_font_size");
5458
nine_button = new StyledButton ("9");
59+
nine_button.get_style_context ().add_class ("pebbles_button_font_size");
5560
four_button = new StyledButton ("4");
61+
four_button.get_style_context ().add_class ("pebbles_button_font_size");
5662
five_button = new StyledButton ("5");
63+
five_button.get_style_context ().add_class ("pebbles_button_font_size");
5764
six_button = new StyledButton ("6");
65+
six_button.get_style_context ().add_class ("pebbles_button_font_size");
5866
one_button = new StyledButton ("1");
67+
one_button.get_style_context ().add_class ("pebbles_button_font_size");
5968
two_button = new StyledButton ("2");
69+
two_button.get_style_context ().add_class ("pebbles_button_font_size");
6070
three_button = new StyledButton ("3");
71+
three_button.get_style_context ().add_class ("pebbles_button_font_size");
6172
zero_button = new StyledButton ("0");
73+
zero_button.get_style_context ().add_class ("pebbles_button_font_size");
6274
decimal_button = new StyledButton (".");
75+
decimal_button.get_style_context ().add_class ("pebbles_button_font_size");
6376

6477
// Arange the buttons
6578
attach (all_clear_button, 0, 0, 1, 1);

src/Views/CommonNumericKeypad.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace Pebbles {
4949

5050
construct {
5151
main_grid = new Gtk.Grid ();
52+
this.get_style_context ().add_class ("pebbles_button_font_size");
5253
// Make the buttons
5354
del_button = new StyledButton ("Del", (_("Backspace")));
5455
all_clear_button = new StyledButton ("AC", (_("All Clear")));

0 commit comments

Comments
 (0)