Put the whole look into one project theme
themes/main_theme.tres is the project theme. It holds Godot's default look for every control type the game uses, plus named styles for the game's own look (popups, the background, spacers, list rows, title and text sizes, highlights) and a palette for the popup dimming. Scenes and scripts name these styles instead of setting colours, sizes or style boxes, and the five old theme files are gone. themes/README.md explains the styles and how to make a new theme. The screenshot tour now uses the real character pictures, so the layout baseline is taken again. Screenshots are pixel-identical to before, and test_theme.gd checks that the look stays in the theme.
This commit was merged in pull request #36.
This commit is contained in:
1 parent
a7bf38c5f9
commit
8b71723a34
39 files changed
+3283
-1869
No files matched your search
+8
-33
@@ -2,58 +2,33 @@ class_name ListRow
|
||||
extends PanelContainer
|
||||
## One item in a list of names, such as the inspiration list or a sync result column.
|
||||
##
|
||||
## Every row has its own background, alternating between two shades, so it is clear
|
||||
## where an item starts even when its text wraps over several lines.
|
||||
|
||||
const EVEN_BACKGROUND: Color = Color(1, 1, 1, 0.05)
|
||||
const ODD_BACKGROUND: Color = Color(1, 1, 1, 0.11)
|
||||
|
||||
static var _even_style: StyleBoxFlat
|
||||
static var _odd_style: StyleBoxFlat
|
||||
## Every row has its own background, alternating between the theme's [code]ListRowEven[/code]
|
||||
## and [code]ListRowOdd[/code] styles, so it is clear where an item starts even when its
|
||||
## text wraps over several lines.
|
||||
|
||||
## The label showing the item's text.
|
||||
var label: Label
|
||||
|
||||
## The item's text.
|
||||
var text: String:
|
||||
|
||||
|
||||
get:
|
||||
return label.text
|
||||
|
||||
|
||||
## Creates the row for item number [param row] (counting from 0) in a list.
|
||||
## Creates the row for item number [param row] (counting from 0) in a list. The text uses
|
||||
## the theme's [param label_style], e.g. [code]TextLarge[/code].
|
||||
static func create(
|
||||
item_text: String,
|
||||
row: int,
|
||||
font_size: int,
|
||||
label_style: StringName,
|
||||
alignment: HorizontalAlignment = HORIZONTAL_ALIGNMENT_LEFT,
|
||||
) -> ListRow:
|
||||
var list_row: ListRow = ListRow.new()
|
||||
list_row.add_theme_stylebox_override("panel", _style(row % 2 != 0))
|
||||
list_row.theme_type_variation = &"ListRowOdd" if row % 2 != 0 else &"ListRowEven"
|
||||
list_row.label = Label.new()
|
||||
list_row.label.add_theme_font_size_override("font_size", font_size)
|
||||
list_row.label.theme_type_variation = label_style
|
||||
list_row.label.text = item_text
|
||||
list_row.label.horizontal_alignment = alignment
|
||||
list_row.label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
list_row.add_child(list_row.label)
|
||||
return list_row
|
||||
|
||||
|
||||
# Rows share two styles instead of each creating its own
|
||||
static func _style(odd: bool) -> StyleBoxFlat:
|
||||
if _even_style == null:
|
||||
_even_style = _make_style(EVEN_BACKGROUND)
|
||||
_odd_style = _make_style(ODD_BACKGROUND)
|
||||
return _odd_style if odd else _even_style
|
||||
|
||||
|
||||
static func _make_style(background: Color) -> StyleBoxFlat:
|
||||
var style: StyleBoxFlat = StyleBoxFlat.new()
|
||||
style.bg_color = background
|
||||
style.set_corner_radius_all(4)
|
||||
style.content_margin_left = 8
|
||||
style.content_margin_right = 8
|
||||
style.content_margin_top = 2
|
||||
style.content_margin_bottom = 2
|
||||
return style
|
||||
Reference in new issue
Block a user