This commit is contained in:
yumoqing 2024-03-14 08:42:01 +08:00
parent e2268a518d
commit 7bfabb51ce

64
bricks/floaticonbar.js Normal file
View File

@ -0,0 +1,64 @@
var bricks = window.bricks || {};
bricks.IconBar = class extends bricks.HBox {
/*
{
margin:
rate:
tools:[
{
name:
icon:
rate:
tip
}
]
}
*/
constructor(opts){
super(opts);
var tools = this.opts.tools;
for (var i=0;i<tools.length;i++){
var rate = this.opts.rate || 1;
var w = new bricks.Icon({
url:tools[i].icon,
rate:tools[i].rate || rate,
tip:tools[i].tip
});
w.set_style('margin', this.opts.margin || '10px');
if (tools[i].name){
w.widget_id = tools[i].name;
}
w.set_style('cursor', 'pointer');
w.bind('click', this.regen_event.bind(this,tools[i]))
this.add_widget(w);
}
}
regen_event(desc, event){
this.dispatch(desc.name, desc);
this.dispatch('command', desc);
event.stopPropagation();
}
}
bricks.FloatIconBar = class extends bricks.HBox {
constructor(opts){
opts.height = opts.height || "auto";
super(opts);
this.float_w = new bricks.Icon({url:bricks_resource('imgs/float-out.png')});
this.float_w.set_style('margin', '10px');
this.float_w.bind('mousemove', this.show_icons.bind(this));
this.add_widget(this.float_w);
this.icons_box = new bricks.IconBar(opts);
bricks.Body.bind('click', this.hide_icons.bind(this));
}
show_icons(){
this.icons_box.set_style('display', 'flex');
}
hide_icons(){
this.icons_box.set_style('display', 'none');
}
}
bricks.Factory.register('IconBar', bricks.IconBar);
bricks.Factory.register('FloatIconBar', bricks.FloatIconBar);