Skip to content
Browse files

started mutation handler overhaul and other changes for Dart compatab…

…ility
  • Loading branch information...
1 parent 92e92c5 commit d864e96a8f5b0fb9632f09277ab7317a8ba649a0 @prujohn prujohn committed
View
13 .children
@@ -0,0 +1,13 @@
+demos/todo/todo.dart
+demos/Colors/Colors.dart
+debug/debug.dart
+core/LUCA_UI_Framework.dart
+core_tests/TestGroup.dart
+unit_test_framework/UnitTestFramework.dart
+demos/DemoStyles/DemoStyles.dart
+core_tests/LUCA_UI_Tests.dart
+extensions/social/lucaui_extension_social.dart
+extensions/media/lucaui_extension_media.dart
+demos/ValueConversion/ValueConversion.dart
+demos/Life/GameOfLife.dart
+demos/tryit/Tryit.dart
View
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>lucaui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.google.dart.tools.core.dartBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.google.dart.tools.core.dartNature</nature>
+ </natures>
+</projectDescription>
View
1 core/.children
@@ -0,0 +1 @@
+LUCA_UI_Framework.dart
View
17 core/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.google.dart.tools.core.dartBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.google.dart.tools.core.dartNature</nature>
+ </natures>
+</projectDescription>
View
45 core/FrameworkElement.dart
@@ -121,7 +121,9 @@ class FrameworkElement extends FrameworkObject {
_initFrameworkProperties();
- _component.attributes["data-lucaui-element"] = _type;
+ //TODO bugged
+ // this._component.get$attributes().$setindex("data-lucaui-element", this.get$_LUCAUI_Extensions_Media_type());
+ //_component.attributes["data-lucaui-element"] = this._type;
_initFrameworkEvents();
}
@@ -560,8 +562,43 @@ class FrameworkElement extends FrameworkObject {
if (this is Panel) updateLayout();
}
- void _initFrameworkEvents(){
- _rawElement.addEventListener("DOMNodeInsertedIntoDocument",(e){
+ //TODO load/unload should be asynchronous
+ void _addToLayoutTree(FrameworkElement parentElement){
+
+ parentElement._component.elements.add(_component);
+
+ _isLoaded = true;
+
+ if (!parentElement._isLoaded) return;
+
+ onAddedToDOM();
+ }
+
+ void onAddedToDOM(){
+ //parent is in the DOM so we should call loaded event and check for children
+
+ updateDataContext();
+
+ updateLayout();
+
+ loaded.invoke(this, new EventArgs());
+
+ if (this.isContainer){
+ this.dynamic.children.forEach((FrameworkElement child) => child.onAddedToDOM());
+ }
+ }
+
+ void _removeFromLayoutTree(){
+ //enforce DOM participation
+ if (!_isLoaded)
+ throw new FrameworkException('Attempted to remove element that is not already loaded into the DOM.');
+
+ }
+
+
+ void _initFrameworkEvents(){
+
+ _component._addEventListener("DOMNodeInsertedIntoDocument",(e){
_isLoaded = true;
updateDataContext();
@@ -571,7 +608,7 @@ class FrameworkElement extends FrameworkObject {
loaded.invoke(this, new EventArgs());
});
- _rawElement.addEventListener("DOMNodeRemovedFromDocument", (e){
+ _component._addEventListener("DOMNodeRemovedFromDocument", (e){
_isLoaded = false;
unloaded.invoke(this, new EventArgs());
});
View
2 core/FrameworkObject.dart
@@ -53,7 +53,7 @@ class FrameworkObject extends LucaObject {
_Dom.appendClass(_component, "luca_ui_frameworkobject");
//grab the unwrapped version
- _rawElement = LevelDom.unwrap(_component);
+ //_rawElement = _unwrap(_component);
_initFrameworkObjectProperties();
View
1 core/IFrameworkContainer.dart
@@ -0,0 +1 @@
+interface IFrameworkContainer{}
View
5 core/IMultiChildContainer.dart
@@ -0,0 +1,5 @@
+
+interface IMultiChildContainer extends IFrameworkContainer{
+
+ ObservableList<FrameworkElement> children;
+}
View
4 core/ISingleChildContainer.dart
@@ -0,0 +1,4 @@
+
+interface ISingleChildContainer extends IFrameworkContainer{
+ FrameworkElement get content();
+}
View
16 core/LUCA_UI_Framework.dart
@@ -25,10 +25,12 @@
#library('LUCAUI_Framework_Core');
-#import('dart:coreimpl');
-#import('dart:htmlimpl');
+//#import('dart:coreimpl');
#import('dart:html');
+//required for now to prevent IDE squiggles on top-level functions like 'print()'
+// #import('dart:builtin');
+
#source('globals.dart');
#source('LucaSystem.dart');
#source('FrameworkObject.dart');
@@ -65,6 +67,7 @@
#source('events/PropertyChangingEventArgs.dart');
#source('events/ListChangedEventArgs.dart');
#source('events/RoutedEventArgs.dart');
+#source('events/SelectedItemChangedEventArgs.dart');
#source('primitives/Tuple.dart');
#source('primitives/Thickness.dart');
@@ -102,6 +105,8 @@
#source('elements/grid/GridCell.dart');
#source('elements/grid/GridLayoutDefinition.dart');
#source('elements/grid/GridLength.dart');
+#source('elements/DropDownList.dart');
+#source('elements/ListBox.dart');
//#source('elements/grid/Grid2.dart');
#source('exceptions/PresentationProviderException.dart');
@@ -132,8 +137,9 @@
#source('resources/GradientStop.dart');
#source('DataTemplate.dart');
#source('CollectionPresenter.dart');
-#source('DropDownList.dart');
-#source('SelectedItemChangedEventArgs.dart');
-#source('ListBox.dart');
#source('BindingData.dart');
#source('ControlTemplate.dart');
+
+#source('IFrameworkContainer.dart');
+#source('IMultiChildContainer.dart');
+#source('ISingleChildContainer.dart');
View
23 core/ObservableList.dart
@@ -43,7 +43,19 @@ class ObservableList<T> implements List<T>{
void forEach(void f(element)) => _list.forEach(f);
- int indexOf(T element, [int startingFrom = 0]) => _list.indexOf(element, startingFrom);
+ Collection map(f(T element)) => _list.map(f);
+
+ Collection<T> filter(bool f(T element)) => _list.filter(f);
+
+ bool every(bool f(T element)) => _list.every(f);
+
+ bool some(bool f(T element)) => _list.some(f);
+
+ Iterator<T> iterator() => _list.iterator();
+
+ int indexOf(T element, [int start = 0]) => _list.indexOf(element, start);
+
+ int lastIndexOf(T element, [int start = 0]) => _list.lastIndexOf(element, start);
int get length() => _list.length;
@@ -82,8 +94,6 @@ class ObservableList<T> implements List<T>{
T last() => _list.last();
- void set length(int newLength) => _list.length(newLength);
-
void sort(int compare(a, b)) => _list.sort(compare);
void insertRange(int start, int length, [T initialValue = null]){
@@ -106,13 +116,6 @@ class ObservableList<T> implements List<T>{
listChanged.invoke(this, new ListChangedEventArgs<T>(ol, from.getRange(startFrom, from.length - startFrom)));
}
- void copyFrom(List<T> src, int srcStart, int dstStart, int count) {
- var ol = getRange(dstStart, count);
- _list.copyFrom(src, srcStart, dstStart, count);
-
- listChanged.invoke(this, new ListChangedEventArgs<T>(ol, src));
- }
-
void _notifySingleOld(T oldItem){
var ol = new List<T>();
ol.add(oldItem);
View
2 core/elements/Button.dart
@@ -18,7 +18,7 @@
/**
* A button control element.
*/
-class Button extends Control
+class Button extends Control implements ISingleChildContainer
{
Dynamic _content;
View
0 core/DropDownList.dart → core/elements/DropDownList.dart
File renamed without changes.
View
2 core/elements/Hyperlink.dart
@@ -18,7 +18,7 @@
/**
* An element that renders a browser link.
*/
-class Hyperlink extends FrameworkElement
+class Hyperlink extends FrameworkElement implements ISingleChildContainer
{
Dynamic _content;
View
0 core/ListBox.dart → core/elements/ListBox.dart
File renamed without changes.
View
2 core/elements/Panel.dart
@@ -23,7 +23,7 @@
* * [LayoutCanvas]
* * [StackPanel]
*/
-class Panel extends _ContainerElement {
+class Panel extends _ContainerElement implements IMultiChildContainer {
/// An observable list of the child elements associated with the panel.
final ObservableList<FrameworkElement> children;
static final String childHasParentExceptionMessage = "Element is already child of another element.";
View
459 core/elements/grid/Grid2.dart
@@ -1,459 +0,0 @@
-/**
-* Provides a column/row based layout element
-* This version attempts to emit a table element for the grid presentation.
-* Not working yet... */
-class Grid2 extends Panel
-{
- static final String noDirectGridCellExceptionMessage = "GridCell cannot be added directly to Grid.";
- final List<GridCell> _internalChildren;
- final ObservableList<ColumnDefinition> columnDefinitions;
- final ObservableList<RowDefinition> rowDefinitions;
- final List<Binding> _bindings;
-
- static AttachedFrameworkProperty columnProperty, rowProperty, columnSpanProperty, rowSpanProperty;
-
- Grid2() :
- _internalChildren = new List<GridCell>(),
- columnDefinitions = new ObservableList<ColumnDefinition>(),
- rowDefinitions = new ObservableList<RowDefinition>(),
- _bindings = new List<Binding>()
- {
- children.listChanged + _onChildrenChanging;
-
- //columnDefinitions.listChanged + (_,__) => _updateRows();
- //rowDefinitions.listChanged + (_,__) => _updateRows();
-
- //widthProperty.propertyChanging + (_, __) => updateLayout();
- //heightProperty.propertyChanging + (_, __) => updateLayout();
- }
-
- void _onChildrenChanging(Object _, ListChangedEventArgs args){
-
- args.oldItems.forEach((item){
- var result = _internalChildren.filter((gc) => gc.content === item);
-
- if (result.length != 1)
- throw new FrameworkException("Deleted element not found in internal Grid collection.");
-
- result[0].removeChild(item);
- _component.removeChild(result[0]._component);
- item.parent = null;
- });
-
-
- args.newItems.forEach((item){
- if (item is GridCell)
- throw const FrameworkException(noDirectGridCellExceptionMessage);
-
- //create a virtual container for each element
- GridCell newGC = new GridCell();
- newGC.content = item;
-
- //newGC._component.style.setProperty("position", "absolute", null);
-
- _internalChildren.add(newGC);
-
- _component.appendChild(newGC._component);
- //_positionElement(newGC);
-
- });
-
- updateLayout();
- }
-
- num _totalLengthOf(List<GridLayoutDefinition> definitions){
- int total = 0;
-
- definitions.forEach((item){
- total += item._adjustedLength;
- });
-
- return total;
- }
-
- void _updateColumnsForRow(RowDefinition r){
- if (r._htmlNode == null)
- throw const FrameworkException("RowDefinition node assignment is null");
-
- //clear current columns...
- while(r._htmlNode.hasChildNodes()){
- if (r._htmlNode.firstChild.hasChildNodes())
- r._htmlNode.firstChild.removeChild(r._htmlNode.firstChild.firstChild);
- r._htmlNode.removeChild(r._htmlNode.firstChild);
- }
-
- //build columns...
- columnDefinitions.forEach((ColumnDefinition c){
- //create a node for the column if one does not already exist
- Element el = document.createElement("TD");
- el.setAttribute("data-lucaui-colid", c.hashCode().toString());
-
- //add column
- r._htmlNode.appendChild(el);
- if (c.width.gridUnitType == GridUnitType.pixel){
- el.style.setProperty("width", c.width.value.toString(), null);
- el.style.setProperty("max-width", c.width.value.toString(), null);
- el.style.setProperty("min-width", c.width.value.toString(), null);
- }
- });
- }
-
- void _updateRows(){
-
- //clearRows
- while(_component.hasChildNodes()){
- _component.removeChild(_component.firstChild);
- }
-
- //build rows
- rowDefinitions.forEach((RowDefinition r){
- //db("creating row", this);
- if (r._htmlNode == null){
- Element el = document.createElement("TR");
- el.setAttribute("data-lucaui-rowid", r.hashCode().toString());
- r._htmlNode = el;
- }
-
- if (r.height.gridUnitType == GridUnitType.pixel){
- r._htmlNode.style.setProperty("height", r.height.value.toString(), null);
- r._htmlNode.style.setProperty("max-height", r.height.value.toString(), null);
- r._htmlNode.style.setProperty("min-height", r.height.value.toString(), null);
- }
-
- _component.appendChild(r._htmlNode);
-
- //build columns for the row...
- _updateColumnsForRow(r);
- });
-
- }
-
- void updateLayout(){
- if (!_isLoaded) return;
- _updateRows();
-
- //set child wrappers to column offsets
- _internalChildren.forEach((child){
- int colIndex = Grid.getColumn(child.content);
- int rowIndex = Grid.getRow(child.content);
-
- if (rowIndex > rowDefinitions.length - 1) rowIndex = rowDefinitions.length - 1;
- if (colIndex > columnDefinitions.length - 1) colIndex = columnDefinitions.length - 1;
-
- ColumnDefinition targetColumn = columnDefinitions[colIndex];
- RowDefinition targetRow = rowDefinitions[rowIndex];
- Element rowElement = rowDefinitions[rowIndex]._htmlNode;
- Element columnElement = rowElement.querySelector("td[data-lucaui-colid='${targetColumn.hashCode()}']");
-
- child._component.style.setProperty("vertical-align","top",null);
-
- //child.width = columnElement.clientWidth;
- child.height = columnElement.clientHeight;
- columnElement.appendChild(child._component);
- });
-
-
- // _updateRowLayout(_component.clientHeight);
-
- // _updateColumnLayout(_component.clientWidth);
- }
-
- // Updates the column layout of the Grid based on given [gridWidth]
- void _updateColumnLayout(int gridMeasurement){
- int gridWidth = gridMeasurement;
-
- if (columnDefinitions.length == 0){
- //handle case where no columnDefinitions are set
- //assign all elements to a ghost column that is the same width as the grid
-
- _internalChildren.forEach((child){
- child.margin = new Thickness.Specified(child.margin.top, 0, 0, 0);
- child.width = gridWidth;
- });
-
- return;// });
- }
-
- num totalPixelValue = 0;
- num totalStarValue = 0;
- ColumnDefinition lastStar = null;
- ColumnDefinition lastAuto = null;
- bool hasAuto = false;
-
- //initialize values for column types
- columnDefinitions.forEach((ColumnDefinition c){
- if (c.width.gridUnitType == GridUnitType.pixel){
- c._adjustedLength = c.width.value;
-
- //summing the total pixels used by fixed column values
- totalPixelValue += c.width.value;
- }
- else if (c.width.gridUnitType == GridUnitType.star){
- totalStarValue += c.width.value; //generating a denominator for later actual width calculation
- lastStar = c;
- }
- else if (c.width.gridUnitType == GridUnitType.auto){
- lastAuto = c;
- }
-
- });
-
- _completeColumnLayout(gridWidth - totalPixelValue, totalStarValue, lastStar);
-
- }
-
- void _completeColumnLayout(num availColWidth, totalStarValue, ColumnDefinition lastStar)
- {
- //print("availColWidth: $availColWidth, totalStarValue: $totalStarValue");
- if (availColWidth < 0) availColWidth = 0;
-
- //now determine the offsets for each column
- int ii = 0;
- int totalStarLength = 0;
- columnDefinitions.forEach((ColumnDefinition c){
-
- // if star type calculate adjusted length
- if (c.width.gridUnitType == GridUnitType.star){
- if (c === lastStar){
- c._adjustedLength = availColWidth - totalStarLength;
- //print ("last adjusted length: ${c._adjustedLength}");
- }
- else{
- c._adjustedLength = (availColWidth * (c.width.value / totalStarValue)).floor();
- //print ("adjusted length: ${c._adjustedLength}");
- totalStarLength += c._adjustedLength;
- }
-
- }
-
- //calculate the offset for each column
- if (ii == 0){
- //first column always offset to 0;
- c._adjustedOffset = 0;
- }else{
- c._adjustedOffset = columnDefinitions[ii - 1]._adjustedOffset + columnDefinitions[ii - 1]._adjustedLength;
- }
- // print("column $ii offset: ${c._adjustedOffset}");
- ii++;
- });
-
- //set child wrappers to column offsets
- _internalChildren.forEach((child){
- int colIndex = Grid.getColumn(child.content);
-
- int childColumnSpan = Grid.getColumnSpan(child.content);
- child.margin = new Thickness.Specified(child.margin.top, 0, 0, columnDefinitions[colIndex]._adjustedOffset);
-
- if (childColumnSpan > 1){
- if (childColumnSpan > columnDefinitions.length - colIndex)
- childColumnSpan = columnDefinitions.length - colIndex;
- child.width = _totalLengthOf(columnDefinitions.getRange(colIndex, childColumnSpan));
- }else{
- child.width = columnDefinitions[colIndex]._adjustedLength;
- }
-
- child.updateLayout();
- });
-
- }
-
- // Updates the row layout of the Grid based on the given [gridHeight]
- void _updateRowLayout(int gridHeight){
-
- if (rowDefinitions.length == 0){
- //handle case where no rowDefinitions are set
- //assign all elements to a ghost row that is the same height as the grid
-
- _internalChildren.forEach((child){
- child.margin = new Thickness.Specified(0, 0, 0, child.margin.left);
- child.height = gridHeight;
- });
-
- return;
- }
-
- num totalPixelValue = 0;
- num totalStarValue = 0;
- RowDefinition lastStar = null;
-
- //initialize values for rows
- rowDefinitions.forEach((RowDefinition c){
- if (c.height.gridUnitType == GridUnitType.pixel){
- c._adjustedLength = c.height.value;
- totalPixelValue += c.height.value;
- }
- else if (c.height.gridUnitType == GridUnitType.star){
- totalStarValue += c.height.value;
- lastStar = c;
- }
- });
-
- _completeRowLayout(gridHeight - totalPixelValue, totalStarValue, lastStar);
- }
-
- void _completeRowLayout(num availRowHeight, num totalStarValue, RowDefinition lastStar)
- {
- //determine how much left for star columns
- if (availRowHeight < 0) availRowHeight = 0;
-
- // Go through the list and set the offset locations of each row.
- int ii = 0;
-
- int totalStarLength = 0;
- rowDefinitions.forEach((RowDefinition c){
-
- if (c.height.gridUnitType == GridUnitType.star){
- if (c === lastStar){
- c._adjustedLength = availRowHeight - totalStarLength;
- }else{
- c._adjustedLength = (availRowHeight * (c.height.value / totalStarValue)).round();
- totalStarLength += c._adjustedLength;
- }
- }
-
- //skip the first one
- if (ii == 0){
- c._adjustedOffset = 0;
- }else{
- //calculate the offset
- c._adjustedOffset = rowDefinitions[ii - 1]._adjustedOffset + rowDefinitions[ii - 1]._adjustedLength;
- }
- ii++;
- });
-
- //assign child wrappers to row offsets
- _internalChildren.forEach((child){
- int rowIndex = Grid.getRow(child.content);
- int childRowSpan = Grid.getRowSpan(child.content);
- child.margin = new Thickness.Specified(rowDefinitions[rowIndex]._adjustedOffset, 0, 0, child.margin.left);
-
- if (childRowSpan > 1){
- if (childRowSpan > rowDefinitions.length - rowIndex)
- childRowSpan = rowDefinitions.length - rowIndex;
- child.height = _totalLengthOf(rowDefinitions.getRange(rowIndex, childRowSpan));
- }else{
- child.height = rowDefinitions[rowIndex]._adjustedLength;
- }
- child.updateLayout();
- });
-
- }
-
- //attached properties
-
- static void setColumn(FrameworkElement element, int column){
- if (element == null) return;
-
- if (column < 0) column = 0;
-
- if (Grid.columnProperty == null){
- Grid.columnProperty = new AttachedFrameworkProperty("column", (FrameworkElement element, int value){
-
- });
- }
-
- setAttachedValue(element, columnProperty, column);
- }
-
- static int getColumn(FrameworkElement element){
- if (element == null) return 0;
-
- var value = getAttachedValue(element, Grid.columnProperty);
-
- if (Grid.columnProperty == null || value == null)
- Grid.setColumn(element, 0);
-
- return getAttachedValue(element, columnProperty);
- }
-
- static void setRow(FrameworkElement element, int row){
- if (element == null) return;
-
- if (row < 0) row = 0;
-
- if (Grid.rowProperty == null){
- Grid.rowProperty = new AttachedFrameworkProperty("row", (FrameworkElement element, int value){
-
- });
- }
-
- setAttachedValue(element, rowProperty, row);
- }
-
- static int getRow(FrameworkElement element){
- if (element == null) return 0;
-
- var value = getAttachedValue(element, Grid.rowProperty);
-
- if (Grid.rowProperty == null || value == null)
- Grid.setRow(element, 0);
-
- return getAttachedValue(element, rowProperty);
- }
-
- static void setColumnSpan(FrameworkElement element, int columnSpan){
- if (element == null) return;
-
- if (columnSpan < 0) columnSpan = 0;
-
- if (Grid.columnSpanProperty == null){
- Grid.columnSpanProperty = new AttachedFrameworkProperty("columnSpan", (FrameworkElement element, int value){
-
- });
- }
-
- setAttachedValue(element, columnSpanProperty, columnSpan);
- }
-
- static int getColumnSpan(FrameworkElement element){
- if (element == null) return 0;
-
- var value = getAttachedValue(element, Grid.columnSpanProperty);
-
- if (Grid.columnSpanProperty == null || value == null)
- Grid.setColumnSpan(element, 0);
-
- return getAttachedValue(element, Grid.columnSpanProperty);
- }
-
- static void setRowSpan(FrameworkElement element, int rowSpan){
- if (element == null) return;
-
- if (rowSpan < 0) rowSpan = 0;
-
- if (Grid.rowSpanProperty == null){
- Grid.rowSpanProperty = new AttachedFrameworkProperty("rowSpan", (FrameworkElement element, int value){
-
- });
- }
-
- setAttachedValue(element, rowSpanProperty, rowSpan);
- }
-
- static int getRowSpan(FrameworkElement element){
- if (element == null) return 0;
-
- var value = getAttachedValue(element, Grid.rowSpanProperty);
-
- if (Grid.rowSpanProperty == null || value == null)
- Grid.setRowSpan(element, 0);
-
- return getAttachedValue(element, rowSpanProperty);
- }
-
-
-
- void CreateElement(){
- _component = document.createElement("TABLE");
- _component.setAttribute("border","1");
- //_component.style.setProperty("border","1",null);
-// LucaSystem.setHorizontalFlexBoxAlignment(this, HorizontalAlignment.Center);
-// LucaSystem.setVerticalFlexBoxAlignment(this, VerticalAlignment.Center);
- }
-
- String _type() { return "Grid"; }
-}
-
-
-
-
View
0 core/SelectedItemChangedEventArgs.dart → .../events/SelectedItemChangedEventArgs.dart
File renamed without changes.
View
2 core_tests/FrameworkFundamentalsTests.dart
@@ -97,7 +97,7 @@ class FrameworkFundamentalsTests extends TestGroupBase
//check if the correct information is rendered to the DOM
Expect.equals(b.component.nodes.length, 1);
- Expect.equals(b.component.nodes[0].nodeName, "BUTTON");
+ Expect.equals(b.component.nodes[0].toString(), "BUTTON");
_removeElement(b);
View
1 core_tests/LUCA_UI_Tests.dart
@@ -20,6 +20,7 @@
//may need to adjust these paths if you have the files a different location
#import('../unit_test_framework/UnitTestFramework.dart');
+
#import('../core/LUCA_UI_Framework.dart');
#source('UIBuilder.dart');
View
175 core_tests/TestFramework.dart
@@ -1,175 +0,0 @@
-class TestFramework {
- static StackPanel _rootPanel;
- final int _failureMessageIndent = 50;
-
- TestFramework()
- {
- LucaSystem.unitTestEnabled = true;
- if (_rootPanel == null){
- _buildTestUI();
- }
- }
-
-
- /**
- * Initializes the main UI for the unit test results */
- void _buildTestUI(){
- var el = document.body.query("#UnitTestResults");
- Expect.isNotNull(el, "Expected to find unit test element in DOM.");
-
- Border b = new Border();
- b.background = new SolidColorBrush(new Color(Colors.Gray));
- b.borderColor = new SolidColorBrush(new Color(Colors.Black));
- b.borderThickness = new Thickness(2);
- b.padding = new Thickness(10);
-
- var wrapperPanel = new StackPanel();
-
- _rootPanel = new StackPanel();
- b.content = wrapperPanel;
-
- TextBlock t = new TextBlock();
- t.text = "LUCA UI - Unit Test Results";
- t.foreground = new SolidColorBrush(new Color(Colors.Yellow));
- t.fontSize = 16;
- t.fontFamily = "Consolas";
-
- _rootPanel.children.add(t);
-
- var btnCollapseToggle = new Button();
-
- btnCollapseToggle.content = "Hide";
-
- btnCollapseToggle.click + (_, __) {
- if (_rootPanel.visibility == Visibility.visible){
- _rootPanel.visibility = Visibility.collapsed;
- b.opacity = .5;
- btnCollapseToggle.content = "Show";
-
- }else{
- _rootPanel.visibility = Visibility.visible;
- b.opacity = 1.0;
- btnCollapseToggle.content = "Hide";
- }
- };
-
- wrapperPanel.children.add(btnCollapseToggle);
- wrapperPanel.children.add(_rootPanel);
-
-
- b.render(el);
- }
-
- /**
- * Executes and displays results of tests for a given test [group] */
- void executeTestGroup(TestGroupBase group){
-
- var contentPanel = _createGroupUI(group);
- bool groupPassed = true;
- group.testList.forEach((testName, value) {
- if (!groupPassed)
- {
- _executeTest(testName, value, contentPanel);
- }else{
- groupPassed = _executeTest(testName, value, contentPanel);
- }
-
- });
-
- //collapse the group if all tests pass
- if (groupPassed){
- var p = contentPanel.parent;
- var h = p.children[0];
- var b = h.children[0];
- b.click.invoke(this, new EventArgs());
- }
- }
-
- /**
- * Executes an individual test. Should not be called directly */
- bool _executeTest(String testName, Function test, StackPanel currentPanel){
- var testText = _addTestMessage(currentPanel, "$testName... ");
-
- testText.foreground = new SolidColorBrush(new Color("#FFCCCC"));
- try{
- test();
- }catch(ExpectException e){
- testText.text = testText.text + "FAILED.";
- var failMsg = _addTestMessage(currentPanel, "... ${e.message}", _failureMessageIndent);
- failMsg.foreground = new SolidColorBrush(new Color("#FFCCCC"));
- return false;
- }catch(FrameworkException e){
- testText.text = testText.text + "FAILED.";
- var failMsg = _addTestMessage(currentPanel, "... FrameworkException: ${e.message}", _failureMessageIndent);
- failMsg.foreground = new SolidColorBrush(new Color("#FFCCCC"));
- return false;
- }catch(Exception e){
- testText.text = testText.text + "FAILED.";
- var failMsg = _addTestMessage(currentPanel, "... Exception: ${e.toString()}", _failureMessageIndent);
- failMsg.foreground = new SolidColorBrush(new Color("#FFCCCC"));
- return false;
- }
-
- testText.foreground = new SolidColorBrush(new Color("#00FF00"));
- testText.text = testText.text + "passed.";
-
- return true;
- }
-
- /**
- * Add an output [message] to the given [targetPanel] with optional [indentation] */
- TextBlock _addTestMessage(StackPanel targetPanel, String message, [int indentation = 0]){
- TextBlock t = new TextBlock();
- t.text = message;
- t.foreground = new SolidColorBrush(new Color(Colors.White));
- t.fontSize = 12;
- t.fontFamily = "Consolas";
- if (indentation > 0)
- t.margin = new Thickness.Specified(0, 0, 0, indentation);
- targetPanel.children.add(t);
- return t;
- }
-
- /**
- * Generates UI for a unit test [group] and returns the content stackpanel */
- StackPanel _createGroupUI(TestGroupBase group){
- StackPanel groupPanel = new StackPanel();
- groupPanel.margin = new Thickness.Specified(10,0,0,0);
-
- StackPanel headerPanel = new StackPanel();
- headerPanel.orientation = Orientation.horizontal;
-
- StackPanel contentPanel = new StackPanel();
- contentPanel.margin = new Thickness.Specified(0,0,0,20);
-
- groupPanel.children.add(headerPanel);
- groupPanel.children.add(contentPanel);
-
- var btnCollapse = new Button();
- btnCollapse.content = "-";
-
- btnCollapse.click + (_, __) {
- if (contentPanel.visibility == Visibility.visible){
- contentPanel.visibility = Visibility.collapsed;
- btnCollapse.content = "+";
-
- }else{
- contentPanel.visibility = Visibility.visible;
- btnCollapse.content = "-";
- }
- };
-
- headerPanel.children.add(btnCollapse);
-
- TextBlock t = new TextBlock();
- t.text = group.testGroupName;
- t.foreground = new SolidColorBrush(new Color("#CCCCFF"));
- t.fontSize = 14;
- t.fontFamily = "Consolas";
- headerPanel.children.add(t);
-
- _rootPanel.children.add(groupPanel);
-
- return contentPanel;
- }
-}
View
10 debug/BorderDemoView.dart
@@ -22,9 +22,9 @@ class BorderDemoView implements IView
LinearGradientBrush lgb = new LinearGradientBrush();
//lgb.direction = LinearGradientDirection.topToBottom;
- lgb.stops.add(new GradientStop(new Color.predefined(Colors.Orange), 50));
- lgb.stops.add(new GradientStop(new Color.predefined(Colors.White)));
- lgb.stops.add(new GradientStop(new Color.predefined(Colors.Orange)));
+ lgb.stops.add(new GradientStop.with(new Color.predefined(Colors.Orange), 50));
+ lgb.stops.add(new GradientStop.with(new Color.predefined(Colors.White)));
+ lgb.stops.add(new GradientStop.with(new Color.predefined(Colors.Orange)));
rootBorder.background = lgb;
@@ -41,8 +41,8 @@ class BorderDemoView implements IView
tb.margin = new Thickness(10);
tb.name = "tbHelloWorld";
tb.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nunc nunc, lacinia sit amet ultricies non, bibendum quis eros. Integer hendrerit volutpat velit sit amet iaculis. Curabitur eu arcu velit, non blandit nulla. Nullam diam dui, molestie non ultricies a, tristique nec nunc. Nullam hendrerit fringilla nulla non porttitor. Cras orci sapien, porttitor placerat dapibus vitae, pharetra a lectus. Nulla tincidunt lacinia elit ac tempus. Sed sed sem justo, quis facilisis dui. Nullam quis lacus a sapien faucibus mollis. Nam eget dolor turpis.";
- tb.horizontalAlignment = HorizontalAlignment.Center;
- tb.verticalAlignment = VerticalAlignment.Center;
+ tb.horizontalAlignment = HorizontalAlignment.center;
+ tb.verticalAlignment = VerticalAlignment.center;
tb.width = 500;
rootBorder.content = tb;
View
10 debug/GridDemoView.dart
@@ -42,7 +42,7 @@ class GridDemoView implements IView
title.fontSize = 36;
title.fontFamily = "Consolas";
title.margin = new Thickness(5);
- title.horizontalAlignment = HorizontalAlignment.Center;
+ title.horizontalAlignment = HorizontalAlignment.center;
Grid.setColumnSpan(title, 3);
// Binding to view model property.
@@ -62,8 +62,8 @@ class GridDemoView implements IView
Border b = new Border();
b.borderColor = new SolidColorBrush(new Color.predefined(Colors.Black));
b.borderThickness = new Thickness(1);
- b.horizontalAlignment = HorizontalAlignment.Stretch;
- b.verticalAlignment = VerticalAlignment.Stretch;
+ b.horizontalAlignment = HorizontalAlignment.stretch;
+ b.verticalAlignment = VerticalAlignment.stretch;
b.name = "border${c.toString()}_${(r-1).toString()}";
//b.background = new SolidColorBrush(new Color(Colors.Yellow));
//b.height = 25;
@@ -76,8 +76,8 @@ class GridDemoView implements IView
tb.name = "tb${c.toString()}_${(r-1).toString()}";
//tb.background = new SolidColorBrush(new Color(Colors.White));
tb.margin = new Thickness(10);
- tb.horizontalAlignment = HorizontalAlignment.Center;
- tb.verticalAlignment = VerticalAlignment.Center;
+ tb.horizontalAlignment = HorizontalAlignment.center;
+ tb.verticalAlignment = VerticalAlignment.center;
b.content = tb;
}
}
View
10 debug/MainUIView.dart
@@ -20,9 +20,9 @@ class MainUIView implements IView
LinearGradientBrush lgb = new LinearGradientBrush();
- lgb.direction = LinearGradientDirection.topToBottom;
- lgb.stops.add(new GradientStop(new Color.hex("#ccccff")));
- lgb.stops.add(new GradientStop(new Color.hex("#000077")));
+ lgb.direction = LinearGradientDirection.vertical;
+ lgb.stops.add(new GradientStop.with(new Color.hex("#ccccff")));
+ lgb.stops.add(new GradientStop.with(new Color.hex("#000077")));
rootBorder.background = lgb;
@@ -42,8 +42,8 @@ class MainUIView implements IView
Border contentBorder = new Border();
Grid.setColumn(contentBorder, 1);
contentBorder.margin = new Thickness(10);
- contentBorder.horizontalAlignment = HorizontalAlignment.Stretch;
- contentBorder.verticalAlignment = VerticalAlignment.Stretch;
+ contentBorder.horizontalAlignment = HorizontalAlignment.stretch;
+ contentBorder.verticalAlignment = VerticalAlignment.stretch;
contentBorder.background = new SolidColorBrush(new Color.predefined(Colors.Beige));
g.children.add(contentBorder);
View
4 debug/View.dart
@@ -26,7 +26,7 @@ class MainView implements IView {
void _generateDemoRadioButtons(Grid rootGrid){
TextBlock txt = new TextBlock();
txt.text = "Radio Buttons:";
- txt.verticalAlignment = VerticalAlignment.Center;
+ txt.verticalAlignment = VerticalAlignment.center;
Grid.setRow(txt, 2);
rootGrid.children.add(txt);
@@ -95,7 +95,7 @@ class MainView implements IView {
TextBlock txt = new TextBlock();
txt.text = "TextBox:";
- txt.verticalAlignment = VerticalAlignment.Center;
+ txt.verticalAlignment = VerticalAlignment.center;
rootGrid.children.add(txt);
tb.textChanged + (_, TextChangedEventArgs args){
View
3 debug/debug.dart
@@ -1,5 +1,8 @@
#import('../core/LUCA_UI_Framework.dart');
#import('dart:html');
+
+#import('dart:builtin'); //remove once IDE supports top-level functions without squiggles
+
//#import('dart:json');
#source('ViewModel.dart');
View
2 demos/Life/PlayfieldViewModel.dart
@@ -122,7 +122,7 @@ class _PlayfieldViewModelImplementation extends ViewModelBase implements Playfie
for (int c = 0; c < model.matrix.length; c++){
color = model.matrix[c][r] == 1 ? occupied : empty;
- view.children[(model.matrix.length * r) + c].background = color;
+ view.children[(model.matrix.length * r) + c].dynamic.background = color;
// var result = view
// .children
View
1 demos/tryit/.children
@@ -0,0 +1 @@
+Tryit.dart
View
17 demos/tryit/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tryit</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.google.dart.tools.core.dartBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.google.dart.tools.core.dartNature</nature>
+ </natures>
+</projectDescription>

0 comments on commit d864e96

Please sign in to comment.
Something went wrong with that request. Please try again.