タブバー上でのドラッグで自動スクロールするように

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4050 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-04-06 17:47:57 +00:00
parent f2805baac8
commit a9d5dbfcf0
2 changed files with 88 additions and 53 deletions

View File

@ -1110,6 +1110,8 @@ catch(e) {
var TSTTabBrowser = this;
if ((function(aSelf) {
try{
if (TSTTabBrowser.treeStyleTab.processAutoScroll(aEvent)) return true;
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
if (!info.target || info.target != TreeStyleTabService.evaluateXPath(

View File

@ -30,8 +30,8 @@ TreeStyleTabBrowser.prototype = {
sizeProp : 'height',
invertedPositionProp : 'screenX',
invertedSizeProp : 'width',
togglerSize : 0,
togglerSize : 0,
sensitiveArea : 7,
get browser()
@ -1062,13 +1062,13 @@ TreeStyleTabBrowser.prototype = {
}, 0, this);
break;
case 'extensions.treestyletab.tabbar.autoShow.mousemove':
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
case 'extensions.treestyletab.tabbar.autoShow.feedback':
if (this.autoHideEnabled && this.shouldListenMouseMove)
this.startListenMouseMove();
case 'extensions.treestyletab.tabbar.autoShow.mousemove':
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
case 'extensions.treestyletab.tabbar.autoShow.feedback':
if (this.autoHideEnabled && this.shouldListenMouseMove)
this.startListenMouseMove();
else
this.endListenMouseMove();
this.endListenMouseMove();
break;
case 'extensions.treestyletab.tabbar.fixed':
@ -1092,8 +1092,8 @@ TreeStyleTabBrowser.prototype = {
break;
case 'extensions.treestyletab.tabbar.togglerSize':
this.togglerSize = value;
var toggler = document.getAnonymousElementByAttribute(b, 'class', this.kTABBAR_TOGGLER);
this.togglerSize = value;
var toggler = document.getAnonymousElementByAttribute(b, 'class', this.kTABBAR_TOGGLER);
toggler.style.minWidth = toggler.style.minHeight = value+'px';
break;
@ -2579,6 +2579,39 @@ TreeStyleTabBrowser.prototype = {
var tabsInfo = this.getDraggedTabsInfoFromOneTab(actionInfo, aTab);
return tabsInfo.draggedTabs.length == this.getTabs(this.mTabBrowser).snapshotLength;
},
processAutoScroll : function(aEvent)
{
var tabs = this.mTabBrowser.mTabContainer;
if (tabs.getAttribute('overflow') != 'true') return false;
var tabStrip = tabs.mTabstrip;
var pixels = tabStrip.scrollIncrement;
var box = tabs.boxObject;
if (this.isVertical) {
if (aEvent.screenY < box.screenY + this.autoScrollArea) {
pixels *= -1;
}
else if (aEvent.screenY < box.screenY + box.height - this.autoScrollArea) {
return false;
}
}
else {
var ltr = window.getComputedStyle(this.parentNode, null).direction == 'ltr';
if (aEvent.screenX < box.screenX + this.autoScrollArea) {
pixels *= -1;
}
else if (aEvent.screenX < box.screenX + box.width - this.autoScrollArea) {
return false;
}
pixels = (ltr ? 1 : -1) * pixels;
}
tabStrip.scrollByPixels(pixels);
aEvent.preventDefault();
aEvent.stopPropagation();
return true;
},
autoScrollArea : 20,
/* commands */
@ -3252,12 +3285,12 @@ TreeStyleTabBrowser.prototype = {
{
switch (this.autoHideMode)
{
case this.kAUTOHIDE_MODE_HIDE:
case this.kAUTOHIDE_MODE_HIDE:
let offset = this.tabbarWidth + this.splitterWidth;
if (this.mTabBrowser.getAttribute(this.kTABBAR_POSITION) == 'left' &&
this.autoHideMode == this.kAUTOHIDE_MODE_HIDE) {
offset -= this.togglerSize;
}
if (this.mTabBrowser.getAttribute(this.kTABBAR_POSITION) == 'left' &&
this.autoHideMode == this.kAUTOHIDE_MODE_HIDE) {
offset -= this.togglerSize;
}
return offset;
break;
@ -3314,7 +3347,7 @@ TreeStyleTabBrowser.prototype = {
else { // to be shown or expanded
switch (b.getAttribute(this.kTABBAR_POSITION))
{
case 'left':
case 'left':
this.container.style.marginRight = '-'+this.autoHideXOffset+'px';
break;
case 'right':
@ -3385,7 +3418,7 @@ TreeStyleTabBrowser.prototype = {
try {
var v = this.mTabBrowser.markupDocumentViewer;
if (this.autoHideEnabled && this.autoHideShown) {
v.move(window.outerWidth,window.outerHeight);
v.move(window.outerWidth,window.outerHeight);
v.move(
(
!this.autoHideShown ? 0 :
@ -3430,9 +3463,9 @@ TreeStyleTabBrowser.prototype = {
var zoom = this.getZoomForFrame(frame);
var x = (pos == 'right') ? browserBox.width - this.autoHideXOffset : 0 ;
var y = (pos == 'bottom') ? browserBox.height - this.autoHideYOffset : 0 ;
if (pos == 'left' && this.autoHideMode == this.kAUTOHIDE_MODE_HIDE)
x -= this.togglerSize;
var y = (pos == 'bottom') ? browserBox.height - this.autoHideYOffset : 0 ;
if (pos == 'left' && this.autoHideMode == this.kAUTOHIDE_MODE_HIDE)
x -= this.togglerSize;
var xOffset = (zoom == 1 && (pos == 'top' || pos == 'bottom')) ?
contentBox.screenX + frame.scrollX - browserBox.screenX :
0 ;
@ -3448,13 +3481,13 @@ TreeStyleTabBrowser.prototype = {
{
let style = window.getComputedStyle(node, null);
'border-left-width,border-right-width,margin-left,margin-right,padding-left,padding-right'
.split(',').forEach(function(aProperty) {
.split(',').forEach(function(aProperty) {
let value = parseInt(style.getPropertyValue(aProperty).replace('px', ''));
w -= value;
w -= value;
if (aProperty.indexOf('left') < -1) x += value;
});
'border-top-width,border-bottom-width,margin-top,margin-bottom,padding-left,padding-right'
.split(',').forEach(function(aProperty) {
.split(',').forEach(function(aProperty) {
let value = parseInt(style.getPropertyValue(aProperty).replace('px', ''));
h -= value;
if (aProperty.indexOf('top') < -1) y += value;
@ -3611,8 +3644,8 @@ TreeStyleTabBrowser.prototype = {
this.mTabBrowser.removeEventListener('resize', this, true);
this.mTabBrowser.removeEventListener('load', this, true);
this.mTabBrowser.mPanelContainer.removeEventListener('scroll', this, true);
this.endListenMouseMove();
if (this.mTabBrowser == gBrowser)
this.endListenMouseMove();
if (this.mTabBrowser == gBrowser)
TreeStyleTabService.endListenKeyEvents();
this.clearTabbarCanvas();
@ -3638,13 +3671,13 @@ TreeStyleTabBrowser.prototype = {
this.mouseMoveListening = false;
},
mouseMoveListening : false,
get shouldListenMouseMove()
{
return this.getTreePref('tabbar.autoShow.mousemove') ||
get shouldListenMouseMove()
{
return this.getTreePref('tabbar.autoShow.mousemove') ||
this.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.getTreePref('tabbar.autoShow.tabSwitch') ||
this.getTreePref('tabbar.autoShow.feedback');
},
this.getTreePref('tabbar.autoShow.tabSwitch') ||
this.getTreePref('tabbar.autoShow.feedback');
},
showHideTabbarOnMousemove : function(aEvent)
{
@ -3654,7 +3687,7 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
var pos = b.getAttribute(this.kTABBAR_POSITION);
var box = b.mCurrentBrowser.boxObject;
var box = b.mCurrentBrowser.boxObject;
var shouldKeepShown = (
pos == 'left' ?
(aEvent.screenX <= box.screenX + this.sensitiveArea) :
@ -3663,20 +3696,20 @@ TreeStyleTabBrowser.prototype = {
pos == 'bottom' ?
(aEvent.screenY >= box.screenY + box.height - this.sensitiveArea) :
(aEvent.screenY <= box.screenY + this.sensitiveArea)
);
if (this.autoHideShown) {
if (
shouldKeepShown &&
this.showHideTabbarReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
this.getTreePref('tabbar.autoShow.keepShownOnMouseover')
) {
);
if (this.autoHideShown) {
if (
shouldKeepShown &&
this.showHideTabbarReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
this.getTreePref('tabbar.autoShow.keepShownOnMouseover')
) {
this.showHideTabbarReason = this.kSHOWN_BY_MOUSEMOVE;
this.cancelDelayedAutoShowForShortcut();
this.cancelHideTabbarForFeedback();
}
else if (
!shouldKeepShown &&
this.getTreePref('tabbar.autoShow.mousemove')
this.cancelDelayedAutoShowForShortcut();
this.cancelHideTabbarForFeedback();
}
else if (
!shouldKeepShown &&
this.getTreePref('tabbar.autoShow.mousemove')
) {
this.showHideTabbarOnMousemoveTimer = window.setTimeout(
function(aSelf) {
@ -3686,27 +3719,27 @@ TreeStyleTabBrowser.prototype = {
},
this.getTreePref('tabbar.autoHide.delay'),
this
);
}
}
else if (
);
}
}
else if (
pos == 'left' ?
(aEvent.screenX <= box.screenX + this.sensitiveArea) :
pos == 'right' ?
(aEvent.screenX >= box.screenX + box.width - this.sensitiveArea) :
pos == 'bottom' ?
(aEvent.screenY >= box.screenY + box.height - this.sensitiveArea) :
(aEvent.screenY <= box.screenY + this.sensitiveArea)
) {
(aEvent.screenY <= box.screenY + this.sensitiveArea)
) {
this.showHideTabbarOnMousemoveTimer = window.setTimeout(
function(aSelf) {
aSelf.cancelDelayedAutoShowForShortcut();
aSelf.cancelDelayedAutoShowForShortcut();
aSelf.cancelHideTabbarForFeedback();
aSelf.showTabbar(aSelf.kSHOWN_BY_MOUSEMOVE);
},
this.getTreePref('tabbar.autoHide.delay'),
this
);
);
}
},
showHideTabbarOnMousemoveTimer : null,