/
d.vision
/
division_engine_cpp
Обзор
Документация
Войти
/
d.vision
/
division_engine_cpp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
resources/scripts/views/decorated_box.lua
54 строки
2 KB
den163
Added texture loading
02 дек 2024, 12:55
02 дек 2024, 12:55
272b195
Код
Авторство
О чём код?
local border_radius = require 'border_radius' local colors = require 'color' local division = require 'division' local view = require 'views.view' local size = require 'constrained_size' ---@class decorated_box.options ---@field color vec4? ---@field border_radius border_radius? ---@field image_path string? ---@field block_input boolean? ---@class decorated_box: view, decorated_box.options ---@overload fun(options: decorated_box.options): decorated_box ---@diagnostic disable-next-line: assign-type-mismatch local decorated_box = view:inherit 'decorated_box' ---@class decorated_box.state: view.state ---@field id entity_id decorated_box.state = view.state:inherit 'decorated_box.state' ---@param self decorated_box ---@param box_options decorated_box.options ---@return decorated_box function decorated_box:__call(box_options) local instance = decorated_box:new(box_options) instance.color = box_options.color or colors.WHITE instance.border_radius = box_options.border_radius or border_radius.all(0) instance.block_input = box_options.block_input or false return instance end function decorated_box:create_state() return decorated_box.state:new { id = division:create_drawable_rect(self.block_input, self.image_path) } end function decorated_box.state:layout(constraints, view) return size.unconstrained() end ---@param render_rect rect ---@param view decorated_box function decorated_box.state:render(render_rect, view) division:set_drawable_rect(self.id, render_rect, view.color, view.border_radius) end function decorated_box.state:destroy() division:destroy_entity(self.id) end return decorated_box