diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-11-30 14:19:32 -0500 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-11-30 15:25:20 -0500 |
commit | f91c4d2671012a52ac0ed988426fe8bbdb1216c9 (patch) | |
tree | 9575b2d49d3d1af3588f3fb02a656e9aaeba6fcc /plugins/plugin_manager/plugin_view.lua | |
parent | 75d099a62ed9d039994cea43972e9bea67c19474 (diff) | |
download | lite-xl-plugin-manager-f91c4d2671012a52ac0ed988426fe8bbdb1216c9.tar.gz lite-xl-plugin-manager-f91c4d2671012a52ac0ed988426fe8bbdb1216c9.zip |
Split off loading screen functionality.
Diffstat (limited to 'plugins/plugin_manager/plugin_view.lua')
-rw-r--r-- | plugins/plugin_manager/plugin_view.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua index 9e9d67c..b864675 100644 --- a/plugins/plugin_manager/plugin_view.lua +++ b/plugins/plugin_manager/plugin_view.lua @@ -145,20 +145,23 @@ local function draw_loading_bar(x, y, width, height, percent) renderer.draw_rect(x, y, width * percent, height, style.caret) end +function PluginView:draw_loading_screen(label, percent) + common.draw_text(style.big_font, style.dim, "Loading...", "center", self.position.x, self.position.y, self.size.x, self.size.y) + local width = self.size.x / 2 + local offset_y = self.size.y / 2 + if self.progress then + common.draw_text(style.font, style.dim, label, "center", self.position.x, self.position.y + offset_y + lh, self.size.x, lh) + draw_loading_bar(self.position.x + (self.size.x / 2) - (width / 2), self.position.y + self.size.y / 2 + (lh * 2), width, lh, percent) + end +end + function PluginView:draw() self:draw_background(style.background) local th = style.font:get_height() local lh = th + style.padding.y if not self.initialized or not self.widths then - common.draw_text(style.big_font, style.dim, "Loading...", "center", self.position.x, self.position.y, self.size.x, self.size.y) - local width = self.size.x / 2 - local offset_y = self.size.y / 2 - if self.progress then - common.draw_text(style.font, style.dim, self.progress.label, "center", self.position.x, self.position.y + offset_y + lh, self.size.x, lh) - draw_loading_bar(self.position.x + (self.size.x / 2) - (width / 2), self.position.y + self.size.y / 2 + (lh * 2), width, lh, self.progress.percent) - end - return + return self:draw_loading_screen(self.progress.label, self.progress.percent) end |