From 988993483ff3d04842cdf9701b6fa0c0dead59aa Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Tue, 20 Mar 2018 15:05:41 +0100 Subject: [PATCH] fix scheme load bug --- src/core/BaseApplication.coffee | 10 ++++++---- src/core/BaseModel.coffee | 4 +++- src/core/gui.coffee | 3 ++- src/packages/AntOSDK/main.coffee | 33 +++++++++++++++++++++++++++---- src/packages/AntOSDK/main.css | 1 + src/packages/AntOSDK/welcome.html | 2 +- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/core/BaseApplication.coffee b/src/core/BaseApplication.coffee index 11f7f9e..b94092d 100644 --- a/src/core/BaseApplication.coffee +++ b/src/core/BaseApplication.coffee @@ -25,13 +25,14 @@ class BaseApplication extends this.OS.GUI.BaseModel CTRL: {} SHIFT: {} META: {} - init: -> - me = @ - # first register some base event to the app @subscribe "appregistry" , ( m ) -> me.applySetting m.data.m if (m.name is me.name) - + init: -> + me = @ + @off "*" + @on "exit", () -> me.quit() + # first register some base event to the app @on "focus", () -> me.sysdock.set "selectedApp", me me.appmenu.pid = me.pid @@ -48,6 +49,7 @@ class BaseApplication extends this.OS.GUI.BaseModel when "#{me.name}-about" then me.openDialog "AboutDialog", ()-> when "#{me.name}-exit" then me.trigger "exit" @loadScheme() + loadScheme: () -> #now load the scheme path = "#{@meta().path}/scheme.html" diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index 89e63b0..b2bfd21 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -52,7 +52,9 @@ class BaseModel one: (e, f) -> @observable.one e, f on: (e, f) -> @observable.on e, f - + off: (e, f) -> + return @observable.off e unless f + @observable.off e, f trigger: (e, d) -> @observable.trigger e, d subscribe: (e, f) -> diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 9a8a87c..f6f4fcf 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -37,6 +37,7 @@ self.OS.GUI = ] htmlToScheme: (html, app, parent) -> scheme = $.parseHTML html + $(app.scheme).remove() if app.scheme ($ parent).append scheme riot.mount ($ scheme), { observable: app.observable } @@ -186,11 +187,11 @@ self.OS.GUI = # so that it can be themed data.iconclass = "fa fa-cogs" if (not meta.icon) and (not meta.iconclass) dock = $ "#sysdock" + app.init() app.one "rendered", () -> dock.get(0).newapp data app.sysdock = dock.get(0) app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0] - app.init() toggleFullscreen: () -> el = ($ "body")[0] diff --git a/src/packages/AntOSDK/main.coffee b/src/packages/AntOSDK/main.coffee index 637f3f4..c713003 100644 --- a/src/packages/AntOSDK/main.coffee +++ b/src/packages/AntOSDK/main.coffee @@ -31,7 +31,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication (@find "btnnewprj").set "onbtclick", () -> me.newProject (path) -> me.prjfile = "#{path}/project.apj".asFileHandler() - me.loadScheme() + me.init() (@find "btnopenprj").set "onbtclick", () -> me.actionProject "#{me.name}-Open" return @@ -208,7 +208,32 @@ class AntOSDK extends this.OS.GUI.BaseApplication }, { path: "#{rpath}/README.md", - content: "##{n}" + content: """ + # #{n} + This is an example project, generated by AntOS Development Kit + + ## Howto + + 1. Open the project.apj file with AntOSDK (simply double Click on it) + 2. Modify the UI in *assets/scheme.html* + 3. Modify application code in *coffees/main.coffee* + 4. Modify CSS style in *css/main.css* + 5. Other files need to be copied: put in to assets + + ## Set up build target + + Click **Menu> Build > Build Option** or simply hit **ALT-Y** + + In the build options dialog, add or remove files that need to be + included into the build + + Click **Save** + + ## Build application + * To build: **Menu > Build > Build** or **ALT-C** + * To build and run: **Menu > Build > Build and Run** or **CTRL-R** + * To release: **Menu > Build > Build release** or **ALT-P** + """ }, { path: "#{rpath}/project.apj", @@ -264,7 +289,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication me.log "INFO", __("Opening {0}", me.prjfile.path) me.tabarea.set "selected", -1 me.tabarea.set "items", [] - me.currfile = "#{d.root}/coffees/main.coffee".asFileHandler() + me.currfile = "#{d.root}/README.md".asFileHandler() me.currfile.dirty = false me.chdir d.root if d.root me.prjfile.cache = d @@ -272,7 +297,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication me.open me.currfile ,"json" else - me.loadScheme() + me.init() open: (file) -> #find table diff --git a/src/packages/AntOSDK/main.css b/src/packages/AntOSDK/main.css index 453ce1e..654a01b 100644 --- a/src/packages/AntOSDK/main.css +++ b/src/packages/AntOSDK/main.css @@ -16,6 +16,7 @@ afx-app-window[data-id="antOSDK"] afx-resizer[data-id="botrz"] z-index: 9; border-top: 1px solid #a6a6a6; background-color: #2f3129; + border-right: 0; } afx-app-window[data-id="antOSDK"] div.welcome-cnt { diff --git a/src/packages/AntOSDK/welcome.html b/src/packages/AntOSDK/welcome.html index 72c0321..a785201 100644 --- a/src/packages/AntOSDK/welcome.html +++ b/src/packages/AntOSDK/welcome.html @@ -2,7 +2,7 @@
- +