|
| 1 | +--[[ |
| 2 | +Minetest |
| 3 | +Copyright (C) 2023 v-rob, Vincent Robinson <[email protected]> |
| 4 | +
|
| 5 | +This program is free software; you can redistribute it and/or modify |
| 6 | +it under the terms of the GNU Lesser General Public License as published by |
| 7 | +the Free Software Foundation; either version 2.1 of the License, or |
| 8 | +(at your option) any later version. |
| 9 | +
|
| 10 | +This program is distributed in the hope that it will be useful, |
| 11 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +GNU Lesser General Public License for more details. |
| 14 | +
|
| 15 | +You should have received a copy of the GNU Lesser General Public License along |
| 16 | +with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | +--]] |
| 19 | + |
| 20 | +local prelude_theme = ui.Style{ |
| 21 | + ui.Style{ |
| 22 | + sel = "root", |
| 23 | + |
| 24 | + -- The root window should be centered on the screen, but have no size |
| 25 | + -- by default, since the size should be user-set. |
| 26 | + rel_pos = {1/2, 1/2}, |
| 27 | + rel_anchor = {1/2, 1/2}, |
| 28 | + rel_size = {0, 0}, |
| 29 | + |
| 30 | + -- Normally, we don't show the backdrop unless we have user focus. |
| 31 | + ui.Style{ |
| 32 | + sel = "@backdrop", |
| 33 | + visible = false, |
| 34 | + }, |
| 35 | + ui.Style{ |
| 36 | + sel = "@backdrop$focused", |
| 37 | + visible = true, |
| 38 | + } |
| 39 | + }, |
| 40 | + ui.Style{ |
| 41 | + sel = "image", |
| 42 | + fg_scale = 0, |
| 43 | + }, |
| 44 | + ui.Style{ |
| 45 | + sel = "check, switch, radio", |
| 46 | + fg_halign = "left", |
| 47 | + }, |
| 48 | +} |
| 49 | + |
| 50 | +function ui.get_prelude_theme() |
| 51 | + return prelude_theme |
| 52 | +end |
| 53 | + |
| 54 | +local core_theme = ui.Style{ |
| 55 | + -- Like any good theme should, we include the prelude theme first. |
| 56 | + prelude_theme, |
| 57 | + |
| 58 | + ui.Style{ |
| 59 | + sel = "root", |
| 60 | + |
| 61 | + ui.Style{ |
| 62 | + sel = "!.ui:blank", |
| 63 | + |
| 64 | + padding = {4, 4, 4, 4}, |
| 65 | + |
| 66 | + bg_image = "ui_root_bg.png", |
| 67 | + bg_middle = {2/16, 2/16, 2/16, 2/16}, |
| 68 | + bg_middle_scale = 2, |
| 69 | + }, |
| 70 | + ui.Style{ |
| 71 | + sel = "@backdrop", |
| 72 | + |
| 73 | + bg_fill = "black#5", |
| 74 | + }, |
| 75 | + }, |
| 76 | + |
| 77 | + ui.Style{ |
| 78 | + sel = "button, toggle, option", |
| 79 | + |
| 80 | + padding = {2, 2, 2, 4}, |
| 81 | + |
| 82 | + bg_image = "ui_button_bg.png", |
| 83 | + bg_source = {0/6, 0, 1/6, 1}, |
| 84 | + bg_middle = {1/16, 2/16, 1/16, 2/16}, |
| 85 | + bg_middle_scale = 2, |
| 86 | + |
| 87 | + ui.Style{ |
| 88 | + sel = "$hovered, $focused", |
| 89 | + bg_source = {1/6, 0, 2/6, 1}, |
| 90 | + }, |
| 91 | + ui.Style{ |
| 92 | + sel = "$disabled", |
| 93 | + bg_source = {2/6, 0, 3/6, 1}, |
| 94 | + }, |
| 95 | + ui.Style{ |
| 96 | + sel = "$pressed, $selected", |
| 97 | + padding = {2, 4, 2, 2}, |
| 98 | + bg_source = {3/6, 0, 4/6, 1}, |
| 99 | + }, |
| 100 | + ui.Style{ |
| 101 | + sel = "($hovered, $focused)$selected", |
| 102 | + bg_source = {4/6, 0, 5/6, 1}, |
| 103 | + }, |
| 104 | + ui.Style{ |
| 105 | + sel = "$disabled$selected", |
| 106 | + bg_source = {5/6, 0, 6/6, 1}, |
| 107 | + }, |
| 108 | + |
| 109 | + ui.Style{ |
| 110 | + sel = ".ui:left", |
| 111 | + bg_image = "ui_button_left_bg.png", |
| 112 | + }, |
| 113 | + ui.Style{ |
| 114 | + sel = ".ui:center", |
| 115 | + bg_image = "ui_button_center_bg.png", |
| 116 | + }, |
| 117 | + ui.Style{ |
| 118 | + sel = ".ui:right", |
| 119 | + bg_image = "ui_button_right_bg.png", |
| 120 | + }, |
| 121 | + }, |
| 122 | + |
| 123 | + ui.Style{ |
| 124 | + sel = "check, switch, radio", |
| 125 | + |
| 126 | + fg_source = {0/4, 0, 1/4, 1}, |
| 127 | + fg_scale = 2, |
| 128 | + |
| 129 | + ui.Style{ |
| 130 | + sel = "check", |
| 131 | + fg_image = "ui_check_fg.png", |
| 132 | + }, |
| 133 | + ui.Style{ |
| 134 | + sel = "check$selected", |
| 135 | + fg_image = "ui_check_selected_fg.png", |
| 136 | + }, |
| 137 | + |
| 138 | + ui.Style{ |
| 139 | + sel = "switch", |
| 140 | + fg_image = "ui_switch_fg.png", |
| 141 | + }, |
| 142 | + ui.Style{ |
| 143 | + sel = "switch$selected", |
| 144 | + fg_image = "ui_switch_selected_fg.png", |
| 145 | + }, |
| 146 | + |
| 147 | + ui.Style{ |
| 148 | + sel = "radio", |
| 149 | + fg_image = "ui_radio_fg.png", |
| 150 | + }, |
| 151 | + ui.Style{ |
| 152 | + sel = "radio$selected", |
| 153 | + fg_image = "ui_radio_selected_fg.png", |
| 154 | + }, |
| 155 | + |
| 156 | + ui.Style{ |
| 157 | + sel = "$hovered, $focused", |
| 158 | + fg_source = {1/4, 0, 2/4, 1}, |
| 159 | + }, |
| 160 | + ui.Style{ |
| 161 | + sel = "$pressed", |
| 162 | + fg_source = {2/4, 0, 3/4, 1}, |
| 163 | + }, |
| 164 | + ui.Style{ |
| 165 | + sel = "$disabled", |
| 166 | + fg_source = {3/4, 0, 4/4, 1}, |
| 167 | + }, |
| 168 | + }, |
| 169 | +} |
| 170 | + |
| 171 | +function ui.get_core_theme() |
| 172 | + return core_theme |
| 173 | +end |
| 174 | + |
| 175 | +local default_theme = core_theme |
| 176 | + |
| 177 | +function ui.get_default_theme() |
| 178 | + return default_theme |
| 179 | +end |
| 180 | + |
| 181 | +function ui.set_default_theme(theme) |
| 182 | + default_theme = theme |
| 183 | +end |
0 commit comments