[Scummvm-cvs-logs] CVS: scummvm/gui ScrollBarWidget.h,1.9,1.10 ScrollBarWidget.cpp,1.21,1.22 ListWidget.cpp,1.48,1.49 ListWidget.h,1.29,1.30 console.cpp,1.60,1.61

Max Horn fingolfin at users.sourceforge.net
Sun May 15 11:02:38 CEST 2005


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32595

Modified Files:
	ScrollBarWidget.h ScrollBarWidget.cpp ListWidget.cpp 
	ListWidget.h console.cpp 
Log Message:
Draw scrollbar arrows using drawLine, instead of hard coding bitmaps; add a param to the ListWidget constructor to choose a 'big' variant

Index: ScrollBarWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ScrollBarWidget.h	17 Apr 2005 11:47:44 -0000	1.9
+++ ScrollBarWidget.h	15 May 2005 18:02:10 -0000	1.10
@@ -26,7 +26,8 @@
 namespace GUI {
 
 enum {
-	kDefaultScrollBarWidth		= 9
+	kNormalScrollBarWidth	= 9,
+	kBigScrollBarWidth		= 15
 };
 
 

Index: ScrollBarWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ScrollBarWidget.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- ScrollBarWidget.cpp	17 Apr 2005 11:47:44 -0000	1.21
+++ ScrollBarWidget.cpp	15 May 2005 18:02:10 -0000	1.22
@@ -28,30 +28,6 @@
 
 #define UP_DOWN_BOX_HEIGHT	(_w+1)
 
-// Up arrow
-static uint32 up_arrow[8] = {
-	0x00000000,
-	0x00000000,
-	0x00001000,
-	0x00001000,
-	0x00011100,
-	0x00011100,
-	0x00110110,
-	0x00100010,
-};
-
-// Down arrow
-static uint32 down_arrow[8] = {
-	0x00000000,
-	0x00000000,
-	0x00100010,
-	0x00110110,
-	0x00011100,
-	0x00011100,
-	0x00001000,
-	0x00001000,
-};
-
 ScrollBarWidget::ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h)
 	: Widget (boss, x, y, w, h), CommandSender(boss) {
 	_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG | WIDGET_WANT_TICKLE;
@@ -205,33 +181,59 @@
 
 void ScrollBarWidget::drawWidget(bool hilite) {
 	NewGui *gui = &g_gui;
-	int bottomY = _y + _h;
+	int bottomY = _y + _h - UP_DOWN_BOX_HEIGHT;
 	bool isSinglePage = (_numEntries <= _entriesPerPage);
+	OverlayColor color;
+	Graphics::Surface &surf = g_gui.getScreen();
+	const int B = (_w + 1) / 4;
+	Common::Point p0, p1, p2;
 
 	gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
 
 	if (_draggingPart != kNoPart)
 		_part = _draggingPart;
 
+	//
 	// Up arrow
+	//
+	color = isSinglePage ? gui->_color :
+					(hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor;
 	gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
-	gui->drawBitmap(up_arrow, _x + 1 + (_w - 8) / 2, _y + (_w - 8) / 2,
-					isSinglePage ? gui->_color :
-					(hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor);
+	p0 = Common::Point(_x + _w / 2, _y + B);
+	p1 = Common::Point(_x + B, _y + _w - B);
+	p2 = Common::Point(_x + _w - B - 1, _y + _w - B);
+	// Evil HACK to draw filled triangle
+//	for (; p1.x <= p2.x; ++p1.x)
+//		surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+	surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+	surf.drawLine(p0.x, p0.y, p2.x, p2.y, color);
+//	surf.drawLine(p1.x, p1.y, p2.x, p2.y, color);
 
+	//
 	// Down arrow
-	gui->frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
-	gui->drawBitmap(down_arrow, _x + 1 + (_w - 8) / 2, bottomY - UP_DOWN_BOX_HEIGHT + (_w - 8) / 2,
-					isSinglePage ? gui->_color :
-					(hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor);
+	//
+	color = isSinglePage ? gui->_color :
+					(hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor;
+	gui->frameRect(_x, bottomY, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
+	p0 = Common::Point(_x + _w / 2, bottomY + _w - B);
+	p1 = Common::Point(_x + B, bottomY + B);
+	p2 = Common::Point(_x + _w - B - 1, bottomY + B);
+	// Evil HACK to draw filled triangle
+//	for (; p1.x <= p2.x; ++p1.x)
+//		surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+	surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+	surf.drawLine(p0.x, p0.y, p2.x, p2.y, color);
+//	surf.drawLine(p1.x, p1.y, p2.x, p2.y, color);
 
+	//
 	// Slider
+	//
 	if (!isSinglePage) {
 		gui->fillRect(_x, _y + _sliderPos, _w, _sliderHeight,
 					(hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
 		gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
 		int y = _y + _sliderPos + _sliderHeight / 2;
-		OverlayColor color = (hilite && _part == kSliderPart) ? gui->_color : gui->_shadowcolor;
+		color = (hilite && _part == kSliderPart) ? gui->_color : gui->_shadowcolor;
 		gui->hLine(_x + 2, y - 2, _x + _w - 3, color);
 		gui->hLine(_x + 2, y, _x + _w - 3, color);
 		gui->hLine(_x + 2, y + 2, _x + _w-3, color);

Index: ListWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- ListWidget.cpp	8 May 2005 21:49:41 -0000	1.48
+++ ListWidget.cpp	15 May 2005 18:02:10 -0000	1.49
@@ -27,16 +27,21 @@
 
 namespace GUI {
 
-ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
-	: EditableWidget(boss, x, y, w - kDefaultScrollBarWidth, h), CommandSender(boss) {
+ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws)
+	: EditableWidget(boss, x, y, w, h), CommandSender(boss) {
+	
+	// TODO: When in kBigWidgetSize mode, use another font
+	_w = w - (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth);
+	_lineHeight = kLineHeight;
+	
 	_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
 	_type = kListWidget;
 	_editMode = false;
 	_numberingMode = kListNumberingOne;
-	_entriesPerPage = (_h - 2) / kLineHeight;
+	_entriesPerPage = (_h - 2) / _lineHeight;
 	_currentPos = 0;
 	_selectedItem = -1;
-	_scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kDefaultScrollBarWidth, _h);
+	_scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h);
 	_scrollBar->setTarget(this);
 	_currentKeyDown = 0;
 	
@@ -144,7 +149,7 @@
 
 
 int ListWidget::findItem(int x, int y) const {
-	return (y - 1) / kLineHeight + _currentPos;
+	return (y - 1) / _lineHeight + _currentPos;
 }
 
 static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) {
@@ -301,14 +306,14 @@
 	// Draw the list items
 	for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
 		const OverlayColor textColor = (_selectedItem == pos && _hasFocus) ? gui->_bgcolor : gui->_textcolor;
-		const int y = _y + 2 + kLineHeight * i;
+		const int y = _y + 2 + _lineHeight * i;
 
 		// Draw the selected item inverted, on a highlighted background.
 		if (_selectedItem == pos) {
 			if (_hasFocus)
-				gui->fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi);
+				gui->fillRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi);
 			else
-				gui->frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi);
+				gui->frameRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi);
 		}
 
 		// If in numbering mode, we first print a number prefix
@@ -339,8 +344,8 @@
 }
 
 Common::Rect ListWidget::getEditRect() const {
-	Common::Rect r(2, 1, _w - 2 , kLineHeight);
-	const int offset = (_selectedItem - _currentPos) * kLineHeight;
+	Common::Rect r(2, 1, _w - 2 , _lineHeight);
+	const int offset = (_selectedItem - _currentPos) * _lineHeight;
 	r.top += offset;
 	r.bottom += offset;
 

Index: ListWidget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- ListWidget.h	6 Apr 2005 15:21:23 -0000	1.29
+++ ListWidget.h	15 May 2005 18:02:10 -0000	1.30
@@ -56,12 +56,13 @@
 	int				_selectedItem;
 	ScrollBarWidget	*_scrollBar;
 	int				_currentKeyDown;
+	int				_lineHeight;
 	
 	String			_quickSelectStr;
 	uint32			_quickSelectTime;
 
 public:
-	ListWidget(GuiObject *boss, int x, int y, int w, int h);
+	ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kDefaultWidgetSize);
 	virtual ~ListWidget();
 	
 	void setList(const StringList& list);

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- console.cpp	17 Apr 2005 12:03:02 -0000	1.60
+++ console.cpp	15 May 2005 18:02:10 -0000	1.61
@@ -57,15 +57,20 @@
 	: Dialog(0, 0, 1, 1),
 	_widthPercent(widthPercent), _heightPercent(heightPercent) {
 
+	const int screenW = g_system->getOverlayWidth();
+	const int screenH = g_system->getOverlayHeight();
+
 	// Calculate the real width/height (rounded to char/line multiples)
-	_w = (uint16)(_widthPercent * g_system->getOverlayWidth());
-	_h = (uint16)((_heightPercent * g_system->getOverlayHeight() - 2) / kConsoleLineHeight);
+	_w = (uint16)(_widthPercent * screenW);
+	_h = (uint16)((_heightPercent * screenH - 2) / kConsoleLineHeight);
 	_h = _h * kConsoleLineHeight + 2;
 
 	// Add scrollbar
-	int scrollBarWidth = kDefaultScrollBarWidth;
-	if (g_system->getOverlayWidth() >= 640)
-		scrollBarWidth = 14;
+	int scrollBarWidth;
+	if (screenW >= 400 && screenH >= 300)
+		scrollBarWidth = kBigScrollBarWidth;
+	else
+		scrollBarWidth = kNormalScrollBarWidth;
 	_scrollBar = new ScrollBarWidget(this, _w - scrollBarWidth - 1, 0, scrollBarWidth, _h);
 	_scrollBar->setTarget(this);
 





More information about the Scummvm-git-logs mailing list