mirror of https://github.com/OpenTTD/OpenTTD
(svn r20459) -Codechange: Remove the Scrollbar members of Window and make NWidgetScrollbar inherit from Scrollbar instead.
parent
55bd5de43d
commit
6e9c9c28d9
|
@ -75,7 +75,7 @@ static void ScrollbarClickPositioning(Window *w, NWidgetScrollbar *nw, int x, in
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
bool rtl = false;
|
bool rtl = false;
|
||||||
Scrollbar *sb = nw->GetScrollbar(w);
|
Scrollbar *sb = nw;
|
||||||
|
|
||||||
switch (nw->type) {
|
switch (nw->type) {
|
||||||
case WWT_SCROLLBAR:
|
case WWT_SCROLLBAR:
|
||||||
|
@ -1670,7 +1670,7 @@ void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding)
|
||||||
* @param colour Colour of the scrollbar.
|
* @param colour Colour of the scrollbar.
|
||||||
* @param index Index in the widget array used by the window system.
|
* @param index Index in the widget array used by the window system.
|
||||||
*/
|
*/
|
||||||
NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL)
|
NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL), Scrollbar(tp != WWT_HSCROLLBAR)
|
||||||
{
|
{
|
||||||
assert(tp == WWT_HSCROLLBAR || tp == WWT_SCROLLBAR || tp == WWT_SCROLL2BAR);
|
assert(tp == WWT_HSCROLLBAR || tp == WWT_SCROLLBAR || tp == WWT_SCROLL2BAR);
|
||||||
this->SetIndex(index);
|
this->SetIndex(index);
|
||||||
|
@ -1722,21 +1722,21 @@ void NWidgetScrollbar::Draw(const Window *w)
|
||||||
case WWT_HSCROLLBAR:
|
case WWT_HSCROLLBAR:
|
||||||
DrawHorizontalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL),
|
DrawHorizontalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL),
|
||||||
w->scrolling_scrollbar == this->index,
|
w->scrolling_scrollbar == this->index,
|
||||||
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL), this->GetScrollbar(w));
|
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL), this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WWT_SCROLLBAR:
|
case WWT_SCROLLBAR:
|
||||||
assert(this->widget_data == 0);
|
assert(this->widget_data == 0);
|
||||||
DrawVerticalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP,
|
DrawVerticalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP,
|
||||||
w->scrolling_scrollbar == this->index,
|
w->scrolling_scrollbar == this->index,
|
||||||
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN, this->GetScrollbar(w));
|
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN, this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WWT_SCROLL2BAR:
|
case WWT_SCROLL2BAR:
|
||||||
assert(this->widget_data == 0);
|
assert(this->widget_data == 0);
|
||||||
DrawVerticalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2),
|
DrawVerticalScrollbar(r, this->colour, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2),
|
||||||
w->scrolling_scrollbar == this->index,
|
w->scrolling_scrollbar == this->index,
|
||||||
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2), this->GetScrollbar(w));
|
(w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2), this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
@ -1747,26 +1747,6 @@ void NWidgetScrollbar::Draw(const Window *w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Scrollbar *NWidgetScrollbar::GetScrollbar(const Window *w) const
|
|
||||||
{
|
|
||||||
switch (this->type) {
|
|
||||||
case WWT_HSCROLLBAR: return &w->old_hscroll;
|
|
||||||
case WWT_SCROLLBAR: return &w->old_vscroll;
|
|
||||||
case WWT_SCROLL2BAR: return &w->old_vscroll2;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Scrollbar *NWidgetScrollbar::GetScrollbar(Window *w) const
|
|
||||||
{
|
|
||||||
switch (this->type) {
|
|
||||||
case WWT_HSCROLLBAR: return &w->old_hscroll;
|
|
||||||
case WWT_SCROLLBAR: return &w->old_vscroll;
|
|
||||||
case WWT_SCROLL2BAR: return &w->old_vscroll2;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Reset the cached dimensions. */
|
/** Reset the cached dimensions. */
|
||||||
/* static */ void NWidgetLeaf::InvalidateDimensionCache()
|
/* static */ void NWidgetLeaf::InvalidateDimensionCache()
|
||||||
{
|
{
|
||||||
|
|
|
@ -632,15 +632,12 @@ public:
|
||||||
* Also assign the scrollbar to other widgets using #SetScrollbar() to make the mousewheel work.
|
* Also assign the scrollbar to other widgets using #SetScrollbar() to make the mousewheel work.
|
||||||
* @ingroup NestedWidgets
|
* @ingroup NestedWidgets
|
||||||
*/
|
*/
|
||||||
class NWidgetScrollbar : public NWidgetCore {
|
class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
|
||||||
public:
|
public:
|
||||||
NWidgetScrollbar(WidgetType tp, Colours colour, int index);
|
NWidgetScrollbar(WidgetType tp, Colours colour, int index);
|
||||||
|
|
||||||
/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
|
/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
|
||||||
/* virtual */ void Draw(const Window *w);
|
/* virtual */ void Draw(const Window *w);
|
||||||
|
|
||||||
const Scrollbar *GetScrollbar(const Window *w) const;
|
|
||||||
Scrollbar *GetScrollbar(Window *w) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -104,7 +104,7 @@ int Window::GetRowFromWidget(int clickpos, int widget, int padding, int line_hei
|
||||||
*/
|
*/
|
||||||
const Scrollbar *Window::GetScrollbar(uint widnum) const
|
const Scrollbar *Window::GetScrollbar(uint widnum) const
|
||||||
{
|
{
|
||||||
return this->GetWidget<NWidgetScrollbar>(widnum)->GetScrollbar(this);
|
return this->GetWidget<NWidgetScrollbar>(widnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ const Scrollbar *Window::GetScrollbar(uint widnum) const
|
||||||
*/
|
*/
|
||||||
Scrollbar *Window::GetScrollbar(uint widnum)
|
Scrollbar *Window::GetScrollbar(uint widnum)
|
||||||
{
|
{
|
||||||
return this->GetWidget<NWidgetScrollbar>(widnum)->GetScrollbar(this);
|
return this->GetWidget<NWidgetScrollbar>(widnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1304,7 +1304,7 @@ void Window::InitNested(const WindowDesc *desc, WindowNumber window_number)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Empty constructor, initialization has been moved to #InitNested() called from the constructor of the derived class. */
|
/** Empty constructor, initialization has been moved to #InitNested() called from the constructor of the derived class. */
|
||||||
Window::Window() : old_hscroll(false), old_vscroll(true), old_vscroll2(true), scrolling_scrollbar(-1)
|
Window::Window() : scrolling_scrollbar(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,9 +256,6 @@ public:
|
||||||
int width; ///< width of the window (number of pixels to the right in x direction)
|
int width; ///< width of the window (number of pixels to the right in x direction)
|
||||||
int height; ///< Height of the window (number of pixels down in y direction)
|
int height; ///< Height of the window (number of pixels down in y direction)
|
||||||
|
|
||||||
Scrollbar old_hscroll; ///< Horizontal scroll bar
|
|
||||||
Scrollbar old_vscroll; ///< First vertical scroll bar
|
|
||||||
Scrollbar old_vscroll2; ///< Second vertical scroll bar
|
|
||||||
ResizeInfo resize; ///< Resize information
|
ResizeInfo resize; ///< Resize information
|
||||||
|
|
||||||
Owner owner; ///< The owner of the content shown in this window. Company colour is acquired from this variable.
|
Owner owner; ///< The owner of the content shown in this window. Company colour is acquired from this variable.
|
||||||
|
|
Loading…
Reference in New Issue