-------------------------------
--@ CreateDate: 2015.08.05
--@ Author: 王成成
--@ FileName: BaoShiTabXiangQianLayer.lua
--@ Brief: 宝石镶嵌
-------------------------------
local UIUtil = require("app.utils.UIUtil")
local curBaoShiTypeIndex = nil
local BaoShiTabXiangQianLayer = class("BaoShiTabXiangQianLayer", function()
return display.newLayer("BaoShiTabXiangQianLayer")
end)
function BaoShiTabXiangQianLayer:ctor()
local object, UITable = UIUtil:createLayerFromCSB("baoshi_xiangqian_layer", callBackProvider,true)
object:addTo(self)
self.scrollView = UITable["ScrollView"]
self.scrollViewBaoShiType = UITable["ScrollViewBaoShiType"]
self:loadData()
self:loadBaoshiTypeData()
end
-------------------------------------
------ 左边的 scrollview start -----
------ 左边的 scrollview start -----
-- 获取子节点的起始坐标
function BaoShiTabXiangQianLayer:getStartPoisition(count)
local x,y = 135,490
if count < 6 then
return x, y
end
y = y + ((count - 5) * 101)
return x, y
end
function BaoShiTabXiangQianLayer:getContentSize(count)
local size = self.scrollView:getContentSize()
if count < 6 then
return size
end
local rowcount = (count - 5)
size.height = size.height + (rowcount * 101)
return size
end
function BaoShiTabXiangQianLayer:loadData()
self.scrollView:removeAllChildren()
local count = 7
local x, y = self:getStartPoisition(count)
local size = self:getContentSize(count)
self.scrollView:setInnerContainerSize(size)
for i = 1, count do
local data = nil
local item, list = self:createItem(data)
item:setPosition({x = x, y = y})
y = y - 101
self.scrollView:addChild(item)
end
end
function BaoShiTabXiangQianLayer:createItem(data)
local callBackProvider = function(path, node, funcName)
if funcName == "itemClick" then
local function itemClick()
print("itemClick")
end
return itemClick
end
end
local object, UITable = UIUtil:createLayerFromCSB("baoshi_xiangqian_item", callBackProvider)
UITable["Image_root"]:setSwallowTouches(false)
return object, UITable
end
------ 左边的 scrollview end -----
------ 左边的 scrollview end -----
-------------------------------------
-------------------------------------
------ 中间的 scrollview start -----
------ 中间的 scrollview start -----
-- 获取子节点的起始坐标
function BaoShiTabXiangQianLayer:getMiddleStartPoisition(count)
local x,y = 135,420
if count < 8 then
return x, y
end
y = y + ((count - 7) * 64)
return x, y
end
function BaoShiTabXiangQianLayer:getMideleContentSize(count)
local size = self.scrollViewBaoShiType:getContentSize()
if count < 8 then
return size
end
local rowcount = (count - 7)
size.height = size.height + (rowcount * 64)
return size
end
function BaoShiTabXiangQianLayer:loadBaoshiTypeData(index)
self.scrollViewBaoShiType:removeAllChildren()
local count = 10
local x, y = self:getMiddleStartPoisition(count)
local size = self:getMideleContentSize(count)
self.scrollViewBaoShiType:setInnerContainerSize(size)
local countSub = 3
if index ~= nil then
y = y + 100 * countSub
end
for i = 1, count do
local data = {}
data.tag = i
local item, list = self:createBaoShiTypeItem(data)
item:setPosition({x = x, y = y})
self.scrollViewBaoShiType:addChild(item)
y = y - 64
--subitem
if i == index then
list["btnBaoShiType"]:loadTextureNormal("ui/baoshi/btn_qiexuan02.png")
for i = 1 , countSub do
item, list = self:createBaoShiTypeItemItem(data)
if i == 1 then
y = y - 20
end
item:setPosition({x = 133, y = y})
self.scrollViewBaoShiType:addChild(item)
y = y - 100
if i == countSub then
y = y + 20
end
end
self.scrollViewBaoShiType:setInnerContainerSize(cc.size(size.width, size.height + countSub * 100))
end
end
end
function BaoShiTabXiangQianLayer:createBaoShiTypeItem(data)
local callBackProvider = function(path, node, funcName)
if funcName == "typeClick" then
local function typeClick()
print("typeClick")
print("-----curBaoShiTypeIndex = "..table.tostring(curBaoShiTypeIndex))
print("----- data.tag = "..table.tostring(data.tag))
if curBaoShiTypeIndex == data.tag then
self:loadBaoshiTypeData()
curBaoShiTypeIndex = nil
else
self:loadBaoshiTypeData(data.tag)
curBaoShiTypeIndex = data.tag
end
end
return typeClick
end
end
local object, UITable = UIUtil:createLayerFromCSB("baoshi_type_item", callBackProvider)
UITable["btnBaoShiType"]:setSwallowTouches(false)
return object, UITable
end
end
return typeClick
end
end
local object, UITable = UIUtil:createLayerFromCSB("baoshi_type_item", callBackProvider)
UITable["btnBaoShiType"]:setSwallowTouches(false)
return object, UITable
end
function BaoShiTabXiangQianLayer:createBaoShiTypeItemItem(data)
local callBackProvider = function(path, node, funcName)
if funcName == "itemClick" then
local function itemClick()
print("itemClick")
end
return itemClick
end
end
local object, UITable = UIUtil:createLayerFromCSB("baoshi_item", callBackProvider)
UITable["Image_root"]:setSwallowTouches(false)
return object, UITable
end
------ 中间的 scrollview end -----
------ 中间的 scrollview end -----
-------------------------------------
function BaoShiTabXiangQianLayer:onExit()
print("onExit")
curBaoShiTypeIndex = nil
end
return BaoShiTabXiangQianLayer