diff options
| author | Alexander Tkachev | 2016-07-01 14:25:05 +0600 | 
|---|---|---|
| committer | Eugene Sandulenko | 2016-07-03 12:24:46 +0200 | 
| commit | 3d636617d0781bdd477551a87f6b9fc60e0a4a1f (patch) | |
| tree | f3a5ff0951093c5c7c329e08683f64f58f340148 /gui | |
| parent | dc9b32e62086151c0bac011e6bc4a5d94d8907a3 (diff) | |
| download | scummvm-rg350-3d636617d0781bdd477551a87f6b9fc60e0a4a1f.tar.gz scummvm-rg350-3d636617d0781bdd477551a87f6b9fc60e0a4a1f.tar.bz2 scummvm-rg350-3d636617d0781bdd477551a87f6b9fc60e0a4a1f.zip  | |
GUI: Use clipping everywhere
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/ThemeEngine.cpp | 94 | ||||
| -rw-r--r-- | gui/ThemeEngine.h | 13 | ||||
| -rw-r--r-- | gui/widget.cpp | 14 | ||||
| -rw-r--r-- | gui/widgets/editable.cpp | 2 | ||||
| -rw-r--r-- | gui/widgets/edittext.cpp | 4 | ||||
| -rw-r--r-- | gui/widgets/list.cpp | 8 | ||||
| -rw-r--r-- | gui/widgets/scrollcontainer.cpp | 2 | 
7 files changed, 117 insertions, 20 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 6174d41ddd..b1decb1b74 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1067,6 +1067,13 @@ void ThemeEngine::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state  	queueDD(kDDSeparator, r);  } +void ThemeEngine::drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingRect, WidgetStateInfo state) { +	if (!ready()) +		return; + +	queueDDClip(kDDSeparator, r, clippingRect); +} +  void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {  	if (!ready())  		return; @@ -1093,6 +1100,32 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str,  	queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);  } +void ThemeEngine::drawCheckboxClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &str, bool checked, WidgetStateInfo state) { +	if (!ready()) +		return; + +	Common::Rect r2 = r; +	DrawData dd = kDDCheckboxDefault; + +	if (checked) +		dd = kDDCheckboxSelected; + +	if (state == kStateDisabled) +		dd = kDDCheckboxDisabled; + +	const int checkBoxSize = MIN((int)r.height(), getFontHeight()); + +	r2.bottom = r2.top + checkBoxSize; +	r2.right = r2.left + checkBoxSize; + +	queueDDClip(dd, r2, clip); + +	r2.left = r2.right + checkBoxSize; +	r2.right = r.right; + +	queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clip, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV); +} +  void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {  	if (!ready())  		return; @@ -1119,6 +1152,32 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s  	queueDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);  } +void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, bool checked, WidgetStateInfo state) { +	if (!ready()) +		return; + +	Common::Rect r2 = r; +	DrawData dd = kDDRadiobuttonDefault; + +	if (checked) +		dd = kDDRadiobuttonSelected; + +	if (state == kStateDisabled) +		dd = kDDRadiobuttonDisabled; + +	const int checkBoxSize = MIN((int)r.height(), getFontHeight()); + +	r2.bottom = r2.top + checkBoxSize; +	r2.right = r2.left + checkBoxSize; + +	queueDDClip(dd, r2, clippingRect); + +	r2.left = r2.right + checkBoxSize; +	r2.right = r.right; + +	queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV); +} +  void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {  	if (!ready())  		return; @@ -1139,6 +1198,26 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s  	queueDD(dd, r2);  } +void ThemeEngine::drawSliderClip(const Common::Rect &r, const Common::Rect &clip, int width, WidgetStateInfo state) { +	if (!ready()) +		return; + +	DrawData dd = kDDSliderFull; + +	if (state == kStateHighlight) +		dd = kDDSliderHover; +	else if (state == kStateDisabled) +		dd = kDDSliderDisabled; + +	Common::Rect r2 = r; +	r2.setWidth(MIN((int16)width, r.width())); +	//	r2.top++; r2.bottom--; r2.left++; r2.right--; + +	drawWidgetBackgroundClip(r, clip, 0, kWidgetBackgroundSlider, kStateEnabled); + +	queueDDClip(dd, r2, clip); +} +  void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {  	if (!ready())  		return; @@ -1582,6 +1661,21 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font  	addDirtyRect(charArea);  } +void ThemeEngine::drawCharClip(const Common::Rect &r, const Common::Rect &clip, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) { +	if (!ready()) +		return; + +	Common::Rect charArea = r; +	charArea.clip(_screen.w, _screen.h); +	if (!clip.isEmpty()) charArea.clip(clip); + +	uint32 rgbColor = _overlayFormat.RGBToColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b); + +	restoreBackground(charArea); +	font->drawChar(&_screen, ch, charArea.left, charArea.top, rgbColor); +	addDirtyRect(charArea); +} +  void ThemeEngine::debugWidgetPosition(const char *name, const Common::Rect &r) {  	_font->drawString(&_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true);  	_screen.hLine(r.left, r.top, r.right, 0xFFFF); diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index b8ceeda39b..3c259b4f9d 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -340,30 +340,33 @@ public:  	void drawWidgetBackground(const Common::Rect &r, uint16 hints,  	                          WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled); -  	void drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clippingArea, uint16 hints,  								WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);  	void drawButton(const Common::Rect &r, const Common::String &str,  	                WidgetStateInfo state = kStateEnabled, uint16 hints = 0); -  	void drawButtonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str,  		WidgetStateInfo state = kStateEnabled, uint16 hints = 0);  	void drawSurface(const Common::Rect &r, const Graphics::Surface &surface,  	                 WidgetStateInfo state = kStateEnabled, int alpha = 255, bool themeTrans = false); -  	void drawSurfaceClip(const Common::Rect &r, const Common::Rect &clippingRect, const Graphics::Surface &surface,  		WidgetStateInfo state = kStateEnabled, int alpha = 255, bool themeTrans = false);  	void drawSlider(const Common::Rect &r, int width,  	                WidgetStateInfo state = kStateEnabled); +	void drawSliderClip(const Common::Rect &r, const Common::Rect &clippingRect, int width, +					WidgetStateInfo state = kStateEnabled);  	void drawCheckbox(const Common::Rect &r, const Common::String &str,  	                  bool checked, WidgetStateInfo state = kStateEnabled); +	void drawCheckboxClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, +					  bool checked, WidgetStateInfo state = kStateEnabled);  	void drawRadiobutton(const Common::Rect &r, const Common::String &str,  	                     bool checked, WidgetStateInfo state = kStateEnabled); +	void drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, +						 bool checked, WidgetStateInfo state = kStateEnabled);  	void drawTab(const Common::Rect &r, int tabHeight, int tabWidth,  	             const Common::Array<Common::String> &tabs, int active, uint16 hints, @@ -384,20 +387,20 @@ public:  	void drawCaret(const Common::Rect &r, bool erase,  	               WidgetStateInfo state = kStateEnabled); -  	void drawCaretClip(const Common::Rect &r, const Common::Rect &clip, bool erase,  		WidgetStateInfo state = kStateEnabled);  	void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled); +	void drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingArea, WidgetStateInfo state = kStateEnabled);  	void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state = kStateEnabled);  	void drawDialogBackgroundClip(const Common::Rect &r, const Common::Rect &clip, DialogBackground type, WidgetStateInfo state = kStateEnabled);  	void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignCenter, TextInversionState inverted = kTextInversionNone, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold, FontColor color = kFontColorNormal, bool restore = true, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0)); -  	void drawTextClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &str, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignCenter, TextInversionState inverted = kTextInversionNone, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold, FontColor color = kFontColorNormal, bool restore = true, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));  	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled, FontColor color = kFontColorNormal); +	void drawCharClip(const Common::Rect &r, const Common::Rect &clippingArea, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled, FontColor color = kFontColorNormal);  	//@} diff --git a/gui/widget.cpp b/gui/widget.cpp index 13be22f142..f2a888e31d 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -99,7 +99,7 @@ void Widget::draw() {  	// Draw border  	if (_flags & WIDGET_BORDER) { -		g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0, ThemeEngine::kWidgetBackgroundBorder); +		g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);  		_x += 4;  		_y += 4;  		_w -= 8; @@ -424,7 +424,7 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) {  }  void PicButtonWidget::drawWidget() { -	g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); +	g_gui.theme()->drawButtonClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), "", _state, getFlags());  	if (_gfx.getPixels()) {  		// Check whether the set up surface needs to be converted to the GUI @@ -437,7 +437,7 @@ void PicButtonWidget::drawWidget() {  		const int x = _x + (_w - _gfx.w) / 2;  		const int y = _y + (_h - _gfx.h) / 2; -		g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w,  y + _gfx.h), _gfx, _state, _alpha, _transparency); +		g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + _gfx.w,  y + _gfx.h), getBossClipRect(), _gfx, _state, _alpha, _transparency);		  	}  } @@ -472,7 +472,7 @@ void CheckboxWidget::setState(bool state) {  }  void CheckboxWidget::drawWidget() { -	g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, Widget::_state); +	g_gui.theme()->drawCheckboxClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _label, _state, Widget::_state);  }  #pragma mark - @@ -541,7 +541,7 @@ void RadiobuttonWidget::setState(bool state, bool setGroup) {  }  void RadiobuttonWidget::drawWidget() { -	g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, Widget::_state); +	g_gui.theme()->drawRadiobuttonClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _label, _state, Widget::_state);  }  #pragma mark - @@ -609,7 +609,7 @@ void SliderWidget::handleMouseWheel(int x, int y, int direction) {  }  void SliderWidget::drawWidget() { -	g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x + _w, _y + _h), valueToBarWidth(_value), _state); +	g_gui.theme()->drawSliderClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), valueToBarWidth(_value), _state);  }  int SliderWidget::valueToBarWidth(int value) { @@ -723,7 +723,7 @@ void ContainerWidget::removeWidget(Widget *widget) {  }  void ContainerWidget::drawWidget() { -	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, ThemeEngine::kWidgetBackgroundBorder); +	g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);  }  } // End of namespace GUI diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp index 83b6a7b84e..4f7e584c14 100644 --- a/gui/widgets/editable.cpp +++ b/gui/widgets/editable.cpp @@ -303,7 +303,7 @@ void EditableWidget::drawCaret(bool erase) {  		// possible glitches due to different methods used.  		width = MIN(editRect.width() - caretOffset, width);  		if (width > 0) { -			g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea); +			g_gui.theme()->drawTextClip(Common::Rect(x, y, x + width, y + editRect.height()), getBossClipRect(), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);  		}  	} diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index bef90d4382..0a8725ac9e 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -97,7 +97,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {  }  void EditTextWidget::drawWidget() { -	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0, ThemeEngine::kWidgetBackgroundEditText); +	g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundEditText);  	// Draw the text  	adjustOffset(); @@ -105,7 +105,7 @@ void EditTextWidget::drawWidget() {  	const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);  	setTextDrawableArea(r); -	g_gui.theme()->drawText(Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea); +	g_gui.theme()->drawTextClip(Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h), getBossClipRect(), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);  }  Common::Rect EditTextWidget::getEditRect() const { diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index 4b69202fdc..f6e5c67510 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -488,7 +488,7 @@ void ListWidget::drawWidget() {  	Common::String buffer;  	// Draw a thin frame around the list. -	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, ThemeEngine::kWidgetBackgroundBorder); +	g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);  	const int scrollbarW = (_scrollBar && _scrollBar->isVisible()) ? _scrollBarWidth : 0;  	// Draw the list items @@ -507,7 +507,7 @@ void ListWidget::drawWidget() {  		// If in numbering mode, we first print a number prefix  		if (_numberingMode != kListNumberingOff) {  			buffer = Common::String::format("%2d. ", (pos + _numberingMode)); -			g_gui.theme()->drawText(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), +			g_gui.theme()->drawTextClip(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), getBossClipRect(),  									buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);  			pad = 0;  		} @@ -528,12 +528,12 @@ void ListWidget::drawWidget() {  			color = _editColor;  			adjustOffset();  			width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW; -			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state, +			g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), getBossClipRect(), buffer, _state,  									Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);  		} else {  			buffer = _list[pos];  			width = _w - r.left - scrollbarW; -			g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state, +			g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), getBossClipRect(), buffer, _state,  									Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);  		} diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp index eca0279c55..8b68b0fc0b 100644 --- a/gui/widgets/scrollcontainer.cpp +++ b/gui/widgets/scrollcontainer.cpp @@ -135,7 +135,7 @@ void ScrollContainerWidget::reflowLayout() {  }  void ScrollContainerWidget::drawWidget() { -	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), ThemeEngine::kDialogBackgroundDefault); +	g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), getBossClipRect(), ThemeEngine::kDialogBackgroundDefault);  }  Widget *ScrollContainerWidget::findWidget(int x, int y) {  | 
