mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add more scroll examples
This commit is contained in:
@@ -98,7 +98,7 @@ end
|
||||
function M.get_size(self)
|
||||
return vmath.vector3(
|
||||
self.border.z - self.border.x,
|
||||
self.border.w - self.border.y,
|
||||
self.border.y - self.border.w,
|
||||
0)
|
||||
end
|
||||
|
||||
|
@@ -27,6 +27,25 @@ local function get_border(node)
|
||||
end
|
||||
|
||||
|
||||
local function update_border(self)
|
||||
local input_border = get_border(self.input_zone)
|
||||
local content_border = get_border(self.node)
|
||||
|
||||
-- border.x - min content.x node pos
|
||||
-- border.y - min content.y node pos
|
||||
-- border.z - max content.x node pos
|
||||
-- border.w - max content.y node pos
|
||||
self.border = vmath.vector4(
|
||||
input_border.x - content_border.x,
|
||||
-input_border.w + content_border.w,
|
||||
input_border.z - content_border.z,
|
||||
-input_border.y + content_border.y
|
||||
)
|
||||
self.can_x = (self.border.x ~= self.border.z)
|
||||
self.can_y = (self.border.y ~= self.border.w)
|
||||
end
|
||||
|
||||
|
||||
function M.init(self, scroll_parent, input_zone, border)
|
||||
self.style = self:get_style()
|
||||
self.node = self:get_node(scroll_parent)
|
||||
@@ -53,14 +72,7 @@ function M.init(self, scroll_parent, input_zone, border)
|
||||
side = false,
|
||||
}
|
||||
|
||||
local input_border = get_border(self.input_zone)
|
||||
local content_border = get_border(self.node)
|
||||
self:set_border(vmath.vector4(
|
||||
input_border.x - content_border.x,
|
||||
-input_border.w + content_border.w,
|
||||
input_border.z - content_border.z,
|
||||
-input_border.y + content_border.y
|
||||
))
|
||||
update_border(self)
|
||||
|
||||
self.on_scroll = Event()
|
||||
self.on_scroll_to = Event()
|
||||
@@ -432,14 +444,9 @@ end
|
||||
-- @function scroll:set_border
|
||||
-- @tparam table self Component instance
|
||||
-- @tparam vmath.vector3 border Size of scrolling area
|
||||
function M.set_border(self, border)
|
||||
-- border.x - min content.x node pos
|
||||
-- border.y - min content.y node pos
|
||||
-- border.z - max content.x node pos
|
||||
-- border.w - max content.y node pos
|
||||
self.border = border
|
||||
self.can_x = (border.x ~= border.z)
|
||||
self.can_y = (border.y ~= border.w)
|
||||
function M.set_border(self, content_size)
|
||||
gui.set_size(self.node, content_size)
|
||||
update_border(self)
|
||||
end
|
||||
|
||||
|
||||
|
@@ -48,6 +48,9 @@ end
|
||||
|
||||
--- Setup scale x, but can only be smaller, than start text scale
|
||||
local function update_text_area_size(self)
|
||||
gui.set_scale(self.node, self.start_scale)
|
||||
gui.set_size(self.node, self.start_size)
|
||||
|
||||
local max_width = self.text_area.x
|
||||
local max_height = self.text_area.y
|
||||
|
||||
|
@@ -20,8 +20,6 @@ local settings = require("druid.system.settings")
|
||||
|
||||
local M = {}
|
||||
|
||||
local log = settings.log
|
||||
|
||||
|
||||
--- Register external druid component.
|
||||
-- After register you can create the component with
|
||||
@@ -37,7 +35,7 @@ function M.register(name, module)
|
||||
return druid_instance.create(self, module, ...)
|
||||
end
|
||||
|
||||
log("Register component", name)
|
||||
-- print("Register component", name)
|
||||
end
|
||||
|
||||
|
||||
|
@@ -43,8 +43,7 @@ local Druid = class("druid.druid_instance")
|
||||
|
||||
|
||||
local function input_init(self)
|
||||
-- TODO: To custom settings
|
||||
if not settings.auto_focus_gain then
|
||||
if not sys.get_config("druid.auto_focus") == "1" then
|
||||
return
|
||||
end
|
||||
|
||||
|
@@ -4,10 +4,7 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
M.is_debug = false
|
||||
M.default_style = nil
|
||||
M.auto_focus_gain = true
|
||||
|
||||
|
||||
function M.get_text(name)
|
||||
return "[Druid]: locales not inited"
|
||||
@@ -18,11 +15,4 @@ function M.play_sound(name)
|
||||
end
|
||||
|
||||
|
||||
function M.log(...)
|
||||
if M.is_debug then
|
||||
print("[Druid]: ", ...)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user