Commit a7ef7a0e authored by Martin Rudalics's avatar Martin Rudalics

Some fixes for scroll bar code.

* w32term.c (w32_horizontal_scroll_bar_handle_click): In
`event->y' return entire range (the size of the scroll bar minus
that of the thumb).
* xterm.c (xm_scroll_callback, xaw_jump_callback): In `whole'
return entire range (the scaled size of the scroll bar minus
that of the slider).  In `portion' return the scaled position of
the slider.
(xaw_jump_callback): Restore part of code for vertical scroll
bar broken in change from 2014-07-27.
(xaw_scroll_callback): Provide incremental scrolling with
horizontal scroll bars.
(x_scroll_bar_handle_click): Fix typo introduced in change from
2014-07-27.
* scroll-bar.el (scroll-bar-horizontal-drag-1): Handle new
interpretation of `portion-whole'.
parent f1fdf67b
2014-08-28 Martin Rudalics <rudalics@gmx.at>
* scroll-bar.el (scroll-bar-horizontal-drag-1): Handle new
interpretation of `portion-whole'.
2014-08-28 Michael Albinus <michael.albinus@gmx.de>
* emacs-lisp/authors.el (authors-aliases): Addition.
......
......@@ -330,9 +330,11 @@ If you click outside the slider, the window scrolls to bring the slider there."
(if (eq (current-bidi-paragraph-direction (window-buffer window))
'left-to-right)
(set-window-hscroll
window (/ (1- (+ (car portion-whole) unit)) unit))
window (/ (+ (car portion-whole) (1- unit)) unit))
(set-window-hscroll
window (/ (1- (+ (cdr portion-whole) unit)) unit)))))
window (/ (+ (- (cdr portion-whole) (car portion-whole))
(1- unit))
unit)))))
(defun scroll-bar-horizontal-drag (event)
"Scroll the window horizontally by dragging the scroll bar slider.
......
2014-08-28 Martin Rudalics <rudalics@gmx.at>
* w32term.c (w32_horizontal_scroll_bar_handle_click): In
`event->y' return entire range (the size of the scroll bar minus
that of the thumb).
* xterm.c (xm_scroll_callback, xaw_jump_callback): In `whole'
return entire range (the scaled size of the scroll bar minus
that of the slider). In `portion' return the scaled position of
the slider.
(xaw_jump_callback): Restore part of code for vertical scroll
bar broken in change from 2014-07-27.
(xaw_scroll_callback): Provide incremental scrolling with
horizontal scroll bars.
(x_scroll_bar_handle_click): Fix typo introduced in change from
2014-07-27.
2014-08-28 Eli Zaretskii <eliz@gnu.org>
* conf_post.h (_GL_EXECINFO_INLINE) [MSDOS]: Don't define.
......
......@@ -4293,7 +4293,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
x = si.nTrackPos;
else
x = si.nPos;
y = si.nMax - x - si.nPage;
y = si.nMax - si.nPage;
bar->dragging = 0;
FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
......@@ -4350,12 +4350,9 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
int end = bar->end;
si.cbSize = sizeof (si);
/** si.fMask = SIF_PAGE | SIF_POS; **/
si.fMask = SIF_POS;
/** si.nPage = end - start + HORIZONTAL_SCROLL_BAR_MIN_HANDLE; **/
si.nPos = min (last_scroll_bar_drag_pos,
XWINDOW (bar->window)->hscroll_whole - 1);
/** si.nPos = last_scroll_bar_drag_pos; **/
SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
}
/* fall through */
......
......@@ -4549,12 +4549,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
if (horizontal)
{
whole = bar->whole;
portion = (((float) cs->value
/ (XM_SB_MAX - slider_size))
* (whole
- ((float) slider_size / XM_SB_MAX) * whole));
portion = max (0, portion);
portion = bar->whole * ((float)cs->value / XM_SB_MAX);
whole = bar->whole * ((float)(XM_SB_MAX - slider_size) / XM_SB_MAX);
portion = min (portion, whole);
part = scroll_bar_horizontal_handle;
}
else
......@@ -4687,24 +4684,51 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
float *top_addr = call_data;
float top = *top_addr;
float shown;
int whole, portion, height;
int whole, portion, height, width;
enum scroll_bar_part part;
int horizontal = bar->horizontal;
/* Get the size of the thumb, a value between 0 and 1. */
block_input ();
XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
unblock_input ();
if (horizontal)
{
whole = bar->whole;
portion = (top * (whole - (shown * whole))) / (1 - shown);
portion = max (0, portion);
/* Get the size of the thumb, a value between 0 and 1. */
block_input ();
XtVaGetValues (widget, XtNshown, &shown, XtNwidth, &width, NULL);
unblock_input ();
if (shown < 1)
{
whole = bar->whole - (shown * bar->whole);
portion = min (top * bar->whole, whole);
}
else
{
whole = bar->whole;
portion = 0;
}
part = scroll_bar_horizontal_handle;
}
else
part = scroll_bar_handle;
{
/* Get the size of the thumb, a value between 0 and 1. */
block_input ();
XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
unblock_input ();
whole = 10000000;
portion = shown < 1 ? top * whole : 0;
if (shown < 1 && (eabs (top + shown - 1) < 1.0f / height))
/* Some derivatives of Xaw refuse to shrink the thumb when you reach
the bottom, so we force the scrolling whenever we see that we're
too close to the bottom (in x_set_toolkit_scroll_bar_thumb
we try to ensure that we always stay two pixels away from the
bottom). */
part = scroll_bar_down_arrow;
else
part = scroll_bar_handle;
}
window_being_scrolled = bar->window;
bar->dragging = portion;
......@@ -4727,28 +4751,54 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
struct scroll_bar *bar = client_data;
/* The position really is stored cast to a pointer. */
int position = (intptr_t) call_data;
Dimension height;
Dimension height, width;
enum scroll_bar_part part;
/* Get the height of the scroll bar. */
block_input ();
XtVaGetValues (widget, XtNheight, &height, NULL);
unblock_input ();
if (bar->horizontal)
{
/* Get the width of the scroll bar. */
block_input ();
XtVaGetValues (widget, XtNwidth, &width, NULL);
unblock_input ();
if (eabs (position) >= width)
part = (position < 0) ? scroll_bar_before_handle : scroll_bar_after_handle;
if (eabs (position) >= height)
part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle;
/* If Xaw3d was compiled with ARROW_SCROLLBAR,
it maps line-movement to call_data = max(5, height/20). */
else if (xaw3d_arrow_scroll && eabs (position) <= max (5, width / 20))
part = (position < 0) ? scroll_bar_left_arrow : scroll_bar_right_arrow;
else
part = scroll_bar_move_ratio;
/* If Xaw3d was compiled with ARROW_SCROLLBAR,
it maps line-movement to call_data = max(5, height/20). */
else if (xaw3d_arrow_scroll && eabs (position) <= max (5, height / 20))
part = (position < 0) ? scroll_bar_up_arrow : scroll_bar_down_arrow;
window_being_scrolled = bar->window;
bar->dragging = -1;
bar->last_seen_part = part;
x_send_scroll_bar_event (bar->window, part, position, width, bar->horizontal);
}
else
part = scroll_bar_move_ratio;
{
window_being_scrolled = bar->window;
bar->dragging = -1;
bar->last_seen_part = part;
x_send_scroll_bar_event (bar->window, part, position, height, bar->horizontal);
/* Get the height of the scroll bar. */
block_input ();
XtVaGetValues (widget, XtNheight, &height, NULL);
unblock_input ();
if (eabs (position) >= height)
part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle;
/* If Xaw3d was compiled with ARROW_SCROLLBAR,
it maps line-movement to call_data = max(5, height/20). */
else if (xaw3d_arrow_scroll && eabs (position) <= max (5, height / 20))
part = (position < 0) ? scroll_bar_up_arrow : scroll_bar_down_arrow;
else
part = scroll_bar_move_ratio;
window_being_scrolled = bar->window;
bar->dragging = -1;
bar->last_seen_part = part;
x_send_scroll_bar_event (bar->window, part, position, height, bar->horizontal);
}
}
#endif /* not USE_GTK and not USE_MOTIF */
......@@ -6134,7 +6184,7 @@ x_scroll_bar_handle_click (struct scroll_bar *bar,
/* If the user has released the handle, set it to its final position. */
if (event->type == ButtonRelease && bar->dragging != -1)
{
int new_start = - bar->dragging;
int new_start = y - bar->dragging;
int new_end = new_start + bar->end - bar->start;
x_scroll_bar_set_handle (bar, new_start, new_end, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment