mirror of https://github.com/axmolengine/axmol.git
Fixed ccui.ListView Test
This commit is contained in:
parent
c7bea705af
commit
9459d2b67e
|
@ -388,20 +388,17 @@ var UIListViewTest_ScrollToItem = UIMainLayer.extend({
|
|||
if(this._getListViewDirection() == ccui.ScrollView.DIR_HORIZONTAL)
|
||||
{
|
||||
var halfY = 110;
|
||||
pNode.drawLine(cc.p(center.x, center.y - halfY), cc.p(center.x, center.y + halfY), cc.color(0, 0, 0, 255));
|
||||
pNode.drawSegment(cc.p(center.x, center.y - halfY), cc.p(center.x, center.y + halfY), 2, cc.color(0, 0, 0, 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
var halfX = 150;
|
||||
pNode.drawLine(cc.p(center.x - halfX, center.y), cc.p(center.x + halfX, center.y), cc.color(0, 0, 0, 255));
|
||||
pNode.drawSegment(cc.p(center.x - halfX, center.y), cc.p(center.x + halfX, center.y), 2, cc.color(0, 0, 0, 255));
|
||||
}
|
||||
pNode.setLineWidth(2);
|
||||
pNode.setContentSize(listView.getContentSize());
|
||||
this._mainNode.addChild(pNode);
|
||||
}
|
||||
|
||||
var NUMBER_OF_ITEMS = 31;
|
||||
|
||||
// Button
|
||||
var pButton = new ccui.Button("ccs-res/cocosui/backtotoppressed.png", "ccs-res/cocosui/backtotopnormal.png");
|
||||
pButton.setAnchorPoint(cc.p(0, 0.5));
|
||||
|
@ -416,15 +413,28 @@ var UIListViewTest_ScrollToItem = UIMainLayer.extend({
|
|||
this._mainNode.addChild(pButton);
|
||||
|
||||
// Add list items
|
||||
var BUTTON_SIZE = cc.size(50, 40);
|
||||
|
||||
var default_button = new ccui.Button();
|
||||
default_button.setName("TextButton");
|
||||
default_button.setTouchEnabled(true);
|
||||
default_button.loadTextures("ccs-res/cocosui/backtotoppressed.png", "ccs-res/cocosui/backtotopnormal.png", "");
|
||||
|
||||
var default_item = new ccui.Layout();
|
||||
default_item.setTouchEnabled(true);
|
||||
default_item.setContentSize(default_button.getContentSize());
|
||||
default_button.x = default_item.width / 2;
|
||||
default_button.y = default_item.height / 2;
|
||||
default_item.addChild(default_button);
|
||||
|
||||
// set model
|
||||
listView.setItemModel(default_item);
|
||||
|
||||
// Add list items
|
||||
for (var i = 0; i < NUMBER_OF_ITEMS; ++i)
|
||||
{
|
||||
var pButton = new ccui.Button("ccs-res/cocosui/button.png", "ccs-res/cocosui/buttonHighlighted.png");
|
||||
pButton.setContentSize(BUTTON_SIZE);
|
||||
pButton.setScale9Enabled(true);
|
||||
pButton.setTitleText("Button-" + i);
|
||||
listView.pushBackCustomItem(pButton);
|
||||
var item = default_item.clone();
|
||||
item.getChildByName("TextButton").setTitleText("Button-" + i);
|
||||
listView.pushBackCustomItem(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -459,8 +469,6 @@ var UIListViewTest_Magnetic = UIMainLayer.extend({
|
|||
var background = this._widget.getChildByName("background_Panel");
|
||||
var backgroundSize = background.getContentSize();
|
||||
|
||||
this._indexLabels= [];
|
||||
|
||||
this._topDisplayLabel.setString("1");
|
||||
this._topDisplayLabel.setFontSize(14);
|
||||
this._topDisplayLabel.x = widgetSize.width / 2.0;
|
||||
|
@ -485,6 +493,8 @@ var UIListViewTest_Magnetic = UIMainLayer.extend({
|
|||
this._listView.x = widgetSize.width / 2;
|
||||
this._listView.y = widgetSize.height / 2;
|
||||
|
||||
this._listView.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL);
|
||||
|
||||
this._mainNode.addChild(this._listView);
|
||||
|
||||
{
|
||||
|
@ -494,14 +504,13 @@ var UIListViewTest_Magnetic = UIMainLayer.extend({
|
|||
if(this._getListViewDirection() == ccui.ScrollView.DIR_HORIZONTAL)
|
||||
{
|
||||
var halfY = 110;
|
||||
pNode.drawLine(cc.p(center.x, center.y - halfY), cc.p(center.x, center.y + halfY), cc.color(0, 0, 0, 255));
|
||||
pNode.drawSegment(cc.p(center.x, center.y - halfY), cc.p(center.x, center.y + halfY), 2, cc.color(0, 0, 0, 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
var halfX = 150;
|
||||
pNode.drawLine(cc.p(center.x - halfX, center.y), cc.p(center.x + halfX, center.y), cc.color(0, 0, 0, 255));
|
||||
pNode.drawSegment(cc.p(center.x - halfX, center.y), cc.p(center.x + halfX, center.y), 2, cc.color(0, 0, 0, 255));
|
||||
}
|
||||
pNode.setLineWidth(2);
|
||||
pNode.setContentSize(this._listView.getContentSize());
|
||||
this._mainNode.addChild(pNode);
|
||||
}
|
||||
|
@ -569,16 +578,28 @@ var UIListViewTest_Magnetic = UIMainLayer.extend({
|
|||
}.bind(this));
|
||||
this._mainNode.addChild(pButton);
|
||||
|
||||
// Add list items
|
||||
var BUTTON_SIZE = cc.size(50, 40);
|
||||
|
||||
var default_button = new ccui.Button();
|
||||
default_button.setName("TextButton");
|
||||
default_button.setTouchEnabled(true);
|
||||
default_button.loadTextures("ccs-res/cocosui/backtotoppressed.png", "ccs-res/cocosui/backtotopnormal.png", "");
|
||||
|
||||
var default_item = new ccui.Layout();
|
||||
default_item.setTouchEnabled(true);
|
||||
default_item.setContentSize(default_button.getContentSize());
|
||||
default_button.x = default_item.width / 2;
|
||||
default_button.y = default_item.height / 2;
|
||||
default_item.addChild(default_button);
|
||||
|
||||
// set model
|
||||
this._listView.setItemModel(default_item);
|
||||
|
||||
// Add list items
|
||||
for (var i = 0; i < 40; ++i)
|
||||
{
|
||||
var pButton = new ccui.Button("ccs-res/cocosui/button.png", "ccs-res/cocosui/buttonHighlighted.png");
|
||||
pButton.setContentSize(BUTTON_SIZE);
|
||||
pButton.setScale9Enabled(true);
|
||||
pButton.setTitleText("Button-" + i);
|
||||
this._listView.pushBackCustomItem(pButton);
|
||||
var item = default_item.clone();
|
||||
item.getChildByName("TextButton").setTitleText("Button-" + i);
|
||||
this._listView.pushBackCustomItem(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue