wsick / Fayde

Inspired by Silverlight; XAML engine using Javascript and rendering to the HTML5 Canvas.
MIT License
189 stars 27 forks source link

Dynamically change Theme code is broken in the latest build. #55

Closed Sally-Xu closed 9 years ago

Sally-Xu commented 10 years ago

I got "Element is already a child of another element." error in XamlObjectCollection.prototype.Insert function when try to set Fayde.Application.Current.ThemeName in ViewModel code.

The callstack points to ItemsPresenter.prototype.OnItemsAdded function.

BSick7 commented 10 years ago

Please include entire callstack.

Sally-Xu commented 10 years ago

Insert [Fayde.js] Line 6165 Script OnItemsAdded [Fayde.js] Line 12129 Script DoApplyTemplateWithError [Fayde.js] Line 12079 Script ApplyTemplateWithError [Fayde.js] Line 4638 Script OnApplyTemplate [Fayde.js] Line 8613 Script ApplyTemplateWithError [Fayde.js] Line 4641 Script _Measure [Fayde.js] Line 3967 Script Measure [Fayde.js] Line 10989 Script MeasureOverride [Fayde.js] Line 10716 Script _Measure [Fayde.js] Line 3987 Script MeasureOverride [Fayde.js] Line 4958 Script _Measure [Fayde.js] Line 3987 Script MeasureOverride [Fayde.js] Line 4032 Script _Measure [Fayde.js] Line 3987 Script MeasureOverride [Fayde.js] Line 4958 Script _Measure [Fayde.js] Line 3987 Script MeasureOverride [Fayde.js] Line 4958 Script _Measure [Fayde.js] Line 3987 Script Measure [Fayde.js] Line 10989 Script MeasureOverride [Fayde.js] Line 10716 Script _Measure [Fayde.js] Line 3987 Script MeasureOverride [Fayde.js] Line 4032 Script _Measure [Fayde.js] Line 3987 Script _DoMeasureWithError [Fayde.js] Line 3934 Script UpdateLayer [Fayde.js] Line 3888 Script _UpdateLayout [Fayde.js] Line 21984 Script ProcessDirtyElements [Fayde.js] Line 21943 Script Update [Fayde.js] Line 20827 Script OnTicked [Fayde.js] Line 20807 Script _DoTick [Fayde.js] Line 20980 Script Anonymous function [Fayde.js] Line 20987 Script

Sally-Xu commented 10 years ago

The error message for dynamically changing theme is now "Could not change theme. Error: ./lib/exjs/Themes/Metro.theme.xml HTTP status: 404" in the latest build.

The following code is looping through each library under the "lib" folder and trying to load the new theme under that library.

Library.ChangeTheme = function (themeName) { var reqs = []; var library; for (var name in libraries) { library = libraries[name]; reqs.push(library._LoadTheme({ ThemeName: themeName, Resolving: [] })); } return deferArraySimple(reqs); };

BSick7 commented 10 years ago

That code iterates through each library registered. I began registering all libraries with the introduction of fayde.json. We can either specifically mark the type of library in fayde.json or gracefully fail when changing a library's theme.

Sally-Xu commented 10 years ago

I'd prefer gracefully fail if the lib has no themes file.

BSick7 commented 9 years ago

While introducing nullstone, it was necessary to rebuild type and theme management. Upcoming changes will allow you to configure library themes (no theme, path template, default path).

BSick7 commented 9 years ago

Also, controls will only look in owning library theme for implicit style.

BSick7 commented 9 years ago

Please see https://github.com/BSick7/Fayde/wiki/Fayde.json for information on fayde.json configuration.