From ae54c9a10c68455d65b702d2c03854fdd5e82a04 Mon Sep 17 00:00:00 2001 From: lxsang Date: Sat, 9 May 2020 23:32:26 +0200 Subject: [PATCH] remove riot and use the new tag engine --- Makefile | 2 + src/core/BaseModel.coffee | 2 +- src/core/BaseService.coffee | 7 ++- src/core/gui.coffee | 37 +++++++------ src/core/tags/FloatListTag.coffee | 2 +- src/core/tags/ListViewTag.coffee | 3 +- src/core/tags/MenuTag.coffee | 52 ++++++++++++++----- src/core/tags/OverlayTag.coffee | 5 +- src/core/tags/SystemPanelTag.coffee | 42 +++++++++++++++ src/core/tags/tag.coffee | 3 +- src/packages/CoreServices/Calendar.coffee | 5 +- .../CoreServices/PushNotification.coffee | 30 ++++++----- src/packages/CoreServices/Spotlight.coffee | 23 ++++---- src/packages/CoreServices/UserService.coffee | 17 +++--- src/packages/ShowCase/coffees/main.coffee | 2 +- src/themes/antos/afx-float-list.css | 4 +- src/themes/antos/afx-label.css | 2 +- src/themes/antos/afx-menu.css | 8 +-- 18 files changed, 163 insertions(+), 83 deletions(-) create mode 100644 src/core/tags/SystemPanelTag.coffee diff --git a/Makefile b/Makefile index 5ea309c..f2a4159 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,8 @@ coffees= src/core/core.coffee \ src/core/tags/ColorPickerTag.coffee \ src/core/tags/FileViewTag.coffee \ src/core/tags/OverlayTag.coffee \ + src/core/tags/AppDockTag.coffee \ + src/core/tags/SystemPanelTag.coffee \ src/antos.coffee diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index 5a8428f..485958c 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -19,7 +19,7 @@ class BaseModel constructor: (@name, @args) -> me = @ - @observable = riot.observable() + @observable = new Announcer() @_api = Ant.OS.API @_gui = Ant.OS.GUI @systemsetting = Ant.OS.setting diff --git a/src/core/BaseService.coffee b/src/core/BaseService.coffee index 010fab9..1ac4e71 100644 --- a/src/core/BaseService.coffee +++ b/src/core/BaseService.coffee @@ -24,6 +24,9 @@ class BaseService extends this.OS.GUI.BaseModel @text = "" @timer = undefined @holder = undefined + me = @ + @onmenuselect = (d) -> + me.awake d init: ()-> #implement by user @@ -33,10 +36,6 @@ class BaseService extends this.OS.GUI.BaseModel Ant.OS.APP[@name].meta attach: (h) -> @holder = h - - update: () -> - @holder.update() if @holder - @scheme.update() if @scheme watch: ( t, f) -> me = @ diff --git a/src/core/gui.coffee b/src/core/gui.coffee index ab9e5cb..41a99f8 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -31,10 +31,10 @@ Ant.OS.GUI = text: "", iconclass: "fa fa-eercast", dataid: "sys-menu-root", - child: [ + children: [ { text: "__(Applications)", - child: [], + children: [], dataid: "sys-apps" iconclass: "fa fa-adn", onmenuselect: (d) -> @@ -53,7 +53,7 @@ Ant.OS.GUI = $(app.scheme).remove() if app.scheme ($ parent).append scheme app.scheme = scheme[0] - riot.mount ($ scheme), { observable: app.observable } + scheme[0].uify app.observable app.main() app.show() loadScheme: (path, app, parent) -> @@ -319,11 +319,15 @@ Ant.OS.GUI = Ant.OS.GUI.shortcut[fnk][c](event) event.preventDefault() # system menu and dock - riot.mount ($ "#syspanel", $ "#wrapper") - riot.mount ($ "#sysdock", $ "#workspace"), { items: [] } - riot.mount ($ "#systooltip", $ "#wrapper") + $("#syspanel")[0].uify() + $("#sysdock")[0].uify() + $("#systooltip")[0].uify() + $("#contextmenu")[0].uify() + #riot.mount ($ "#syspanel", $ "#wrapper") + #riot.mount ($ "#sysdock", $ "#workspace"), { items: [] } + #riot.mount ($ "#systooltip", $ "#wrapper") # context menu - riot.mount ($ "#contextmenu", $ "#wrapper") + #riot.mount ($ "#contextmenu", $ "#wrapper") ($ "#workspace").contextmenu (e) -> Ant.OS.GUI.bindContextMenu e # tooltip ($ "#workspace").mouseover (e) -> @@ -409,7 +413,8 @@ Ant.OS.GUI = desktop[0].fetch() if d.data.file.hash() is fp.hash() or d.data.file.parent().hash() is fp.hash() Ant.OS.announcer.ostrigger "desktoploaded" # mount it - riot.mount desktop + desktop[0].uify() + # riot.mount desktop , (e, s) -> alert __("System fail: Cannot init desktop manager") console.log s, e @@ -417,21 +422,21 @@ Ant.OS.GUI = ($ Ant.OS.GUI.workspace)[0].fetch() refreshSystemMenu: () -> - Ant.OS.GUI.SYS_MENU[0].child.length = 1 - Ant.OS.GUI.SYS_MENU[0].child[0].child.length = 0 - Ant.OS.GUI.SYS_MENU[0].child[0].child.push v for k, v of Ant.OS.setting.system.packages when (v and v.app) - Ant.OS.GUI.SYS_MENU[0].child.push v for k, v of Ant.OS.setting.system.menu - Ant.OS.GUI.SYS_MENU[0].child.push + Ant.OS.GUI.SYS_MENU[0].children.length = 1 + Ant.OS.GUI.SYS_MENU[0].children[0].children.length = 0 + Ant.OS.GUI.SYS_MENU[0].children[0].children.push v for k, v of Ant.OS.setting.system.packages when (v and v.app) + Ant.OS.GUI.SYS_MENU[0].children.push v for k, v of Ant.OS.setting.system.menu + Ant.OS.GUI.SYS_MENU[0].children.push text: "__(Toggle Full screen)", dataid: "os-fullsize", iconclass: "fa fa-tv" - Ant.OS.GUI.SYS_MENU[0].child.push + Ant.OS.GUI.SYS_MENU[0].children.push text: "__(Log out)", dataid: "sys-logout", iconclass: "fa fa-user-times" - ($ "[data-id = 'os_menu']", "#syspanel")[0].update() + # Ant.OS.GUI.buildSystemMenu() buildSystemMenu: () -> - ($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", Ant.OS.GUI.SYS_MENU + ($ "[data-id = 'osmenu']", "#syspanel")[0].set "items", Ant.OS.GUI.SYS_MENU #console.log menu diff --git a/src/core/tags/FloatListTag.coffee b/src/core/tags/FloatListTag.coffee index e4760f1..72edd6b 100644 --- a/src/core/tags/FloatListTag.coffee +++ b/src/core/tags/FloatListTag.coffee @@ -86,4 +86,4 @@ class FloatListTag extends ListViewTag cleft = 20 ctop += h + 20 -Ant.OS.GUI.define "afx-float-list1", FloatListTag +Ant.OS.GUI.define "afx-float-list", FloatListTag diff --git a/src/core/tags/ListViewTag.coffee b/src/core/tags/ListViewTag.coffee index 98b14a7..cbc0bdc 100644 --- a/src/core/tags/ListViewTag.coffee +++ b/src/core/tags/ListViewTag.coffee @@ -70,7 +70,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag @setopt "onlistdbclick", () -> @setopt "onitemclose", () -> true @setopt "buttons", [] - @setopt "data", {} + @setopt "data", [] @setopt "dropdown", false @setopt "itemtag", "afx-list-item" @setopt "multiselect", false @@ -116,6 +116,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag .set "onclose", (e) -> me.iclose e .set "data", item + item.domel = el[0] el[0] remove: (item) -> diff --git a/src/core/tags/MenuTag.coffee b/src/core/tags/MenuTag.coffee index e316542..a57f1cc 100644 --- a/src/core/tags/MenuTag.coffee +++ b/src/core/tags/MenuTag.coffee @@ -162,6 +162,9 @@ class MenuTag extends Ant.OS.GUI.BaseTag @setopt "items", [] @root.show = (e) -> me.showctxmenu e + @root.push = (e) -> me.push e + @root.remove = (e) -> me.remove e + @root.unshift = (e) -> me.unshift e handleselect: (e) -> $(@root).hide() if @isctxmenu() @@ -184,31 +187,54 @@ class MenuTag extends Ant.OS.GUI.BaseTag mount: () -> me = @ + $(@refs.container).css "display", "contents" return unless me.isctxmenu() - $(@refs.container).mouseleave (e) -> + $(@refs.wrapper).mouseleave (e) -> return unless me.is_root() $(me.root).hide() + __context__: (v) -> - $(@refs.container).removeClass("context") + $(@refs.wrapper).removeClass("context") return unless v - $(@refs.container).addClass("context") + $(@refs.wrapper).addClass("context") $(@root).hide() + unshift: (item) -> + @push item, true + + remove: (item) -> + el = item.get "data" + data = @get "items" + if data.includes el + data.splice data.indexOf(el), 1 + $(item).remove() + + push: (item, flag) -> + el = $("<#{@get("contentag")}>") + if flag + $(@refs.container).prepend el[0] + @get("items").unshift item + else + el.appendTo @refs.container + @get("items").push item + el[0].uify undefined + el[0].set "parent", @get("parent") + el[0].set "root", if @get("parent") then @get("parent").get("root") else @ + el[0].set "data", item + item.domel = el[0] + el[0] + __items__: (data) -> - me = @ $(@refs.container).empty() - $("
  • ").appendTo(@refs.container).addClass("afx-corner-fix") for item in data - el = $("<#{@get("contentag")}>").appendTo @refs.container - el[0].uify undefined - el[0].set "parent", me.get("parent") - el[0].set "root", if me.get("parent") then me.get("parent").get("root") else me - el[0].set "data", item - item.domel = el[0] - $("
  • ").appendTo(@refs.container).addClass("afx-corner-fix") + @push item, false layout: () -> - [{ el: "ul", ref: "container" }] + [{ el: "ul", ref: "wrapper", children: [ + { el: "li", class: "afx-corner-fix" }, + { el: "div", ref: "container" }, + { el: "li", class: "afx-corner-fix" } + ] }] Ant.OS.GUI.define "afx-menu", MenuTag Ant.OS.GUI.define "afx-menu-entry-proto", MenuEntryTag diff --git a/src/core/tags/OverlayTag.coffee b/src/core/tags/OverlayTag.coffee index c3e1d38..ff8bfe3 100644 --- a/src/core/tags/OverlayTag.coffee +++ b/src/core/tags/OverlayTag.coffee @@ -28,7 +28,6 @@ class OverlayTag extends Ant.OS.GUI.BaseTag } layout: () -> - [{ - el: "div", ref: "yield" - }] + @refs.yield = @root + [] Ant.OS.GUI.define "afx-overlay", OverlayTag \ No newline at end of file diff --git a/src/core/tags/SystemPanelTag.coffee b/src/core/tags/SystemPanelTag.coffee new file mode 100644 index 0000000..32a3f93 --- /dev/null +++ b/src/core/tags/SystemPanelTag.coffee @@ -0,0 +1,42 @@ +class SystemPanelTag extends Ant.OS.GUI.BaseTag + constructor: (r, o) -> + super r, o + me = @ + @setopt "osmenu", { children: [] } + @setopt "appmenu", [] + @setopt "systray", [] + @root.attachservice = (s) -> me.attachservice s + @root.detachservice = (s) -> me.detachservice s + + __osmenu__: (v) -> + @refs.osmenu.set "items", [v] + + __appmenu__: (v) -> + @refs.appmenu.set "items", v + + __systray__: (v) -> + @refs.systray.set "items", [v] + + attachservice: (s) -> + @refs.systray.unshift s + s.attach @refs.systray + + detachservice: (s) -> + @refs.systray.remove s + + layout: () -> + [{ + el: "div", children: [ + { el: "afx-menu", id: "osmenu", ref: "osmenu", class: "afx-panel-os-menu" }, + { el: "afx-menu", id: "appmenu", ref: "appmenu", class: "afx-panel-os-app" }, + { el: "afx-menu", id: "systray", ref: "systray", class: "afx-panel-os-stray" } + ] + }] + + mount: () -> + $(@refs.osmenu).css("z-index", 1000000) + $(@refs.appmenu).css("z-index", 1000000) + $(@refs.systray).css("z-index", 1000000) + Ant.OS.announcer.trigger("syspanelloaded") + +Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag \ No newline at end of file diff --git a/src/core/tags/tag.coffee b/src/core/tags/tag.coffee index d9817a2..64a19cd 100644 --- a/src/core/tags/tag.coffee +++ b/src/core/tags/tag.coffee @@ -77,6 +77,7 @@ class Ant.OS.GUI.BaseTag return undefined unless tag dom = $("<#{tag.el}>") $(dom).addClass tag.class if tag.class + $(dom).attr "data-id", tag.id if tag.id if tag.children $(@mkui(v)).appendTo(dom) for v in tag.children if tag.ref @@ -102,7 +103,7 @@ Element.prototype.mount = () -> Element.prototype.uify = (observable) -> @mkui(observable) - @sync() + @mount() Ant.OS.GUI.define = (name, cls) -> Ant.OS.GUI.tag[name] = cls diff --git a/src/packages/CoreServices/Calendar.coffee b/src/packages/CoreServices/Calendar.coffee index 8801e42..ca0f999 100644 --- a/src/packages/CoreServices/Calendar.coffee +++ b/src/packages/CoreServices/Calendar.coffee @@ -27,7 +27,8 @@ class Calendar extends this.OS.GUI.BaseService @watch 1000, () -> now = new Date me.text = now.toString() - me.update() + me.domel.set "text", me.text + awake: (e) -> @.openDialog "CalendarDialog", (d) -> @@ -38,4 +39,4 @@ class Calendar extends this.OS.GUI.BaseService console.log "cleanup for quit" # do nothing -this.OS.register "Calendar",Calendar \ No newline at end of file +this.OS.register "Calendar", Calendar \ No newline at end of file diff --git a/src/packages/CoreServices/PushNotification.coffee b/src/packages/CoreServices/PushNotification.coffee index f94a5ef..28da4b4 100644 --- a/src/packages/CoreServices/PushNotification.coffee +++ b/src/packages/CoreServices/PushNotification.coffee @@ -20,7 +20,6 @@ class PushNotification extends this.OS.GUI.BaseService constructor: (args) -> super "PushNotification", args @iconclass = "fa fa-bars" - @onmenuselect = (e) -> console.log e @cb = undefined @pending = [] init: -> @@ -45,7 +44,7 @@ class PushNotification extends this.OS.GUI.BaseService @mfeed = @find "notifeed" @nzone = @find "notifyzone" @fzone = @find "feedzone" - (@find "btclear").set "onbtclick", (e) -> me.mlist.set "items", [] + (@find "btclear").set "onbtclick", (e) -> me.mlist.set "data", [] #@subscribe "fail", (e) -> console.log e @subscribe "notification", (o) -> me.pushout 'INFO', o @subscribe "fail", (o) -> me.pushout 'FAIL', o @@ -64,15 +63,21 @@ class PushNotification extends this.OS.GUI.BaseService ($ @nzone).css "right", 0 .css "top", "-3px" - .css "height", "" + .css "height", "100%" .css "bottom", "0" .css "z-index", 1000000 + .css "display", "flex" + .css "flex-direction", "column" .hide() + ($ @mlist).css "flex", "1" ($ @fzone) #.css("z-index", 99999) .css("bottom", "0") - .css("height", "") + .css("height", "100%") + .css "display", "flex" + .css "flex-direction", "column" .hide() + ($ @mfeed).css "flex", "1" pushout: (s, o, mfeed) -> d = { @@ -82,7 +87,7 @@ class PushNotification extends this.OS.GUI.BaseService closable: true } #console.log o.data.s #console.log o.data.e - @mlist.unshift d, true + @mlist.unshift d @notifeed d notifeed: (d) -> @@ -90,18 +95,17 @@ class PushNotification extends this.OS.GUI.BaseService @mfeed.unshift d, true ($ @fzone).show() timer = setTimeout () -> - me.mfeed.remove d, true + me.mfeed.remove d.domel clearTimeout timer , 3000 - awake: (e) -> + awake: (evt) -> if @view then ($ @nzone).hide() else ($ @nzone).show() @view = not @view me = @ if not @cb @cb = (e) -> - return if e.originalEvent.item and e.originalEvent.item.i isnt undefined - if not ($ e.target).closest($ me.nzone).length and not ($ e.target).closest($ me.holder.root).length + if not ($ e.target).closest($ me.nzone).length and not ($ e.target).closest(evt.data.item).length ($ me.nzone).hide() $(document).unbind "click", me.cb me.view = not me.view @@ -113,15 +117,15 @@ class PushNotification extends this.OS.GUI.BaseService cleanup: (evt) -> # do nothing PushNotification.scheme = """ - + - + - + """ -this.OS.register "PushNotification",PushNotification \ No newline at end of file +this.OS.register "PushNotification", PushNotification \ No newline at end of file diff --git a/src/packages/CoreServices/Spotlight.coffee b/src/packages/CoreServices/Spotlight.coffee index 24cd08d..e234952 100644 --- a/src/packages/CoreServices/Spotlight.coffee +++ b/src/packages/CoreServices/Spotlight.coffee @@ -37,7 +37,7 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog ($ document).keyup @fn @fn1 = (e) -> - return if $(e.target).closest(me.parent.holder.root).length + return if $(e.target).closest(me.parent.holder).length if not $(e.target).closest(me.scheme).length ($ document).unbind "click", me.fn1 ($ document).unbind "keyup", me.fn @@ -49,7 +49,7 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog ($ @searchbox).focus() ($ @searchbox).keyup (e) -> me.search e - @container.set "onlistdbclick", (e)-> + @container.set "onlistdbclick", (e) -> return if e.data.dataid and e.data.dataid is "header" me.handler(e) if me.handler me._gui.openWith e.data @@ -86,11 +86,14 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog return unless text.length >= 3 result = @_api.search text return if result.length is 0 - @container.set "items", result + @container.set "data", result + console.log result ($ @scheme).css("height", @height) SpotlightDialog.scheme = """ - +
    @@ -99,7 +102,7 @@ SpotlightDialog.scheme = """
    -""" +""" this.OS.register "SpotlightDialog", SpotlightDialog class Spotlight extends this.OS.GUI.BaseService @@ -111,13 +114,7 @@ class Spotlight extends this.OS.GUI.BaseService me = @ @_gui.bindKey "CTRL- ", (e) -> me.awake(e) - #@child = [ - # { - # text: "#{@.name} (#{@.pid}): dummy notif", - # child: [ { text: "submenu" } ] - # } - #] - # do nothing + main: -> awake: (e) -> @@ -134,4 +131,4 @@ class Spotlight extends this.OS.GUI.BaseService cleanup: (evt) -> # do nothing -this.OS.register "Spotlight",Spotlight \ No newline at end of file +this.OS.register "Spotlight", Spotlight \ No newline at end of file diff --git a/src/packages/CoreServices/UserService.coffee b/src/packages/CoreServices/UserService.coffee index 33b95eb..573b30f 100644 --- a/src/packages/CoreServices/UserService.coffee +++ b/src/packages/CoreServices/UserService.coffee @@ -19,26 +19,27 @@ class UserService extends this.OS.GUI.BaseService constructor: (args) -> super "UserService", args - @text =@systemsetting.user.username + @text = @systemsetting.user.username @iconclass = undefined - init: -> me = @ - @child = [ + @children = [ { text: "__(About)", dataid: "user-about", iconclass: "fa fa-user-circle-o" }, { text: "__(Logout)", dataid: "sys-logout", - iconclass: "fa fa-user-times" + iconclass: "fa fa-user-times", + onmenuselect: (d) -> + me.notify __("This feature is not implemented yet") } ] - @onmenuselect = (d) -> - return window.OS.exit() if d.item.data.dataid is "sys-logout" - me.notify __("This feature is not implemented yet") + + init: -> + awake: (e) -> cleanup: (evt) -> -this.OS.register "UserService",UserService \ No newline at end of file +this.OS.register "UserService", UserService \ No newline at end of file diff --git a/src/packages/ShowCase/coffees/main.coffee b/src/packages/ShowCase/coffees/main.coffee index 59cb097..889f223 100644 --- a/src/packages/ShowCase/coffees/main.coffee +++ b/src/packages/ShowCase/coffees/main.coffee @@ -65,7 +65,7 @@ class ShowCase extends this.OS.GUI.BaseApplication - + diff --git a/src/themes/antos/afx-float-list.css b/src/themes/antos/afx-float-list.css index d15c00d..4ce7599 100644 --- a/src/themes/antos/afx-float-list.css +++ b/src/themes/antos/afx-float-list.css @@ -1,11 +1,11 @@ -afx-float-list1 div.list-container > ul{ +afx-float-list div.list-container > ul{ padding: 0; margin: 0; background-color: transparent; } -afx-float-list1 div.list-container > ul li{ +afx-float-list div.list-container > ul li{ padding: 0; margin: 0; background-color: transparent; diff --git a/src/themes/antos/afx-label.css b/src/themes/antos/afx-label.css index 749f66d..13c9389 100644 --- a/src/themes/antos/afx-label.css +++ b/src/themes/antos/afx-label.css @@ -2,5 +2,5 @@ afx-label i.icon-style { width: 16px; height: 16px; display: inline-block; - float:left; + float: left; } \ No newline at end of file diff --git a/src/themes/antos/afx-menu.css b/src/themes/antos/afx-menu.css index 70b250e..fc53133 100644 --- a/src/themes/antos/afx-menu.css +++ b/src/themes/antos/afx-menu.css @@ -2,7 +2,7 @@ afx-menu { position:relative; display:inline-block; - /*z-index: 100000;*/ + z-index: 100000; } afx-menu a{ text-decoration: none; @@ -54,15 +54,16 @@ afx-menu ul li /*, afx-menu ul >afx-menu-entry > li*/{ padding:3px; padding-left: 5px; padding-right: 5px; + cursor:default; } -afx-menu ul > li.fix_padding{ +afx-menu ul li.fix_padding{ padding-top:1px; padding-bottom: 0; padding-left: 5px; padding-right: 5px; } -afx-menu afx-menu ul > li.fix_padding{ +afx-menu afx-menu ul li.fix_padding{ padding:3px; padding-left: 5px; padding-right: 5px; @@ -79,6 +80,7 @@ afx-menu afx-menu i{ afx-menu afx-menu li{ float:none; min-width: 150px; + cursor:default; } afx-menu afx-menu afx-menu, afx-menu ul.context afx-menu{ top:-4px;