mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
#111 Add druid.stencil_check for auto stencil check to call set_click_zone
This commit is contained in:
@@ -57,7 +57,11 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Button = component.create("button", { component.ON_INPUT, component.ON_MESSAGE_INPUT })
|
||||
local Button = component.create("button", {
|
||||
component.ON_INPUT,
|
||||
component.ON_MESSAGE_INPUT,
|
||||
component.ON_LATE_INIT
|
||||
})
|
||||
|
||||
|
||||
local function is_input_match(self, action_id)
|
||||
@@ -221,6 +225,16 @@ function Button.init(self, node, callback, params, anim_node)
|
||||
end
|
||||
|
||||
|
||||
function Button.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Button.on_input(self, action_id, action)
|
||||
if not is_input_match(self, action_id) then
|
||||
return false
|
||||
|
@@ -51,7 +51,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Drag = component.create("drag", { component.ON_INPUT }, const.PRIORITY_INPUT_HIGH)
|
||||
local Drag = component.create("drag", { component.ON_INPUT, component.ON_LATE_INIT }, const.PRIORITY_INPUT_HIGH)
|
||||
|
||||
|
||||
local function start_touch(self, touch)
|
||||
@@ -189,6 +189,16 @@ function Drag.init(self, node, on_drag_callback)
|
||||
end
|
||||
|
||||
|
||||
function Drag.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Drag.on_input_interrupt(self)
|
||||
if self.is_drag or self.is_touch then
|
||||
end_touch(self)
|
||||
|
@@ -18,7 +18,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Hover = component.create("hover", { component.ON_INPUT })
|
||||
local Hover = component.create("hover", { component.ON_INPUT, component.ON_LATE_INIT })
|
||||
|
||||
|
||||
--- Component init function
|
||||
@@ -38,6 +38,16 @@ function Hover.init(self, node, on_hover_callback)
|
||||
end
|
||||
|
||||
|
||||
function Hover.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Hover.on_input(self, action_id, action)
|
||||
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
|
||||
return false
|
||||
|
@@ -61,7 +61,12 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Scroll = component.create("scroll", { component.ON_INPUT, component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
|
||||
local Scroll = component.create("scroll", {
|
||||
component.ON_INPUT,
|
||||
component.ON_UPDATE,
|
||||
component.ON_LAYOUT_CHANGE,
|
||||
component.ON_LATE_INIT
|
||||
})
|
||||
|
||||
|
||||
local function inverse_lerp(min, max, current)
|
||||
@@ -172,6 +177,16 @@ function Scroll.init(self, view_node, content_node)
|
||||
end
|
||||
|
||||
|
||||
function Scroll.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Scroll.on_layout_change(self)
|
||||
gui.set_position(self.content_node, self.position)
|
||||
end
|
||||
|
@@ -23,7 +23,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Swipe = component.create("swipe", { component.ON_INPUT })
|
||||
local Swipe = component.create("swipe", { component.ON_INPUT, component.ON_LATE_INIT })
|
||||
|
||||
|
||||
local function start_swipe(self, action)
|
||||
@@ -99,6 +99,16 @@ function Swipe.init(self, node, on_swipe_callback)
|
||||
end
|
||||
|
||||
|
||||
function Swipe.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Swipe.on_input(self, action_id, action)
|
||||
if action_id ~= const.ACTION_TOUCH then
|
||||
return false
|
||||
|
Reference in New Issue
Block a user