add float list

This commit is contained in:
mrsang 2020-04-27 18:50:52 +02:00
parent 8a441e5a59
commit c46049fd0c
7 changed files with 118 additions and 18 deletions

View File

@ -40,6 +40,7 @@ coffees= src/core/core.coffee \
src/core/tags/TabContainer.coffee \ src/core/tags/TabContainer.coffee \
src/core/tags/TreeViewTag.coffee \ src/core/tags/TreeViewTag.coffee \
src/core/tags/SliderTag.coffee \ src/core/tags/SliderTag.coffee \
src/core/tags/FloatListTag.coffee \
src/antos.coffee src/antos.coffee

View File

@ -0,0 +1,14 @@
class CalendarTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
layout: () ->
[{
el: "div", children: [
{ el: "i", class: "prevmonth", ref: "prev" },
{ el: "afx-label", ref: "mlbl" },
{ el: "afx-label", ref: "ylbl" },
{ el: "i", class: "nextmonth", ref: "next" },
{ el: "afx-grid-view", ref: "grid" }
]
}]

View File

@ -2,24 +2,87 @@ class FloatListTag extends ListViewTag
constructor: (r, o) -> constructor: (r, o) ->
super r, o super r, o
me = @ me = @
@root.refresh = () -> @setopt "dir", "horizontal"
me.refresh() @root.refresh = () -> me.refresh()
@root.push = (e) -> me.refs.mlist.push(e)
@root.unshift = (e) -> me.refs.mlist.unshift(e)
@root.remove = (e) -> me.refs.mlist.remove(e)
# disable some uneccessary functions # disable some uneccessary functions
__dropdown__: (v) -> __dropdown__: (v) -> @set "dropdown", false if v
@set "dropdown", false if v
__buttons__: (v) -> __buttons__: (v) ->
showlist: (e) -> showlist: (e) ->
dropoff: (e) -> dropoff: (e) ->
calibrate: (e) -> __data__: (v) ->
super.__data__(v)
@refresh() @refresh()
__dir__: (v) ->
@refresh()
calibrate: (e) -> @refresh()
mount: () -> mount: () ->
@refresh() $(@refs.container)
.css "width", "100%"
.css "height", "100%"
$(@refs.mlist)
.css "position", "absolute"
.css "display", "block"
.css "width", "100%"
push: (v) ->
el = super.push(v)
@enable_drag el
el
enable_drag: (el) ->
globalof = $(@refs.mlist).offset()
$(el)
.css "user-select", "none"
.css "cursor", "default"
.css "display", "block"
.css "position", "absolute"
.on "mousedown", (evt) ->
evt.preventDefault()
offset = $(el).offset()
offset.top = evt.clientY - offset.top
offset.left = evt.clientX - offset.left
mouse_move = (e) ->
top = e.clientY - offset.top - globalof.top
left = e.clientX - globalof.top - offset.left
left = if left < 0 then 0 else left
top = if top < 0 then 0 else top
$(el)
.css "top", "#{top}px"
.css "left", "#{left}px"
mouse_up = (e) ->
$(window).unbind "mousemove", mouse_move
$(window).unbind "mouseup", mouse_up
$(window).on "mousemove", mouse_move
$(window).on "mouseup", mouse_up
refresh: () -> refresh: () ->
ctop = 20
cleft = 20
$(@refs.mlist)
.css "height", "#{$(@refs.container).height()}px"
gw = $(@refs.mlist).width()
gh = $(@refs.mlist).height()
me = @
$(@refs.mlist).children().each (e) ->
$(@)
.css "top", "#{ctop}px"
.css "left", "#{cleft}px"
w = $(@).width()
h = $(@).height()
if me.get("dir") is "vertical"
ctop += h + 20
if ctop > gh
ctop = 20
cleft += w + 20
else
cleft += w + 20
if cleft > gw
cleft = 20
ctop += h + 20
Ant.OS.GUI.define "afx-float-list1", FloatListTag
layout: () ->
[{
el: "div", ref: "mlist"
}]

View File

@ -160,6 +160,11 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
mount: () -> mount: () ->
me = @ me = @
$(@root)
.css "overflow", "hidden"
.css "display", "block"
.css "padding", "5px"
$(@refs.grid).css "display", "grid" $(@refs.grid).css "display", "grid"
$(@refs.header).css "display", "grid" $(@refs.header).css "display", "grid"
@observable.on "resize", (e) -> me.calibrate() @observable.on "resize", (e) -> me.calibrate()

View File

@ -70,7 +70,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
</afx-hbox> </afx-hbox>
<afx-hbox title="Virtual desktop"> <afx-hbox title="Virtual desktop">
<div data-height="200">desktop</div> <afx-float-list1 data-id = "flist"/>
</afx-hbox> </afx-hbox>
</afx-tab-container> </afx-tab-container>
@ -198,6 +198,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
slider[0].set "onchanging", (v) -> slider[0].set "onchanging", (v) ->
console.log v console.log v
list = $ "[data-id='flist']", scheme[0]
list[0].set "data", [
{ text: "File.txt" },
{ text: "FileB.doc" },
{ text: "Data.doc", iconclass: "fa fa-camera-retro fa-lg" }
]
mnFile: () -> mnFile: () ->
#console.log file #console.log file
me = @ me = @

View File

@ -0,0 +1,14 @@
afx-float-list1 div.list-container > ul{
padding: 0;
margin: 0;
background-color: transparent;
}
afx-float-list1 div.list-container > ul li{
padding: 0;
background-color: transparent;
list-style: none;
max-width: 100px;
}

View File

@ -1,8 +1,3 @@
afx-grid-view{
overflow: hidden;
padding:5px;
display: block;
}
afx-grid-view afx-grid-row div{ afx-grid-view afx-grid-row div{
padding:3px; padding:3px;
padding-left: 5px; padding-left: 5px;