File diff r16430:b3f65f9bc976 → r16431:ec558deca9d7
src/widget.cpp
Show inline comments
 
@@ -49,13 +49,13 @@ static Point HandleScrollbarHittest(cons
 
	if (count != 0) top += height * pos / count;
 

	
 
	if (cap > count) cap = count;
 
	if (count != 0) bottom -= (count - pos - cap) * height / count;
 

	
 
	Point pt;
 
	if (horizontal && _dynlang.text_dir == TD_RTL) {
 
	if (horizontal && _current_text_dir == TD_RTL) {
 
		pt.x = rev_base - (bottom - 1);
 
		pt.y = rev_base - top;
 
	} else {
 
		pt.x = top;
 
		pt.y = bottom - 1;
 
	}
 
@@ -75,13 +75,13 @@ static void ScrollbarClickPositioning(Wi
 
{
 
	int pos;
 
	bool rtl = false;
 

	
 
	if (sb->type == NWID_HSCROLLBAR) {
 
		pos = x;
 
		rtl = _dynlang.text_dir == TD_RTL;
 
		rtl = _current_text_dir == TD_RTL;
 
	} else {
 
		pos = y;
 
	}
 
	if (pos <= mi + 9) {
 
		/* Pressing the upper button? */
 
		SetBit(sb->disp_flags, NDB_SCROLLBAR_UP);
 
@@ -384,13 +384,13 @@ static inline void DrawFrame(const Rect 
 

	
 
	/* If the frame has text, adjust the top bar to fit half-way through */
 
	int dy1 = 4;
 
	if (str != STR_NULL) dy1 = FONT_HEIGHT_NORMAL / 2 - 1;
 
	int dy2 = dy1 + 1;
 

	
 
	if (_dynlang.text_dir == TD_LTR) {
 
	if (_current_text_dir == TD_LTR) {
 
		/* Line from upper left corner to start of text */
 
		GfxFillRect(r.left, r.top + dy1, r.left + 4, r.top + dy1, c1);
 
		GfxFillRect(r.left + 1, r.top + dy2, r.left + 4, r.top + dy2, c2);
 

	
 
		/* Line from end of text to upper right corner */
 
		GfxFillRect(x2, r.top + dy1, r.right - 1, r.top + dy1, c1);
 
@@ -511,13 +511,13 @@ void DrawCaption(const Rect &r, Colours 
 
 * @param str              Text of the button.
 
 *
 
 * @note Magic constants are also used in #NWidgetLeaf::ButtonHit.
 
 */
 
static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, StringID str)
 
{
 
	if (_dynlang.text_dir == TD_LTR) {
 
	if (_current_text_dir == TD_LTR) {
 
		DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
		DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 
		DrawString(r.right - (clicked_dropdown ? 10 : 11), r.right, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
 
		if (str != STR_NULL) DrawString(r.left + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + WD_DROPDOWNTEXT_TOP + clicked_button, str, TC_BLACK);
 
	} else {
 
		DrawFrameRect(r.left + 12, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
@@ -561,13 +561,13 @@ void Window::DrawSortButtonState(int wid
 
	if (state == SBS_OFF) return;
 

	
 
	assert(this->nested_array != NULL);
 
	const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 

	
 
	int offset = this->IsWidgetLowered(widget) ? 1 : 0;
 
	int base = offset + nwid->pos_x + (_dynlang.text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0);
 
	int base = offset + nwid->pos_x + (_current_text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0);
 
	int top = nwid->pos_y;
 

	
 
	DrawString(base, base + WD_SORTBUTTON_ARROW_WIDTH, top + 1 + offset, state == SBS_DOWN ? DOWNARROW : UPARROW, TC_BLACK, SA_HOR_CENTER);
 
}
 

	
 

	
 
@@ -2011,14 +2011,14 @@ void NWidgetLeaf::Draw(const Window *w)
 
			break;
 

	
 
		case WWT_ARROWBTN:
 
		case WWT_PUSHARROWBTN: {
 
			SpriteID sprite;
 
			switch (this->widget_data) {
 
				case AWV_DECREASE: sprite = _dynlang.text_dir != TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_INCREASE: sprite = _dynlang.text_dir == TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_DECREASE: sprite = _current_text_dir != TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_INCREASE: sprite = _current_text_dir == TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_LEFT:     sprite = SPR_ARROW_LEFT;  break;
 
				case AWV_RIGHT:    sprite = SPR_ARROW_RIGHT; break;
 
				default: NOT_REACHED();
 
			}
 
			DrawImageButtons(r, WWT_PUSHIMGBTN, this->colour, clicked, sprite);
 
		}
 
@@ -2095,13 +2095,13 @@ void NWidgetLeaf::Draw(const Window *w)
 
 * @return The point refers to the button.
 
 *
 
 * @note The magic constants are also used at #DrawButtonDropdown.
 
 */
 
bool NWidgetLeaf::ButtonHit(const Point &pt)
 
{
 
	if (_dynlang.text_dir == TD_LTR) {
 
	if (_current_text_dir == TD_LTR) {
 
		int button_width = this->pos_x + this->current_x - 12;
 
		return pt.x < button_width;
 
	} else {
 
		int button_left = this->pos_x + 12;
 
		return pt.x >= button_left;
 
	}