equal
deleted
inserted
replaced
13 import java.awt.Font |
13 import java.awt.Font |
14 |
14 |
15 import org.gjt.sp.jedit.{jEdit, View} |
15 import org.gjt.sp.jedit.{jEdit, View} |
16 |
16 |
17 |
17 |
18 object Font_Info |
18 object Font_Info { |
19 { |
|
20 /* size range */ |
19 /* size range */ |
21 |
20 |
22 val min_size = 5 |
21 val min_size = 5 |
23 val max_size = 250 |
22 val max_size = 250 |
24 |
23 |
36 Font_Info(main_family(), main_size(scale)) |
35 Font_Info(main_family(), main_size(scale)) |
37 |
36 |
38 |
37 |
39 /* incremental size change */ |
38 /* incremental size change */ |
40 |
39 |
41 object main_change |
40 object main_change { |
42 { |
41 private def change_size(change: Float => Float): Unit = { |
43 private def change_size(change: Float => Float): Unit = |
|
44 { |
|
45 GUI_Thread.require {} |
42 GUI_Thread.require {} |
46 |
43 |
47 val size0 = main_size() |
44 val size0 = main_size() |
48 val size = restrict_size(change(size0)).round |
45 val size = restrict_size(change(size0)).round |
49 if (size != size0) { |
46 if (size != size0) { |
54 } |
51 } |
55 } |
52 } |
56 |
53 |
57 // owned by GUI thread |
54 // owned by GUI thread |
58 private var steps = 0 |
55 private var steps = 0 |
59 private val delay = Delay.last(PIDE.options.seconds("editor_input_delay"), gui = true) |
56 private val delay = Delay.last(PIDE.options.seconds("editor_input_delay"), gui = true) { |
60 { |
57 change_size(size => { |
61 change_size(size => |
58 var i = size.round |
62 { |
59 while (steps != 0 && i > 0) { |
63 var i = size.round |
60 if (steps > 0) { i += (i / 10) max 1; steps -= 1 } |
64 while (steps != 0 && i > 0) { |
61 else { i -= (i / 10) max 1; steps += 1 } |
65 if (steps > 0) |
62 } |
66 { i += (i / 10) max 1; steps -= 1 } |
63 steps = 0 |
67 else |
64 i.toFloat |
68 { i -= (i / 10) max 1; steps += 1 } |
65 }) |
69 } |
|
70 steps = 0 |
|
71 i.toFloat |
|
72 }) |
|
73 } |
66 } |
74 |
67 |
75 def step(i: Int): Unit = |
68 def step(i: Int): Unit = { |
76 { |
|
77 steps += i |
69 steps += i |
78 delay.invoke() |
70 delay.invoke() |
79 } |
71 } |
80 |
72 |
81 def reset(size: Float): Unit = |
73 def reset(size: Float): Unit = { |
82 { |
|
83 delay.revoke() |
74 delay.revoke() |
84 steps = 0 |
75 steps = 0 |
85 change_size(_ => size) |
76 change_size(_ => size) |
86 } |
77 } |
87 } |
78 } |
90 /* zoom box */ |
81 /* zoom box */ |
91 |
82 |
92 abstract class Zoom_Box extends GUI.Zoom_Box { tooltip = "Zoom factor for output font size" } |
83 abstract class Zoom_Box extends GUI.Zoom_Box { tooltip = "Zoom factor for output font size" } |
93 } |
84 } |
94 |
85 |
95 sealed case class Font_Info(family: String, size: Float) |
86 sealed case class Font_Info(family: String, size: Float) { |
96 { |
|
97 def font: Font = new Font(family, Font.PLAIN, size.round) |
87 def font: Font = new Font(family, Font.PLAIN, size.round) |
98 } |
88 } |
99 |
|