summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_gui.cpp22
-rw-r--r--src/news_gui.cpp12
-rw-r--r--src/order_gui.cpp16
3 files changed, 25 insertions, 25 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 045dbbc4e..bad88e7ce 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -156,8 +156,8 @@ struct NewGRFAddWindow : public Window {
/* Count the number of GRFs */
for (c = _all_grfs; c != NULL; c = c->next) n++;
- this->vscroll.cap = (wl->bottom - wl->top) / 10;
- SetVScrollCount(this, n);
+ this->vscroll.SetCapacity((wl->bottom - wl->top) / 10);
+ this->vscroll.SetCount(n);
this->SetWidgetDisabledState(ANGRFW_ADD, this->sel == NULL || this->sel->IsOpenTTDBaseGRF());
this->DrawWidgets();
@@ -165,8 +165,8 @@ struct NewGRFAddWindow : public Window {
GfxFillRect(wl->left + 1, wl->top + 1, wl->right, wl->bottom, 0xD7);
uint y = wl->top + 1;
- for (c = _all_grfs, n = 0; c != NULL && n < (this->vscroll.pos + this->vscroll.cap); c = c->next, n++) {
- if (n >= this->vscroll.pos) {
+ for (c = _all_grfs, n = 0; c != NULL && n < (this->vscroll.GetPosition() + this->vscroll.GetCapacity()); c = c->next, n++) {
+ if (n >= this->vscroll.GetPosition()) {
bool h = c == this->sel;
const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
@@ -194,7 +194,7 @@ struct NewGRFAddWindow : public Window {
case ANGRFW_GRF_LIST: {
/* Get row... */
const GRFConfig *c;
- uint i = (pt.y - this->widget[ANGRFW_GRF_LIST].top) / 10 + this->vscroll.pos;
+ uint i = (pt.y - this->widget[ANGRFW_GRF_LIST].top) / 10 + this->vscroll.GetPosition();
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--) {}
this->sel = c;
@@ -376,8 +376,8 @@ struct NewGRFWindow : public Window {
for (c = this->list, i = 0; c != NULL; c = c->next, i++) {}
- this->vscroll.cap = (this->widget[SNGRFS_FILE_LIST].bottom - this->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
- SetVScrollCount(this, i);
+ this->vscroll.SetCapacity((this->widget[SNGRFS_FILE_LIST].bottom - this->widget[SNGRFS_FILE_LIST].top) / 14 + 1);
+ this->vscroll.SetCount(i);
this->SetWidgetsDisabledState(!this->editable,
SNGRFS_PRESET_LIST,
@@ -437,7 +437,7 @@ struct NewGRFWindow : public Window {
int y = this->widget[SNGRFS_FILE_LIST].top;
int i = 0;
for (const GRFConfig *c = this->list; c != NULL; c = c->next, i++) {
- if (i >= this->vscroll.pos && i < this->vscroll.pos + this->vscroll.cap) {
+ if (this->vscroll.IsVisible(i)) {
const char *text = (c->name != NULL && !StrEmpty(c->name)) ? c->name : c->filename;
SpriteID pal;
byte txtoffset;
@@ -579,7 +579,7 @@ struct NewGRFWindow : public Window {
case SNGRFS_FILE_LIST: { // Select a GRF
GRFConfig *c;
- uint i = (pt.y - this->widget[SNGRFS_FILE_LIST].top) / 14 + this->vscroll.pos;
+ uint i = (pt.y - this->widget[SNGRFS_FILE_LIST].top) / 14 + this->vscroll.GetPosition();
for (c = this->list; c != NULL && i > 0; c = c->next, i--) {}
this->sel = c;
@@ -711,8 +711,8 @@ struct NewGRFWindow : public Window {
ResizeButtons(this, SNGRFS_SET_PARAMETERS, SNGRFS_APPLY_CHANGES);
}
- this->vscroll.cap += delta.y / 14;
- this->widget[SNGRFS_FILE_LIST].data = (this->vscroll.cap << MAT_ROW_START) + (1 << MAT_COL_START);
+ this->vscroll.UpdateCapacity(delta.y / 14);
+ this->widget[SNGRFS_FILE_LIST].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
this->SetupNewGRFWindow();
}
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 67e130f25..e0d72f947 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -822,7 +822,7 @@ struct MessageHistoryWindow : Window {
MessageHistoryWindow(const WindowDesc *desc) : Window()
{
this->InitNested(desc); // Initializes 'this->line_height' and 'this->date_width'.
- this->vscroll.cap = (this->nested_array[MHW_BACKGROUND]->current_y - this->top_spacing - this->bottom_spacing) / this->line_height;
+ this->vscroll.SetCapacity((this->nested_array[MHW_BACKGROUND]->current_y - this->top_spacing - this->bottom_spacing) / this->line_height);
this->OnInvalidateData(0);
}
@@ -852,7 +852,7 @@ struct MessageHistoryWindow : Window {
/* Find the first news item to display. */
NewsItem *ni = _latest_news;
- for (int n = this->vscroll.pos; n > 0; n--) {
+ for (int n = this->vscroll.GetPosition(); n > 0; n--) {
ni = ni->prev;
if (ni == NULL) return;
}
@@ -861,7 +861,7 @@ struct MessageHistoryWindow : Window {
int y = r.top + this->top_spacing;
const int date_left = r.left + WD_FRAMETEXT_LEFT; // Left edge of dates
const int news_left = date_left + this->date_width + 5; // Left edge of news items
- for (int n = this->vscroll.cap; n > 0; n--) {
+ for (int n = this->vscroll.GetCapacity(); n > 0; n--) {
SetDParam(0, ni->date);
DrawString(date_left, news_left, y, STR_SHORT_DATE);
@@ -875,7 +875,7 @@ struct MessageHistoryWindow : Window {
virtual void OnInvalidateData(int data)
{
- SetVScrollCount(this, _total_news);
+ this->vscroll.SetCount(_total_news);
}
virtual void OnClick(Point pt, int widget)
@@ -884,7 +884,7 @@ struct MessageHistoryWindow : Window {
NewsItem *ni = _latest_news;
if (ni == NULL) return;
- for (int n = (pt.y - this->nested_array[MHW_BACKGROUND]->pos_y - WD_FRAMERECT_TOP) / this->line_height + this->vscroll.pos; n > 0; n--) {
+ for (int n = (pt.y - this->nested_array[MHW_BACKGROUND]->pos_y - WD_FRAMERECT_TOP) / this->line_height + this->vscroll.GetPosition(); n > 0; n--) {
ni = ni->prev;
if (ni == NULL) return;
}
@@ -895,7 +895,7 @@ struct MessageHistoryWindow : Window {
virtual void OnResize(Point delta)
{
- this->vscroll.cap += delta.y / this->line_height;
+ this->vscroll.UpdateCapacity(delta.y / this->line_height);
this->OnInvalidateData(0);
}
};
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index f298aecd8..fb7498f2f 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -423,9 +423,9 @@ private:
{
int sel = (y - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / ORDER_LIST_LINE_HEIGHT; // Selected line in the ORDER_WIDGET_ORDER_LIST panel.
- if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER;
+ if ((uint)sel >= this->vscroll.GetCapacity()) return INVALID_ORDER;
- sel += this->vscroll.pos;
+ sel += this->vscroll.GetPosition();
return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_ORDER;
}
@@ -639,7 +639,7 @@ public:
assert(this->widget[ORDER_WIDGET_ORDER_LIST].top + 1 + num_lines * ORDER_LIST_LINE_HEIGHT == this->widget[ORDER_WIDGET_ORDER_LIST].bottom);
this->owner = v->owner;
- this->vscroll.cap = num_lines;
+ this->vscroll.SetCapacity(num_lines);
this->resize.step_height = ORDER_LIST_LINE_HEIGHT;
this->selected_order = -1;
this->vehicle = v;
@@ -717,7 +717,7 @@ public:
{
bool shared_orders = this->vehicle->IsOrderListShared();
- SetVScrollCount(this, this->vehicle->GetNumOrders() + 1);
+ this->vscroll.SetCount(this->vehicle->GetNumOrders() + 1);
int sel = OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel);
@@ -829,12 +829,12 @@ public:
int y = 15;
- int i = this->vscroll.pos;
+ int i = this->vscroll.GetPosition();
order = this->vehicle->GetOrder(i);
StringID str;
while (order != NULL) {
/* Don't draw anything if it extends past the end of the window. */
- if (i - this->vscroll.pos >= this->vscroll.cap) break;
+ if (!this->vscroll.IsVisible(i)) break;
DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, this->widget[ORDER_WIDGET_ORDER_LIST].right - 4);
y += ORDER_LIST_LINE_HEIGHT;
@@ -843,7 +843,7 @@ public:
order = order->next;
}
- if (i - this->vscroll.pos < this->vscroll.cap) {
+ if (this->vscroll.IsVisible(i)) {
str = shared_orders ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
DrawString(this->widget[ORDER_WIDGET_ORDER_LIST].left + 2, this->widget[ORDER_WIDGET_ORDER_LIST].right - 2, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
}
@@ -1167,7 +1167,7 @@ public:
virtual void OnResize(Point delta)
{
/* Update the scroll + matrix */
- this->vscroll.cap = (this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / ORDER_LIST_LINE_HEIGHT;
+ this->vscroll.UpdateCapacity((this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / ORDER_LIST_LINE_HEIGHT);
/* Update the button bars. */
if (this->vehicle->owner == _local_company) {