|
@@ -175,49 +175,49 @@ static void DispatchRightClickEvent(Wind
|
|
|
/** Dispatch the mousewheel-action to the window which will scroll any
|
|
|
* compatible scrollbars if the mouse is pointed over the bar or its contents
|
|
|
* @param *w Window
|
|
|
* @param widget the widget where the scrollwheel was used
|
|
|
* @param wheel scroll up or down
|
|
|
*/
|
|
|
static void DispatchMouseWheelEvent(Window *w, int widget, int wheel)
|
|
|
{
|
|
|
const Widget *wi1, *wi2;
|
|
|
Scrollbar *sb;
|
|
|
|
|
|
if (widget < 0) return;
|
|
|
|
|
|
wi1 = &w->widget[widget];
|
|
|
wi2 = &w->widget[widget + 1];
|
|
|
|
|
|
/* The listbox can only scroll if scrolling was done on the scrollbar itself,
|
|
|
* or on the listbox (and the next item is (must be) the scrollbar)
|
|
|
* XXX - should be rewritten as a widget-dependent scroller but that's
|
|
|
* not happening until someone rewrites the whole widget-code */
|
|
|
if ((sb = &w->vscroll, wi1->type == WWT_SCROLLBAR) || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR) ||
|
|
|
(sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) {
|
|
|
|
|
|
if (sb->count > sb->cap) {
|
|
|
int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap);
|
|
|
int pos = Clamp(sb->pos + wheel, 0, sb->count - sb->cap);
|
|
|
if (pos != sb->pos) {
|
|
|
sb->pos = pos;
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right, int bottom);
|
|
|
|
|
|
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
|
|
|
{
|
|
|
Window* const *wz;
|
|
|
DrawPixelInfo bk;
|
|
|
_cur_dpi = &bk;
|
|
|
|
|
|
FOR_ALL_WINDOWS(wz) {
|
|
|
const Window *w = *wz;
|
|
|
if (right > w->left &&
|
|
|
bottom > w->top &&
|
|
|
left < w->left + w->width &&
|
|
|
top < w->top + w->height) {
|
|
|
DrawOverlappedWindow(wz, left, top, right, bottom);
|
|
|
}
|
|
@@ -1274,50 +1274,50 @@ static bool HandleWindowDragging()
|
|
|
vsnap = delta;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (w->left + w->width >= v->left && w->left <= v->left + v->width) {
|
|
|
/* Your top border <-> other top border */
|
|
|
delta = abs(v->top - y);
|
|
|
if (delta <= vsnap) {
|
|
|
ny = v->top;
|
|
|
vsnap = delta;
|
|
|
}
|
|
|
|
|
|
/* Your bottom border <-> other bottom border */
|
|
|
delta = abs(v->top + v->height - y - w->height);
|
|
|
if (delta <= vsnap) {
|
|
|
ny = v->top + v->height - w->height;
|
|
|
vsnap = delta;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Make sure the window doesn't leave the screen
|
|
|
* 13 is the height of the title bar */
|
|
|
nx = clamp(nx, 13 - t->right, _screen.width - 13 - t->left);
|
|
|
ny = clamp(ny, 0, _screen.height - 13);
|
|
|
nx = Clamp(nx, 13 - t->right, _screen.width - 13 - t->left);
|
|
|
ny = Clamp(ny, 0, _screen.height - 13);
|
|
|
|
|
|
/* Make sure the title bar isn't hidden by behind the main tool bar */
|
|
|
v = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
|
|
if (v != NULL) {
|
|
|
int v_bottom = v->top + v->height;
|
|
|
int v_right = v->left + v->width;
|
|
|
if (ny + t->top >= v->top && ny + t->top < v_bottom) {
|
|
|
if ((v->left < 13 && nx + t->left < v->left) ||
|
|
|
(v_right > _screen.width - 13 && nx + t->right > v_right)) {
|
|
|
ny = v_bottom;
|
|
|
} else {
|
|
|
if (nx + t->left > v->left - 13 &&
|
|
|
nx + t->right < v_right + 13) {
|
|
|
if (w->top >= v_bottom) {
|
|
|
ny = v_bottom;
|
|
|
} else if (w->left < nx) {
|
|
|
nx = v->left - 13 - t->left;
|
|
|
} else {
|
|
|
nx = v_right + 13 - t->right;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2092,55 +2092,55 @@ void RelocateAllWindows(int neww, int ne
|
|
|
e.we.sizing.size.x = w->width;
|
|
|
e.we.sizing.size.y = w->height;
|
|
|
e.we.sizing.diff.x = neww - w->width;
|
|
|
e.we.sizing.diff.y = 0;
|
|
|
w->wndproc(w, &e);
|
|
|
}
|
|
|
|
|
|
top = w->top;
|
|
|
left = PositionMainToolbar(w); // changes toolbar orientation
|
|
|
break;
|
|
|
|
|
|
case WC_SELECT_GAME:
|
|
|
case WC_GAME_OPTIONS:
|
|
|
case WC_NETWORK_WINDOW:
|
|
|
top = (newh - w->height) >> 1;
|
|
|
left = (neww - w->width) >> 1;
|
|
|
break;
|
|
|
|
|
|
case WC_NEWS_WINDOW:
|
|
|
top = newh - w->height;
|
|
|
left = (neww - w->width) >> 1;
|
|
|
break;
|
|
|
|
|
|
case WC_STATUS_BAR:
|
|
|
ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0);
|
|
|
ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
|
|
|
top = newh - w->height;
|
|
|
left = (neww - w->width) >> 1;
|
|
|
break;
|
|
|
|
|
|
case WC_SEND_NETWORK_MSG:
|
|
|
ResizeWindow(w, clamp(neww, 320, 640) - w->width, 0);
|
|
|
ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
|
|
|
top = (newh - 26); // 26 = height of status bar + height of chat bar
|
|
|
left = (neww - w->width) >> 1;
|
|
|
break;
|
|
|
|
|
|
case WC_CONSOLE:
|
|
|
IConsoleResize(w);
|
|
|
continue;
|
|
|
|
|
|
default:
|
|
|
left = w->left;
|
|
|
if (left + (w->width >> 1) >= neww) left = neww - w->width;
|
|
|
top = w->top;
|
|
|
if (top + (w->height >> 1) >= newh) top = newh - w->height;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (w->viewport != NULL) {
|
|
|
w->viewport->left += left - w->left;
|
|
|
w->viewport->top += top - w->top;
|
|
|
}
|
|
|
|
|
|
w->left = left;
|
|
|
w->top = top;
|
|
|
}
|