From 7362792c380114c774fd01120c978360e81360d3 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Sun, 9 Dec 2007 22:24:30 +0000 Subject: initial --- qooxdoo/source/class/Smokeping/ui/Mover.js | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 qooxdoo/source/class/Smokeping/ui/Mover.js (limited to 'qooxdoo/source/class/Smokeping/ui/Mover.js') diff --git a/qooxdoo/source/class/Smokeping/ui/Mover.js b/qooxdoo/source/class/Smokeping/ui/Mover.js new file mode 100644 index 0000000..f212708 --- /dev/null +++ b/qooxdoo/source/class/Smokeping/ui/Mover.js @@ -0,0 +1,110 @@ +/* ************************************************************************ +#module(Smokeping) +************************************************************************ */ + +/** + * Lets you do google map like draging of the graph canvas along time axis + * + */ + +qx.Class.define('Smokeping.ui.Mover', +{ + extend: qx.ui.layout.CanvasLayout, + include: Smokeping.ui.MPosition, + + /* + ***************************************************************************** + CONSTRUCTOR + ***************************************************************************** + */ + + /** + * @param target {Widget} What surface should we base our selection on + * + * @param width {Integer} Width of the 'interesting' area of the target + * + * @param height {Integer} Height ot the 'interesting' area of the target + * + * @param right {Integer} Distance from the right edge + * + * @param top {Integer} Distance from the top + * + * The zoomer will not activate if the ctrl key is pressed. This allows + * for the Mover to act on these events + * + */ + + construct: function (target,src,width,height,top,right,start,end) { + this._target = target; + this._width = width; + this._src = src; + this._height = height; // some where the calc is 1 off. this fixes it + this._top = top; + this._right = right; + with(this){ + base(arguments); + set({ + width: width, + height: height+17, + top: top-2, + right: right, + visibility: false, + overflow: 'hidden', + backgroundColor: 'white' + }); + } + // make the canvas large + + this._moveing = false; + this._target.addEventListener("mousedown", this._move_start,this); + this._target.addEventListener("mousemove", this._move_move,this); + this._target.addEventListener("mouseup", this._move_end,this); + }, + + members: { + _move_start: function(e){ + if (!e.isCtrlPressed()) return; + this._init_cache(); + this._moveing = true; + this._start_x = e.getPageX(); + this._target.setCapture(true); + this.removeAll(); + for (var i=0;i<4;i++){ + var duration = (this._end-this._start); + var tile = new qx.ui.basic.Image(); + tile.set({ + top: -(this._top-2), + left: -this._canvas_left, + clipTop: this._top-2, + clipLeft: this._canvas_left, + clipWidth: this._width, + width: this._width, + height: this._height+17, + left: this._width * i, + source: this._src+';w='+this._width+';h='+this._height+';s='+(this._start+(duration*(i-2)))+'e='+(this._end+(duration*(i-2))) + }); + this.add(tile); + } + this.setScrollLeft(2*this._width); + this.setVisibility(true); + this._move_move(e); + }, + + _move_move: function(e){ + if (this._target.getCapture() && this._moveing ){ + var drag_x = e.getPageX() - this._start_x; + this.setScrollLeft(-drag_x+this._width*2); + } + }, + _move_end: function(e){ + if (!this._moveing) return; + this._moveing = false; + this._target.setCapture(false); + this.setVisibility(false); + } + } + + +}); + + -- cgit v1.2.3-24-g4f1b