diff options
| author | YAMAMOTO Mitsuharu | 2007-02-24 02:43:04 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2007-02-24 02:43:04 +0000 |
| commit | 4d5724e587b5a9f5b91a4b2976e81996e9980fe2 (patch) | |
| tree | 95f61aebb02a8477cb559123503354d2c446dfbc /src | |
| parent | bfd1426943601edbd4cd7abc90b8fac2cf0bd066 (diff) | |
| download | emacs-4d5724e587b5a9f5b91a4b2976e81996e9980fe2.tar.gz emacs-4d5724e587b5a9f5b91a4b2976e81996e9980fe2.zip | |
[USE_TOOLKIT_SCROLL_BARS] (x_scroll_bar_handle_drag)
(x_set_toolkit_scroll_bar_thumb): Add bar->min_handle as margin to
scroll bar handle size in order to avoid `scroll backward' problem.
(x_scroll_bar_create, XTset_vertical_scroll_bar)
[USE_TOOLKIT_SCROLL_BARS]: Initialize bar->min_handle.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/macterm.c b/src/macterm.c index b00317baf31..25c41ce9557 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -4829,9 +4829,7 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp) | |||
| 4829 | XSETINT (bar->dragging, - (XINT (bar->dragging) + 1)); | 4829 | XSETINT (bar->dragging, - (XINT (bar->dragging) + 1)); |
| 4830 | 4830 | ||
| 4831 | top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top); | 4831 | top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top); |
| 4832 | top_range = (XINT (bar->track_height) - (r.bottom - r.top)) * | 4832 | top_range = XINT (bar->track_height) - XINT (bar->min_handle); |
| 4833 | (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch)) | ||
| 4834 | + .5; | ||
| 4835 | 4833 | ||
| 4836 | if (top < 0) | 4834 | if (top < 0) |
| 4837 | top = 0; | 4835 | top = 0; |
| @@ -4898,13 +4896,16 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | |||
| 4898 | if (XINT (bar->track_height) == 0) | 4896 | if (XINT (bar->track_height) == 0) |
| 4899 | return; | 4897 | return; |
| 4900 | 4898 | ||
| 4901 | if (whole == 0) | 4899 | if (whole <= portion) |
| 4902 | value = 0, viewsize = 1, maximum = 0; | 4900 | value = 0, viewsize = 1, maximum = 0; |
| 4903 | else | 4901 | else |
| 4904 | { | 4902 | { |
| 4905 | value = position; | 4903 | float scale; |
| 4906 | viewsize = portion; | 4904 | |
| 4907 | maximum = max (0, whole - portion); | 4905 | maximum = XINT (bar->track_height) - XINT (bar->min_handle); |
| 4906 | scale = (float) maximum / (whole - portion); | ||
| 4907 | value = position * scale + 0.5f; | ||
| 4908 | viewsize = (int) (portion * scale + 0.5f) + XINT (bar->min_handle); | ||
| 4908 | } | 4909 | } |
| 4909 | 4910 | ||
| 4910 | BLOCK_INPUT; | 4911 | BLOCK_INPUT; |
| @@ -4985,6 +4986,7 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height) | |||
| 4985 | #ifdef USE_TOOLKIT_SCROLL_BARS | 4986 | #ifdef USE_TOOLKIT_SCROLL_BARS |
| 4986 | bar->track_top = Qnil; | 4987 | bar->track_top = Qnil; |
| 4987 | bar->track_height = Qnil; | 4988 | bar->track_height = Qnil; |
| 4989 | bar->min_handle = Qnil; | ||
| 4988 | #endif | 4990 | #endif |
| 4989 | 4991 | ||
| 4990 | /* Add bar to its frame's list of scroll bars. */ | 4992 | /* Add bar to its frame's list of scroll bars. */ |
| @@ -5205,6 +5207,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 5205 | #ifdef USE_TOOLKIT_SCROLL_BARS | 5207 | #ifdef USE_TOOLKIT_SCROLL_BARS |
| 5206 | bar->track_top = Qnil; | 5208 | bar->track_top = Qnil; |
| 5207 | bar->track_height = Qnil; | 5209 | bar->track_height = Qnil; |
| 5210 | bar->min_handle = Qnil; | ||
| 5208 | #endif | 5211 | #endif |
| 5209 | } | 5212 | } |
| 5210 | 5213 | ||
| @@ -5218,6 +5221,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 5218 | { | 5221 | { |
| 5219 | XSETINT (bar->track_top, 0); | 5222 | XSETINT (bar->track_top, 0); |
| 5220 | XSETINT (bar->track_height, 0); | 5223 | XSETINT (bar->track_height, 0); |
| 5224 | XSETINT (bar->min_handle, 0); | ||
| 5221 | } | 5225 | } |
| 5222 | else | 5226 | else |
| 5223 | { | 5227 | { |
| @@ -5227,7 +5231,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 5227 | BLOCK_INPUT; | 5231 | BLOCK_INPUT; |
| 5228 | 5232 | ||
| 5229 | SetControl32BitMinimum (ch, 0); | 5233 | SetControl32BitMinimum (ch, 0); |
| 5230 | SetControl32BitMaximum (ch, 1); | 5234 | SetControl32BitMaximum (ch, 1 << 30); |
| 5231 | SetControlViewSize (ch, 1); | 5235 | SetControlViewSize (ch, 1); |
| 5232 | 5236 | ||
| 5233 | /* Move the scroll bar thumb to the top. */ | 5237 | /* Move the scroll bar thumb to the top. */ |
| @@ -5235,12 +5239,13 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 5235 | get_control_part_bounds (ch, kControlIndicatorPart, &r0); | 5239 | get_control_part_bounds (ch, kControlIndicatorPart, &r0); |
| 5236 | 5240 | ||
| 5237 | /* Move the scroll bar thumb to the bottom. */ | 5241 | /* Move the scroll bar thumb to the bottom. */ |
| 5238 | SetControl32BitValue (ch, 1); | 5242 | SetControl32BitValue (ch, 1 << 30); |
| 5239 | get_control_part_bounds (ch, kControlIndicatorPart, &r1); | 5243 | get_control_part_bounds (ch, kControlIndicatorPart, &r1); |
| 5240 | 5244 | ||
| 5241 | UnionRect (&r0, &r1, &r0); | 5245 | UnionRect (&r0, &r1, &r0); |
| 5242 | XSETINT (bar->track_top, r0.top); | 5246 | XSETINT (bar->track_top, r0.top); |
| 5243 | XSETINT (bar->track_height, r0.bottom - r0.top); | 5247 | XSETINT (bar->track_height, r0.bottom - r0.top); |
| 5248 | XSETINT (bar->min_handle, r1.bottom - r1.top); | ||
| 5244 | 5249 | ||
| 5245 | /* Don't show the scroll bar if its height is not enough to | 5250 | /* Don't show the scroll bar if its height is not enough to |
| 5246 | display the scroll bar thumb. */ | 5251 | display the scroll bar thumb. */ |