Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timob 8221 New children hierarchy mechanisms. #2272

Merged
merged 6 commits into from
May 29, 2012
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions mobileweb/titanium/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ define(
while (recursionStack.length > 0) {
node = recursionStack.pop();
node._markedForLayout = true;
children = node.children;
children = node._children;
for (j in children) {
child = children[j];
if (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child)) {
Expand All @@ -203,7 +203,7 @@ define(
parent._markedForLayout = true;
previousParent = parent;
parent = parent._parent;

// Check if this parent is the stopping point
breakAfterChildrenCalculations = false;
if (!parent || parent === container) {
Expand All @@ -213,12 +213,12 @@ define(
!parent._markedForLayout && !~rootNodesToLayout.indexOf(parent) && rootNodesToLayout.push(parent);
breakAfterChildrenCalculations = true;
}

// Recurse through the children of the parent
recursionStack = [parent];
while (recursionStack.length > 0) {
node = recursionStack.pop();
children = node.children;
children = node._children;
for (j in children) {
child = children[j];
if (child !== previousParent && (node.layout !== "composite" || child._needsMeasuring || node._layout._isDependentOnParent(child))) {
Expand All @@ -227,15 +227,15 @@ define(
}
}
}

if (breakAfterChildrenCalculations) {
break;
}
}
}
}
}

// Layout all nodes that need it
if (layoutRootNode) {
var container = self._container,
Expand Down
10 changes: 5 additions & 5 deletions mobileweb/titanium/Ti/UI/AlertDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Locale", "T
}),
buttons = this.buttonNames || [];

alertWindow.add(dimmingView);
alertWindow.add(alertDialog);
alertWindow._add(dimmingView);
alertWindow._add(alertDialog);

// Add the title
alertDialog.add(UI.createLabel({
alertDialog._add(UI.createLabel({
text: Locale._getString(this.titleid, this.title),
font: {fontWeight: "bold"},
left: 5,
Expand All @@ -39,7 +39,7 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Locale", "T
}));

// Add the message
alertDialog.add(UI.createLabel({
alertDialog._add(UI.createLabel({
text: Locale._getString(this.messageid, this.message),
left: 5,
right: 5,
Expand All @@ -61,7 +61,7 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Locale", "T
index: i
});
i === this.cancel && css.add(button.domNode, "TiUIElementGradientCancel");
alertDialog.add(button);
alertDialog._add(button);
button.addEventListener("singletap", lang.hitch(this, function(){
alertWindow.close();
this._alertWindow = void 0;
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/titanium/Ti/UI/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/_/css", "Ti/_/styl
});
this._add(contentContainer);
contentContainer._add(this._buttonImage = UI.createImageView());
contentContainer.add(this._buttonTitle = UI.createLabel());
contentContainer._add(this._buttonTitle = UI.createLabel());
this._addStyleableDomNode(this._buttonTitle.domNode);

this._setDefaultLook();
Expand Down
4 changes: 2 additions & 2 deletions mobileweb/titanium/Ti/UI/ImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/style", "Ti/_/UI/Widget", "Ti/UI"],
set: function(value) {
this._removeAllChildren();
this._images = void 0;
this.add(this._createImage(value, function() {
this._add(this._createImage(value, function() {
this.fireEvent("load", {
state: "image"
});
Expand Down Expand Up @@ -232,7 +232,7 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/style", "Ti/_/UI/Widget", "Ti/UI"],
});
setStyle(img.domNode, "display", "none");
imgs.push(img);
this.add(img);
this._add(img);
}, this);
}
this._images = imgs;
Expand Down
16 changes: 16 additions & 0 deletions mobileweb/titanium/Ti/UI/MobileWeb/NavigationGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,23 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/UI/View", "Ti/UI", "Ti/_/lang"],
return len ? windows[windows.length - 1] : null;
},

add: function(view) {
this._navBarContainer._add(view);
this._publish(view);
},

remove: function(view) {
this._navBarContainer._remove(view);
this._unpublish(view);
},

open: function(win) {
if (!win._opened) {
var backButton = this._backButton;

// Publish the window
this._publish(win);

// Show the back button, if need be
backButton.animate({opacity: 1, duration: 250}, function() {
backButton.opacity = 1;
Expand All @@ -101,6 +114,9 @@ define(["Ti/_/css", "Ti/_/declare", "Ti/UI/View", "Ti/UI", "Ti/_/lang"],
var windows = this._windows,
windowIdx = windows.indexOf(win);

// Unpublish the window
this._unpublish(win);

// make sure the window exists and it's not the root
if (windowIdx > 0) {
windows.splice(windowIdx, 1);
Expand Down
8 changes: 4 additions & 4 deletions mobileweb/titanium/Ti/UI/OptionDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Locale", "Ti/UI", "Ti/_
opacity: 0
});

optionsWindow.add(dimmingView);
optionsWindow.add(optionsDialog);
optionsWindow._add(dimmingView);
optionsWindow._add(optionsDialog);

// Add the title
optionsDialog.add(UI.createLabel({
optionsDialog._add(UI.createLabel({
text: Locale._getString(this.titleid, this.title),
font: {fontWeight: "bold"},
left: 5,
Expand All @@ -53,7 +53,7 @@ define(["Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Locale", "Ti/UI", "Ti/_
} else if (i === this.cancel) {
css.add(button.domNode, "TiUIElementGradientCancel");
}
optionsDialog.add(button);
optionsDialog._add(button);
button.addEventListener("singletap", lang.hitch(this, function(){
optionsWindow.close();
this._optionsWindow = void 0;
Expand Down
5 changes: 3 additions & 2 deletions mobileweb/titanium/Ti/UI/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/UI/Widget", "Ti/UI", "Ti/_/lang", "T
this.fireEvent("change", eventInfo);
});
column.addEventListener("change", column._pickerChangeEventListener);
View.prototype.add.call(this,column);
this._add(column);
this._publish(column);
},

_updateColumnHeights: function() {
Expand Down Expand Up @@ -231,7 +232,7 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/UI/Widget", "Ti/UI", "Ti/_/lang", "T
});
dateTimeInput.min = self.min;
dateTimeInput.max = self.max;
View.prototype.add.call(self,dateTimeInput);
this._add(dateTimeInput);
}
switch(value) {
case UI.PICKER_TYPE_DATE:
Expand Down
12 changes: 7 additions & 5 deletions mobileweb/titanium/Ti/UI/PickerColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
right: 0,
bottom: 0
});
listWindow.add(dimmingView);
listWindow._add(dimmingView);

// Create the list dialog itself
var listDialog = UI.createView({
Expand All @@ -76,7 +76,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
borderRadius: 3,
opacity: 0
});
listWindow.add(listDialog);
listWindow._add(listDialog);

// Create the table rows
var rows = self._rows,
Expand All @@ -100,7 +100,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
height: data.length < 10 ? UI.SIZE : "70%",
data: data
});
listDialog.add(listTable);
listDialog._add(listTable);
listTable.addEventListener("singletap", function(e) {
e.index in self._rows && (self.selectedRow = self._rows[e.index]);
listWindow.close();
Expand All @@ -113,13 +113,13 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
right: 5,
title: "Cancel"
});
listDialog.add(cancelButton);
listDialog._add(cancelButton);
cancelButton.addEventListener("singletap", function() {
listWindow.close();
});

// Add a view to handle padding since there is no TI API to do it
listDialog.add(UI.createView({ height: "5px" }));
listDialog._add(UI.createView({ height: "5px" }));

// Show the options dialog
listWindow.open();
Expand Down Expand Up @@ -237,6 +237,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
if (!this.selectedRow) {
this.selectedRow = row;
}
this._publish(row);
},

removeRow: function(row) {
Expand All @@ -250,6 +251,7 @@ define(["Ti/_/declare", "Ti/_/UI/FontWidget", "Ti/_/dom", "Ti/UI", "Ti/_/style",
this.selectedRow = this._rows[0];
}
}
this._unpublish(row);
},

constants: {
Expand Down
6 changes: 3 additions & 3 deletions mobileweb/titanium/Ti/UI/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/UI/FontWidget", "Ti/_/lang", "Ti
return declare("Ti.UI.ProgressBar", Widget, {

constructor: function() {
this.add(this._contentContainer = UI.createView({
this._add(this._contentContainer = UI.createView({
width: UI.INHERIT,
height: UI.INHERIT,
left: 0,
top: 0,
layout: UI._LAYOUT_CONSTRAINING_VERTICAL
}));
this._contentContainer._layout._defaultHorizontalLayout = "start";
this._contentContainer.add(this._message = UI.createLabel());
this._contentContainer.add(this._progressBar = new InternalProgressBar({
this._contentContainer._add(this._message = UI.createLabel());
this._contentContainer._add(this._progressBar = new InternalProgressBar({
width: UI.INHERIT,
height: UI.INHERIT
}));
Expand Down
6 changes: 4 additions & 2 deletions mobileweb/titanium/Ti/UI/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang", "Ti/UI"],
this._add(contentContainer);
style.set(contentContainer.domNode,"overflow","hidden");

contentContainer.add(this._contentMeasurer = UI.createView({
contentContainer._add(this._contentMeasurer = UI.createView({
width: UI.SIZE,
height: UI.SIZE,
left: 0,
Expand Down Expand Up @@ -123,11 +123,13 @@ define(["Ti/_/declare", "Ti/UI/View", "Ti/_/style", "Ti/_/lang", "Ti/UI"],
},

add: function(view) {
this._contentMeasurer.add(view);
this._contentMeasurer._add(view);
this._publish(view);
},

remove: function(view) {
this._contentMeasurer.remove(view);
this._unpublish(view);
},

properties: {
Expand Down