aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeData.cpp
blob: e05ca7f9881c1ac6c65045dd90ac6651e21c5d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#include "common/util.h"
#include "common/system.h"

#include "graphics/surface.h"
#include "graphics/colormasks.h"
#include "graphics/imageman.h"
#include "graphics/cursorman.h"
#include "graphics/VectorRenderer.h"

#include "gui/ThemeEngine.h"
#include "gui/ThemeData.h"

namespace GUI {

/**********************************************************
 *	Data definitions for theme engine elements
 *********************************************************/
const ThemeEngine::DrawDataInfo ThemeEngine::kDrawDataDefaults[] = {
	{kDDMainDialogBackground,		"mainmenu_bg",		true,	kDDNone},
	{kDDSpecialColorBackground,		"special_bg",		true,	kDDNone},
	{kDDPlainColorBackground,		"plain_bg",			true,	kDDNone},
	{kDDDefaultBackground,			"default_bg",		true,	kDDNone},
	{kDDTextSelectionBackground,	"text_selection",	false,	kDDNone},

	{kDDWidgetBackgroundDefault,	"widget_default",	true,	kDDNone},
	{kDDWidgetBackgroundSmall,		"widget_small",		true,	kDDNone},
	{kDDWidgetBackgroundEditText,	"widget_textedit",	true,	kDDNone},
	{kDDWidgetBackgroundSlider,		"widget_slider",	true,	kDDNone},

	{kDDButtonIdle,					"button_idle",		true,	kDDWidgetBackgroundSlider},
	{kDDButtonHover,				"button_hover",	false,	kDDButtonIdle},
	{kDDButtonDisabled,				"button_disabled",	true,	kDDNone},

	{kDDSliderFull,					"slider_full",		false,	kDDNone},
	{kDDSliderHover,				"slider_hover",		false,	kDDNone},
	{kDDSliderDisabled,				"slider_disabled",	true,	kDDNone},

	{kDDCheckboxDefault,			"checkbox_default",			true,	kDDNone},
	{kDDCheckboxDisabled,			"checkbox_disabled",		true,	kDDNone},
	{kDDCheckboxSelected,			"checkbox_selected",		false,	kDDCheckboxDefault},

	{kDDTabActive,					"tab_active",				false,	kDDTabInactive},
	{kDDTabInactive,				"tab_inactive",				true,	kDDNone},
	{kDDTabBackground,				"tab_background",			true,	kDDNone},

	{kDDScrollbarBase,				"scrollbar_base",			true,	kDDNone},

	{kDDScrollbarButtonIdle,		"scrollbar_button_idle",	true,	kDDNone},
	{kDDScrollbarButtonHover,		"scrollbar_button_hover",	false,	kDDScrollbarButtonIdle},

	{kDDScrollbarHandleIdle,		"scrollbar_handle_idle",	false,	kDDNone},
	{kDDScrollbarHandleHover,		"scrollbar_handle_hover",	false,	kDDScrollbarBase},

	{kDDPopUpIdle,					"popup_idle",	true,	kDDNone},
	{kDDPopUpHover,					"popup_hover",	false,	kDDPopUpIdle},
	{kDDPopUpDisabled,				"popup_disabled",	true,	kDDNone},

	{kDDCaret,						"caret",		false,	kDDNone},
	{kDDSeparator,					"separator",	true,	kDDNone},
};

const ThemeEngine::TextDataInfo ThemeEngine::kTextDataDefaults[] = {
	{kTextDataDefault,		"text_default"},
	{kTextDataHover,		"text_hover"},
	{kTextDataDisabled,		"text_disabled"},
	{kTextDataInverted,		"text_inverted"},
	{kTextDataButton,		"text_button"},
	{kTextDataButtonHover,	"text_button_hover"},
	{kTextDataNormalFont,	"text_normal"}
};


/**********************************************************
 *	ThemeItem functions for drawing queues.
 *********************************************************/
void ThemeItemDrawData::drawSelf(bool draw, bool restore) {

	Common::Rect extendedRect = _area;
	extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset);

	if (restore)
		_engine->restoreBackground(extendedRect);

	if (draw) {
		Common::List<Graphics::DrawStep>::const_iterator step;
		for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step)
			_engine->renderer()->drawStep(_area, *step, _dynamicData);
	}

	_engine->addDirtyRect(extendedRect);
}

void ThemeItemTextData::drawSelf(bool draw, bool restore) {
	if (_restoreBg || restore)
		_engine->restoreBackground(_area);

	if (draw) {
		_engine->renderer()->setFgColor(_data->_color.r, _data->_color.g, _data->_color.b);
		_engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis);
	}

	_engine->addDirtyRect(_area);
}

void ThemeItemBitmap::drawSelf(bool draw, bool restore) {
	if (restore)
		_engine->restoreBackground(_area);

	if (draw) {
		if (_alpha)
			_engine->renderer()->blitAlphaBitmap(_bitmap, _area);
		else
			_engine->renderer()->blitSubSurface(_bitmap, _area);
	}

	_engine->addDirtyRect(_area);
}

}