mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Input priority little rework? Remove on_swipe
This commit is contained in:
parent
44016bc4f3
commit
c2b65eb4e2
@ -113,7 +113,7 @@ function M.update(self, dt)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Call only if exist interest: const.ON_INPUT or const.ON_SWIPE
|
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
|
||||||
function M.on_input(self, action_id, action)
|
function M.on_input(self, action_id, action)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -123,8 +123,8 @@ function M.on_message(self, message_id, message, sender)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Call only if swipe was started on another component (ex. scroll)
|
-- Call if input was interrupt by previous components (ex. scroll)
|
||||||
function M.on_swipe(self)
|
function M.on_input_interrupt(self)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ _TODO_
|
|||||||
- update
|
- update
|
||||||
- on_input
|
- on_input
|
||||||
- on_message
|
- on_message
|
||||||
- on_swipe
|
- on_input_interrupt
|
||||||
- setup_component
|
- setup_component
|
||||||
- get_style
|
- get_style
|
||||||
- set_style
|
- set_style
|
||||||
|
@ -7,29 +7,29 @@ Simple to-do for Druid Alpha 0.2.0
|
|||||||
+ add druid events/triggers? better callback system
|
+ add druid events/triggers? better callback system
|
||||||
+ better name for locale component? lang? lang_text?
|
+ better name for locale component? lang? lang_text?
|
||||||
+ better name for slider component? Slider is ok
|
+ better name for slider component? Slider is ok
|
||||||
|
+ Druid store assets - separate repository with rich components (progress_rich migrate)
|
||||||
- refactor on_swipe. To on_scroll? Add input priority
|
- refactor on_swipe. To on_scroll? Add input priority
|
||||||
- separate custom data and predefined fields in components?
|
- separate custom data and predefined fields in components?
|
||||||
- add init/remove stuff for every style in component. How to set custom sprites for button states?
|
- add init/remove stuff for every style in component. How to set custom sprites for button states?
|
||||||
|
- unify component api (get/set/to and other general stuff)
|
||||||
|
- add druid settings (add auto_focus input and other stuff)
|
||||||
- button add key trigger
|
- button add key trigger
|
||||||
- button polish, actions
|
- button polish, actions
|
||||||
- add druid settings (add auto_focus input and other stuff)
|
|
||||||
- better callbacks for every components
|
|
||||||
- better default style, add template for custom style
|
|
||||||
- add docs for all components
|
|
||||||
- add docs folder for every component with gifs? Solutions
|
|
||||||
- unify component api (get/set/to and other general stuff)
|
|
||||||
- add text component for alpha release
|
|
||||||
- compare with gooey
|
|
||||||
- button and hover click restriction zone?
|
- button and hover click restriction zone?
|
||||||
|
- better callbacks for every components
|
||||||
- better scroll size management, check different cases. So implicit now
|
- better scroll size management, check different cases. So implicit now
|
||||||
- better grid + scroll management
|
- better grid + scroll management
|
||||||
|
- better default style, add template for custom style
|
||||||
|
- add text component for alpha release
|
||||||
|
- compare with gooey
|
||||||
|
- add docs for all components
|
||||||
|
- add docs folder for every component with gifs? Solutions
|
||||||
|
|
||||||
|
|
||||||
-- Low
|
-- Low
|
||||||
- add code template and example for user components
|
- add code template and example for user components
|
||||||
- custom input settings (name of touch, text, etc)
|
- custom input settings (name of touch, text, etc)
|
||||||
- ability to relocalize all locale text nodes
|
|
||||||
- add good examples with template and/or nodes (basic component no use any of them)
|
- add good examples with template and/or nodes (basic component no use any of them)
|
||||||
- try use final druid in real project (FI uses custom druid) (use in 4321?)
|
- try use final druid in real project (FI uses custom druid) (use in 4321?)
|
||||||
- Druid store assest - separate repository with rich components
|
- ability to relocalize all locale text nodes
|
||||||
- ability to control buttons via controller. Select it by cursor (d-pad)
|
- ability to control buttons via controller. Select it by cursor (d-pad)
|
||||||
|
@ -5,7 +5,7 @@ local const = require("druid.const")
|
|||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("blocker", { const.ON_SWIPE })
|
local M = component.create("blocker", { const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
function M.init(self, node)
|
function M.init(self, node)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--- Component to handle basic GUI button
|
--- Component to handle basic GUI button
|
||||||
-- @module druid.button
|
-- @module druid.button
|
||||||
|
|
||||||
|
local Event = require("druid.event")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local helper = require("druid.helper")
|
local helper = require("druid.helper")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
@ -60,6 +61,12 @@ function M.init(self, node, callback, params, anim_node, event)
|
|||||||
self.hover_anim = self.style.IS_HOVER
|
self.hover_anim = self.style.IS_HOVER
|
||||||
self.hover = self.druid:new_hover(node, self, on_button_hover)
|
self.hover = self.druid:new_hover(node, self, on_button_hover)
|
||||||
|
|
||||||
|
-- Event stubs
|
||||||
|
self.on_click = Event()
|
||||||
|
self.on_hold_click = Event()
|
||||||
|
self.on_long_click = Event()
|
||||||
|
self.on_double_click = Event()
|
||||||
|
|
||||||
self.click_zone = nil
|
self.click_zone = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,7 +106,7 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_swipe(self)
|
function M.on_input_interrupt(self)
|
||||||
self.can_action = false
|
self.can_action = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.on_swipe(self)
|
function M.on_input_interrupt(self)
|
||||||
set_hover(self, false)
|
set_hover(self, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ local helper = require("druid.helper")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("scroll", { const.ON_UPDATE, const.ON_SWIPE })
|
local M = component.create("scroll", { const.ON_UPDATE, const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
-- Global on all scrolls
|
-- Global on all scrolls
|
||||||
|
@ -5,7 +5,7 @@ local helper = require("druid.helper")
|
|||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
local component = require("druid.component")
|
local component = require("druid.component")
|
||||||
|
|
||||||
local M = component.create("slider", { const.ON_SWIPE })
|
local M = component.create("slider", { const.ON_INPUT_HIGH })
|
||||||
|
|
||||||
|
|
||||||
local function on_change_value(self)
|
local function on_change_value(self)
|
||||||
|
@ -19,14 +19,13 @@ M.ZERO = "0"
|
|||||||
M.ALL = "all"
|
M.ALL = "all"
|
||||||
|
|
||||||
|
|
||||||
--- Interests
|
--- Component Interests
|
||||||
M.ON_MESSAGE = hash("on_message")
|
M.ON_MESSAGE = hash("on_message")
|
||||||
M.ON_UPDATE = hash("on_update")
|
M.ON_UPDATE = hash("on_update")
|
||||||
|
M.ON_INPUT_HIGH = hash("on_input_high")
|
||||||
|
|
||||||
-- Input
|
|
||||||
M.ON_SWIPE = hash("on_swipe")
|
|
||||||
M.ON_INPUT = hash("on_input")
|
M.ON_INPUT = hash("on_input")
|
||||||
|
M.ON_CHANGE_LANGUAGE = hash("on_change_language")
|
||||||
|
M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
|
||||||
|
|
||||||
|
|
||||||
M.PIVOTS = {
|
M.PIVOTS = {
|
||||||
@ -42,43 +41,21 @@ M.PIVOTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
M.SIDE = {
|
|
||||||
X = "x",
|
|
||||||
Y = "y"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
M.UI_INPUT = {
|
|
||||||
[M.ON_SWIPE] = true,
|
|
||||||
[M.ON_INPUT] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
-- UI messages
|
|
||||||
M.ON_CHANGE_LANGUAGE = hash("on_change_language")
|
|
||||||
M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
|
|
||||||
|
|
||||||
|
|
||||||
M.SPECIFIC_UI_MESSAGES = {
|
M.SPECIFIC_UI_MESSAGES = {
|
||||||
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
|
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
|
||||||
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
|
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Basic druid components
|
M.UI_INPUT = {
|
||||||
M.COMPONENTS = {
|
[M.ON_INPUT_HIGH] = true,
|
||||||
BUTTON = "button",
|
[M.ON_INPUT] = true
|
||||||
BLOCKER = "blocker",
|
}
|
||||||
BACK_HANDLER = "back_handler",
|
|
||||||
TEXT = "text",
|
|
||||||
LOCALE = "locale",
|
M.SIDE = {
|
||||||
TIMER = "timer",
|
X = "x",
|
||||||
PROGRESS = "progress",
|
Y = "y"
|
||||||
GRID = "grid",
|
|
||||||
SCROLL = "scroll",
|
|
||||||
SLIDER = "slider",
|
|
||||||
CHECKBOX = "checkbox",
|
|
||||||
CHECKBOX_GROUP = "checkbox_group",
|
|
||||||
RADIO_GROUP = "radio_group",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,16 +82,24 @@ local function create(self, instance_class)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function notify_input_on_swipe(self)
|
local function process_input(action_id, action, components, is_input_consumed)
|
||||||
if self.components[const.ON_INPUT] then
|
if not components then
|
||||||
local len = #self.components[const.ON_INPUT]
|
return is_input_consumed
|
||||||
for i = len, 1, -1 do
|
end
|
||||||
local comp = self.components[const.ON_INPUT][i]
|
|
||||||
if comp.on_swipe then
|
for i = #components, 1, -1 do
|
||||||
comp:on_swipe()
|
local component = components[i]
|
||||||
|
|
||||||
|
if not is_input_consumed then
|
||||||
|
is_input_consumed = component:on_input(action_id, action)
|
||||||
|
else
|
||||||
|
if component.on_input_interrupt then
|
||||||
|
component:on_input_interrupt()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return is_input_consumed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -169,33 +177,15 @@ end
|
|||||||
-- @tparam hash action_id Action_id from on_input
|
-- @tparam hash action_id Action_id from on_input
|
||||||
-- @tparam table action Action from on_input
|
-- @tparam table action Action from on_input
|
||||||
function Druid.on_input(self, action_id, action)
|
function Druid.on_input(self, action_id, action)
|
||||||
-- TODO: расписать отличия ON_SWIPE и ON_INPUT
|
local is_input_consumed = false
|
||||||
-- Почему-то некоторые используют ON_SWIPE, а логичнее ON_INPUT? (blocker, slider)
|
|
||||||
local components = self.components[const.ON_SWIPE]
|
|
||||||
if components then
|
|
||||||
local result
|
|
||||||
for i = #components, 1, -1 do
|
|
||||||
local v = components[i]
|
|
||||||
result = result or v:on_input(action_id, action)
|
|
||||||
end
|
|
||||||
if result then
|
|
||||||
notify_input_on_swipe(self)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
components = self.components[const.ON_INPUT]
|
is_input_consumed = process_input(action_id, action,
|
||||||
if components then
|
self.components[const.ON_INPUT_HIGH], is_input_consumed)
|
||||||
for i = #components, 1, -1 do
|
|
||||||
local v = components[i]
|
|
||||||
if v:on_input(action_id, action) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
is_input_consumed = process_input(action_id, action,
|
||||||
|
self.components[const.ON_INPUT], is_input_consumed)
|
||||||
|
|
||||||
|
return is_input_consumed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user