This commit is contained in:
Insality 2024-11-22 02:22:21 +02:00
parent af44d0d26e
commit 28bd165cee
6 changed files with 44 additions and 8 deletions

View File

@ -54,7 +54,7 @@ nodes {
}
type: TYPE_TEXT
text: "Placeholder"
font: "text_bold"
font: "druid_text_bold"
id: "placeholder_text"
outline {
x: 0.4
@ -87,7 +87,7 @@ nodes {
}
type: TYPE_TEXT
text: "User input"
font: "text_bold"
font: "druid_text_bold"
id: "input_text"
shadow {
x: 1.0
@ -145,7 +145,7 @@ nodes {
}
type: TYPE_TEXT
text: "|"
font: "text_bold"
font: "druid_text_bold"
id: "cursor_text"
shadow {
x: 1.0

View File

@ -519,4 +519,21 @@ function M.remove_with_shift(array, index, shift_policy)
end
---Get full position of node in the GUI tree
---@param node node GUI node
---@param root node|nil GUI root node to stop search
function M.get_full_position(node, root)
local position = gui.get_position(node)
local parent = gui.get_parent(node)
while parent and parent ~= root do
local parent_position = gui.get_position(parent)
position.x = position.x + parent_position.x
position.y = position.y + parent_position.y
parent = gui.get_parent(parent)
end
return position
end
return M

View File

@ -1,3 +1,4 @@
local helper = require("druid.helper")
local mini_graph = require("druid.widget.mini_graph.mini_graph")
---@class widget.fps_panel: druid.widget
@ -22,7 +23,13 @@ function M:init()
self.mini_graph:set_samples(self.graph_samples) -- show last 30 seconds
self.mini_graph:set_max_value(TARGET_FPS)
gui.set_parent(self:get_node("content"), self.mini_graph.content, true)
do -- Set parent manually
local parent_node = self.mini_graph.content
local position = helper.get_full_position(parent_node, self.mini_graph.root)
local content = self:get_node("content")
gui.set_parent(content, self.mini_graph.content)
gui.set_position(content, -position)
end
self.text_min_fps = self.druid:new_text("text_min_fps")
self.text_fps = self.druid:new_text("text_fps")

View File

@ -1,3 +1,4 @@
local helper = require("druid.helper")
local mini_graph = require("druid.widget.mini_graph.mini_graph")
---@class widget.memory_panel: druid.widget
@ -5,13 +6,24 @@ local mini_graph = require("druid.widget.mini_graph.mini_graph")
local M = {}
function M:init()
self.root = self:get_node("root")
self.delta_time = 0.1
self.samples_count = 30
self.memory_limit = 100
self.mini_graph = self.druid:new_widget(mini_graph, "mini_graph")
self.mini_graph:set_samples(self.samples_count)
gui.set_parent(self:get_node("content"), self.mini_graph.content, true)
-- This one is not works with scaled root
--gui.set_parent(self:get_node("content"), self.mini_graph.content, true)
do -- Set parent manually
local parent_node = self.mini_graph.content
local position = helper.get_full_position(parent_node, self.mini_graph.root)
local content = self:get_node("content")
gui.set_parent(content, self.mini_graph.content)
gui.set_position(content, -position)
end
self.max_value = self.druid:new_text("text_max_value")
self.text_per_second = self.druid:new_text("text_per_second")

View File

@ -37,7 +37,7 @@ nodes {
}
type: TYPE_TEXT
text: "Input"
font: "text_bold"
font: "druid_text_bold"
id: "text_name"
pivot: PIVOT_W
outline {

View File

@ -37,7 +37,7 @@ nodes {
}
type: TYPE_TEXT
text: "Text"
font: "text_bold"
font: "druid_text_bold"
id: "text_name"
pivot: PIVOT_W
outline {
@ -74,7 +74,7 @@ nodes {
}
type: TYPE_TEXT
text: "Text"
font: "text_bold"
font: "druid_text_bold"
id: "text_right"
pivot: PIVOT_E
outline {