Last Modified: 2023-07-09

Custom class

Put a lua file of your own class in commompinets/custom folder

Set your classname to a layer in App/bookX/pageX/index.lua

local sceneName = ...
--
local scene = require('controller.scene').new(sceneName, {
    name = "page1",
    components = {
      layers = {
            {  bg={ } },
            {  gotoBtn={ } },
            {  title={ class={"myClass"} } },
      },
      audios = {},
      groups = {},
      timers = {},
      variables = {},
      page = { }
    },
    commands = { },
    onInit = function(scene) print("onInit") end
})
--
return scene

myClass.lua will be called with a display image object of a layer associated with

  local yourLibrary = require("lib.yourLibrary")
  --
  --
  local M = {}

  --
  function M:init(UI)
  end
  --
  function M:create(UI)
    local obj = UI.sceneGroup[self.name]
  end
  --
  function M:didShow(UI)
  end
  --
  function M:didHide(UI)
  end
  --
  function M:destroy(UI)
  end

  M.set = function(instance)
    return setmetatable(instance, {__index=M})
  end
  --
  return M

properties can be defined in App/bookX/pageX/components/layers/layerX_myClass.lua

M.params={
  mytext = "hello my class",
}
...
...
return M

class as a name space

you can use a classname as name space

For instance, transition2.lua is a custom class and it has functions like “to”, “from”, “moveBy” etc.

you can speficy a function name as classoption with “.” in App/bookX/components/pageX/index.lua

 M.params ={
   {x = 260, delay = 400},
   {y = 260, xScale = -0.8, delay = 800},
   {xScale = -1, yScale = 1, delay = 400},
   {x = 60, xScale = -0.6, yScale = 0.6, delay = 1200},
   {rotation = 135, delay = 400},
   {x = 260, y = 60, alpha = 0, delay = 400},
   {rotation = 0, alpha = 1, delay = 800},
   {x = 60, delay = 400},
   {xScale = 0.8, yScale = 0.8, delay = 400}
 }

for imported class

use classOption with an opion value for instance “to” for trasition2 in M.props

local M={
  path = "bookTest.components.page2.layers.three.index",
  name = "three",
}
M.props = {
   five_transition2 = {classOption="to"},
}
return require("components.kwik.importer").new(M)

Generic Editor

ToDo

REST httpYac

### selectLayer with class if exists or not
GET /bookFree/page1/title/?class=transition2.to

###
POST /bookFree/page1/title/?class=transition2.to
Content-Type: application/lua

{
	{x = 260, delay = 400},
	{y = 260, xScale = -0.8, delay = 800},
	{xScale = -1, yScale = 1, delay = 400},
	{x = 60, xScale = -0.6, yScale = 0.6, delay = 1200},
	{rotation = 135, delay = 400},
	{x = 260, y = 60, alpha = 0, delay = 400},
	{rotation = 0, alpha = 1, delay = 800},
	{x = 60, delay = 400},
	{xScale = 0.8, yScale = 0.8, delay = 400}
}