Fix scrollbars so that clicks scroll the pane to a location that matches
the clicked location. Interpret mousewheel events so that scroll panes can be scrolled. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2307
This commit is contained in:
parent
7093b65c7d
commit
bc087b49e2
2 changed files with 38 additions and 8 deletions
|
|
@ -34,10 +34,12 @@
|
|||
|
||||
// Special keypress values that correspond to mouse button clicks
|
||||
|
||||
#define TXT_MOUSE_BASE 0x10000
|
||||
#define TXT_MOUSE_LEFT (TXT_MOUSE_BASE + 0)
|
||||
#define TXT_MOUSE_RIGHT (TXT_MOUSE_BASE + 1)
|
||||
#define TXT_MOUSE_MIDDLE (TXT_MOUSE_BASE + 2)
|
||||
#define TXT_MOUSE_BASE 0x10000
|
||||
#define TXT_MOUSE_LEFT (TXT_MOUSE_BASE + 0)
|
||||
#define TXT_MOUSE_RIGHT (TXT_MOUSE_BASE + 1)
|
||||
#define TXT_MOUSE_MIDDLE (TXT_MOUSE_BASE + 2)
|
||||
#define TXT_MOUSE_SCROLLUP (TXT_MOUSE_BASE + 3)
|
||||
#define TXT_MOUSE_SCROLLDOWN (TXT_MOUSE_BASE + 4)
|
||||
#define TXT_MAX_MOUSE_BUTTONS 16
|
||||
|
||||
// Screen size
|
||||
|
|
|
|||
|
|
@ -416,6 +416,33 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
|
|||
|
||||
scrollbars = NeedsScrollbars(scrollpane);
|
||||
|
||||
if (b == TXT_MOUSE_SCROLLUP)
|
||||
{
|
||||
if (scrollbars & SCROLLBAR_VERTICAL)
|
||||
{
|
||||
--scrollpane->y;
|
||||
}
|
||||
else if (scrollbars & SCROLLBAR_HORIZONTAL)
|
||||
{
|
||||
--scrollpane->x;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (b == TXT_MOUSE_SCROLLDOWN)
|
||||
{
|
||||
if (scrollbars & SCROLLBAR_VERTICAL)
|
||||
{
|
||||
++scrollpane->y;
|
||||
}
|
||||
else if (scrollbars & SCROLLBAR_HORIZONTAL)
|
||||
{
|
||||
++scrollpane->x;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rel_x = x - scrollpane->widget.x;
|
||||
rel_y = y - scrollpane->widget.y;
|
||||
|
||||
|
|
@ -433,14 +460,15 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
|
|||
else
|
||||
{
|
||||
int range = FullWidth(scrollpane) - scrollpane->w;
|
||||
int bar_max = scrollpane->w - 3;
|
||||
|
||||
scrollpane->x = ((rel_x - 1) * range) / (scrollpane->w - 3);
|
||||
scrollpane->x = ((rel_x - 1) * range + (bar_max / 2)) / bar_max;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Click on the horizontal scrollbar?
|
||||
// Click on the vertical scrollbar?
|
||||
if ((scrollbars & SCROLLBAR_VERTICAL) && rel_x == scrollpane->w)
|
||||
{
|
||||
if (rel_y == 0)
|
||||
|
|
@ -454,8 +482,9 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
|
|||
else
|
||||
{
|
||||
int range = FullHeight(scrollpane) - scrollpane->h;
|
||||
int bar_max = scrollpane->h - 3;
|
||||
|
||||
scrollpane->y = ((rel_y - 1) * range) / (scrollpane->h - 3);
|
||||
scrollpane->y = ((rel_y - 1) * range + (bar_max / 2)) / bar_max;
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -465,7 +494,6 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
|
|||
{
|
||||
TXT_WidgetMousePress(scrollpane->child, x, y, b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void TXT_ScrollPaneLayout(TXT_UNCAST_ARG(scrollpane))
|
||||
|
|
|
|||
Loading…
Reference in a new issue