Rename locale -> lang_text

This commit is contained in:
Insality 2020-02-22 15:24:52 +03:00
parent 2c0b100ab7
commit 640753c080
7 changed files with 46 additions and 43 deletions

View File

@ -2,9 +2,9 @@ Simple to-do for Druid Alpha 0.2.0
-- High -- High
- remove button event and match_event from druid + remove button event and match_event from druid
- add hover component + add hover component
- 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 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
@ -22,6 +22,7 @@ Simple to-do for Druid Alpha 0.2.0
- separate custom data and predefined fields in components? - separate custom data and predefined fields in components?
- unify component api (get/set/to and other general stuff) - unify component api (get/set/to and other general stuff)
- compare with gooey - compare with gooey
- button and hover click restriction zone?
-- Low -- Low
@ -31,3 +32,4 @@ Simple to-do for Druid Alpha 0.2.0
- 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 - Druid store assest - separate repository with rich components
- ability to control buttons via controller. Select it by cursor (d-pad)

View File

@ -16,6 +16,26 @@ local function on_button_hover(self, hover_state)
self.style.on_hover(self, self.anim_node, hover_state) self.style.on_hover(self, self.anim_node, hover_state)
end end
local function on_button_release(self)
if not self.disabled then
if not self.stub and self.can_action then
self.can_action = false
if self.style.on_click then
self.style.on_click(self, self.anim_node)
end
self.callback(self:get_context(), self.params, self)
end
return true
else
if self.style.on_click_disabled then
self.style.on_click_disabled(self, self.anim_node)
end
return false
end
end
--- Component init function --- Component init function
-- @function button:init -- @function button:init
-- @tparam table self Component instance -- @tparam table self Component instance
@ -44,25 +64,6 @@ function M.init(self, node, callback, params, anim_node, event)
end end
local function on_button_release(self)
if not self.disabled then
if not self.stub and self.can_action then
self.can_action = false
if self.style.on_click then
self.style.on_click(self, self.anim_node)
end
self.callback(self:get_context(), self.params, self)
end
return true
else
if self.style.on_click_disabled then
self.style.on_click_disabled(self, self.anim_node)
end
return false
end
end
function M.on_input(self, action_id, action) function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then if action_id ~= const.ACTION_TOUCH then
return false return false

View File

@ -1,12 +1,12 @@
--- Component to handle all GUI texts --- Component to handle all GUI texts
-- Good working with localization system -- Good working with localization system
-- @module druid.locale -- @module druid.lang_text
local const = require("druid.const") local const = require("druid.const")
local settings = require("druid.system.settings") local settings = require("druid.system.settings")
local component = require("druid.component") local component = require("druid.component")
local M = component.create("locale", { const.ON_CHANGE_LANGUAGE }) local M = component.create("lang_text", { const.ON_CHANGE_LANGUAGE })
function M.init(self, node, lang_id, no_adjust) function M.init(self, node, lang_id, no_adjust)

View File

@ -6,7 +6,7 @@
-- @see druid.back_handler -- @see druid.back_handler
-- @see druid.input -- @see druid.input
-- @see druid.text -- @see druid.text
-- @see druid.locale -- @see druid.lang_text
-- @see druid.timer -- @see druid.timer
-- @see druid.progress -- @see druid.progress
-- @see druid.grid -- @see druid.grid
@ -26,7 +26,7 @@ local blocker = require("druid.base.blocker")
local back_handler = require("druid.base.back_handler") local back_handler = require("druid.base.back_handler")
local hover = require("druid.base.hover") local hover = require("druid.base.hover")
local text = require("druid.base.text") local text = require("druid.base.text")
local locale = require("druid.base.locale") local lang_text = require("druid.base.lang_text")
local timer = require("druid.base.timer") local timer = require("druid.base.timer")
local progress = require("druid.base.progress") local progress = require("druid.base.progress")
local grid = require("druid.base.grid") local grid = require("druid.base.grid")
@ -269,12 +269,12 @@ function Druid.new_text(self, ...)
end end
--- Create locale basic component --- Create lang_text basic component
-- @function druid:new_locale -- @function druid:new_lang_text
-- @tparam args ... locale init args -- @tparam args ... lang_text init args
-- @treturn Component locale component -- @treturn Component lang_text component
function Druid.new_locale(self, ...) function Druid.new_lang_text(self, ...)
return Druid.create(self, locale, ...) return Druid.create(self, lang_text, ...)
end end

View File

@ -29,7 +29,7 @@ end
local function init_top_panel(self) local function init_top_panel(self)
self.druid:new_button("button_left/button", on_control_button, -1) self.druid:new_button("button_left/button", on_control_button, -1)
self.druid:new_button("button_right/button", on_control_button, 1) self.druid:new_button("button_right/button", on_control_button, 1)
self.header = self.druid:new_locale("text_header", "main_page") self.header = self.druid:new_lang_text("text_header", "main_page")
end end

View File

@ -26,16 +26,16 @@ end
local function setup_texts(self) local function setup_texts(self)
self.druid:new_locale("text_button", "ui_section_button") self.druid:new_lang_text("text_button", "ui_section_button")
self.druid:new_locale("text_text", "ui_section_text") self.druid:new_lang_text("text_text", "ui_section_text")
self.druid:new_locale("text_timer", "ui_section_timer") self.druid:new_lang_text("text_timer", "ui_section_timer")
self.druid:new_locale("text_progress", "ui_section_progress") self.druid:new_lang_text("text_progress", "ui_section_progress")
self.druid:new_locale("text_slider", "ui_section_slider") self.druid:new_lang_text("text_slider", "ui_section_slider")
self.druid:new_locale("text_radio", "ui_section_radio") self.druid:new_lang_text("text_radio", "ui_section_radio")
self.druid:new_locale("text_checkbox", "ui_section_checkbox") self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
self.druid:new_locale("text_translated", "ui_text_example") self.druid:new_lang_text("text_translated", "ui_text_example")
self.druid:new_locale("text_button_lang", "ui_text_change_lang") self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
self.druid:new_text("text_simple", "Simple") self.druid:new_text("text_simple", "Simple")
end end

View File

@ -19,7 +19,7 @@ local function setup_texts(self)
self.druid:new_text("text_multiline", "Simple multiline text with smth") self.druid:new_text("text_multiline", "Simple multiline text with smth")
local anchoring = self.druid:new_text("text_anchoring", "Anchoring") local anchoring = self.druid:new_text("text_anchoring", "Anchoring")
self.druid:new_text("text_no_adjust", "Without adjust size", true) self.druid:new_text("text_no_adjust", "Without adjust size", true)
self.druid:new_locale("text_locale", "ui_text_example") self.druid:new_lang_text("text_locale", "ui_text_example")
local big_text = "Check max size" local big_text = "Check max size"
local width = self.druid:new_text("text_max_width", big_text) local width = self.druid:new_text("text_max_width", big_text)