bugfic
This commit is contained in:
parent
7bfabb51ce
commit
6b1a844abc
@ -10,21 +10,20 @@ bricks.IconBar = class extends bricks.HBox {
|
|||||||
name:
|
name:
|
||||||
icon:
|
icon:
|
||||||
rate:
|
rate:
|
||||||
|
dynsize:
|
||||||
tip
|
tip
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
|
opts.height = opts.height || 'auto';
|
||||||
super(opts);
|
super(opts);
|
||||||
|
this.set_style('height', 'auto');
|
||||||
var tools = this.opts.tools;
|
var tools = this.opts.tools;
|
||||||
|
this.height_int = 0;
|
||||||
for (var i=0;i<tools.length;i++){
|
for (var i=0;i<tools.length;i++){
|
||||||
var rate = this.opts.rate || 1;
|
var w = this.build_item(tools[i]);
|
||||||
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');
|
w.set_style('margin', this.opts.margin || '10px');
|
||||||
if (tools[i].name){
|
if (tools[i].name){
|
||||||
w.widget_id = tools[i].name;
|
w.widget_id = tools[i].name;
|
||||||
@ -33,6 +32,22 @@ bricks.IconBar = class extends bricks.HBox {
|
|||||||
w.bind('click', this.regen_event.bind(this,tools[i]))
|
w.bind('click', this.regen_event.bind(this,tools[i]))
|
||||||
this.add_widget(w);
|
this.add_widget(w);
|
||||||
}
|
}
|
||||||
|
this.set_style('height', this.height_int + 'px');
|
||||||
|
}
|
||||||
|
build_item(opts){
|
||||||
|
var rate = this.opts.rate || 1;
|
||||||
|
var desc = {
|
||||||
|
url:opts.icon,
|
||||||
|
rate:opts.rate || rate,
|
||||||
|
dynsize:opts.dynsize||true,
|
||||||
|
tip:opts.tip
|
||||||
|
};
|
||||||
|
var h = bricks.app.charsize * rate;
|
||||||
|
if (this.height_int < h){
|
||||||
|
this.height_int = h;
|
||||||
|
}
|
||||||
|
var w = new bricks.Icon(desc);
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
regen_event(desc, event){
|
regen_event(desc, event){
|
||||||
this.dispatch(desc.name, desc);
|
this.dispatch(desc.name, desc);
|
||||||
@ -41,17 +56,62 @@ bricks.IconBar = class extends bricks.HBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bricks.IconTextBar = class extends bricks.IconBar {
|
||||||
|
build_item(opts){
|
||||||
|
var rate = opts.rate || this.opts.rate || 1;
|
||||||
|
var o = {
|
||||||
|
width:'auto',
|
||||||
|
height:'auto',
|
||||||
|
cheight:1.3 * rate
|
||||||
|
};
|
||||||
|
if (opts.tip){
|
||||||
|
o.tip = opts.tip;
|
||||||
|
}
|
||||||
|
var box = new bricks.HBox(o);
|
||||||
|
if (opts.icon){
|
||||||
|
var desc = {
|
||||||
|
url:opts.icon,
|
||||||
|
rate:opts.rate || rate,
|
||||||
|
dynsize:opts.dynsize||true
|
||||||
|
};
|
||||||
|
var w = new bricks.Icon(desc);
|
||||||
|
box.add_widget(w);
|
||||||
|
}
|
||||||
|
if (opts.label){
|
||||||
|
var desc = {
|
||||||
|
otext:opts.label,
|
||||||
|
i18n:true,
|
||||||
|
wrap:true,
|
||||||
|
haligh:'left',
|
||||||
|
rate:opts.rate || rate,
|
||||||
|
dynsize:opts.dynsize||true
|
||||||
|
};
|
||||||
|
var w = new bricks.Text(desc);
|
||||||
|
box.add_widget(w);
|
||||||
|
}
|
||||||
|
var h = bricks.app.charsize * rate;
|
||||||
|
if (this.height_int < h){
|
||||||
|
this.height_int = h;
|
||||||
|
}
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
}
|
||||||
bricks.FloatIconBar = class extends bricks.HBox {
|
bricks.FloatIconBar = class extends bricks.HBox {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
opts.height = opts.height || "auto";
|
|
||||||
super(opts);
|
super(opts);
|
||||||
this.float_w = new bricks.Icon({url:bricks_resource('imgs/float-out.png')});
|
this.float_w = new bricks.Icon({url:bricks_resource('imgs/float-out.png')});
|
||||||
this.float_w.set_style('margin', '10px');
|
this.float_w.set_style('margin', '10px');
|
||||||
this.float_w.bind('mousemove', this.show_icons.bind(this));
|
this.float_w.bind('mousemove', this.show_icons.bind(this));
|
||||||
this.add_widget(this.float_w);
|
this.add_widget(this.float_w);
|
||||||
this.icons_box = new bricks.IconBar(opts);
|
this.icons_box = this.build_bar(opts);
|
||||||
|
this.add_widget(this.icons_box);
|
||||||
|
this.hide_icons()
|
||||||
|
this.set_style('height', this.icons_box.height_int + 'px')
|
||||||
bricks.Body.bind('click', this.hide_icons.bind(this));
|
bricks.Body.bind('click', this.hide_icons.bind(this));
|
||||||
}
|
}
|
||||||
|
build_bar(opts){
|
||||||
|
return new bricks.IconBar(opts);
|
||||||
|
}
|
||||||
show_icons(){
|
show_icons(){
|
||||||
this.icons_box.set_style('display', 'flex');
|
this.icons_box.set_style('display', 'flex');
|
||||||
}
|
}
|
||||||
@ -60,5 +120,13 @@ bricks.FloatIconBar = class extends bricks.HBox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bricks.FloatIconTextBar = class extends bricks.FloatIconBar {
|
||||||
|
build_bar(opts){
|
||||||
|
return new bricks.IconTextBar(opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bricks.Factory.register('IconBar', bricks.IconBar);
|
bricks.Factory.register('IconBar', bricks.IconBar);
|
||||||
|
bricks.Factory.register('IconTextBar', bricks.IconTextBar);
|
||||||
bricks.Factory.register('FloatIconBar', bricks.FloatIconBar);
|
bricks.Factory.register('FloatIconBar', bricks.FloatIconBar);
|
||||||
|
bricks.Factory.register('FloatIconTextBar', bricks.FloatIconTextBar);
|
||||||
|
@ -34,7 +34,7 @@ bricks.Image = class oops extends bricks.JsWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bricks.Icon = class oops extends bricks.Image {
|
bricks.Icon = class extends bricks.Image {
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
var rate = opts.rate || 1;
|
var rate = opts.rate || 1;
|
||||||
var siz = bricks.app.charsize * rate + 'px';
|
var siz = bricks.app.charsize * rate + 'px';
|
||||||
|
BIN
examples/.form.ui.swp
Normal file
BIN
examples/.form.ui.swp
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user