幅を半分にする機能

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@2643 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2008-06-17 01:21:41 +00:00
parent 710138f209
commit 56717087cc
3 changed files with 126 additions and 54 deletions

View File

@ -63,7 +63,12 @@ var TreeStyleTabService = {
kTRANSPARENT_NONE : 0,
kTRANSPARENT_PART : 1,
kTRANSPARENT_FULL : 2,
kTRANSPARENT_STYLE : ['none', 'part', 'full'],
kTRANSPARENT_STYLE : ['none', 'part', 'full'],
kAUTOHIDE_MODE_DISABLED : 0,
kAUTOHIDE_MODE_HIDE : 1,
kAUTOHIDE_MODE_SHRINK : 2,
autoHideMode : 0,
kINSERT_FISRT : 0,
kINSERT_LAST : 1,
@ -470,8 +475,11 @@ var TreeStyleTabService = {
toggleAutoHide : function()
{
this.setTreePref('tabbar.autoHide.enabled',
!this.getTreePref('tabbar.autoHide.enabled'));
this.setTreePref('tabbar.autoHide.mode',
this.getTreePref('tabbar.autoHide.mode') == this.kAUTOHIDE_MODE_DISABLED ?
this.getTreePref('tabbar.autoHide.mode.toggle') :
this.kAUTOHIDE_MODE_DISABLED
);
},
toggleFixed : function()
@ -815,7 +823,7 @@ var TreeStyleTabService = {
this.overrideExtensionsOnInitAfter(); // hacks.js
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin');
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.autoHide.enabled');
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.autoHide.mode');
this.observe(null, 'nsPref:changed', 'browser.link.open_newwindow.restriction.override');
this.observe(null, 'nsPref:changed', 'browser.tabs.loadFolderAndReplace.override');
},
@ -1376,11 +1384,13 @@ catch(e) {
onTabbarResized : function(aEvent)
{
this.setPref(
'extensions.treestyletab.tabbar.width',
TreeStyleTabService.getTabBrowserFromChild(aEvent.currentTarget)
.mStrip.boxObject.width
);
var b = this.getTabBrowserFromChild(aEvent.currentTarget);
if (b.treeStyleTab.tabbarShrunken) {
this.setTreePref('tabbar.shrunkenWidth', b.mStrip.boxObject.width);
}
else {
this.setTreePref('tabbar.width', b.mStrip.boxObject.width);
}
},
initContextMenu : function()
@ -1630,12 +1640,13 @@ catch(e) {
this.ObserverService.notifyObservers(null, 'TreeStyleTab:levelMarginModified', value);
break;
case 'extensions.treestyletab.tabbar.autoHide.enabled':
case 'extensions.treestyletab.tabbar.autoHide.mode':
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
case 'extensions.treestyletab.tabbar.autoShow.tabSwitch':
case 'extensions.treestyletab.tabbar.autoShow.feedback':
this.autoHideMode = this.getTreePref('tabbar.autoHide.mode');
if (
this.getTreePref('tabbar.autoHide.enabled') &&
this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED &&
(
this.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.getTreePref('tabbar.autoShow.tabSwitch') ||

View File

@ -360,7 +360,7 @@ TreeStyleTabBrowser.prototype = {
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.fixed');
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.transparent.style');
window.setTimeout(function() {
b.treeStyleTab.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.autoHide.enabled');
b.treeStyleTab.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.autoHide.mode');
}, 0);
delete i;
@ -873,9 +873,9 @@ TreeStyleTabBrowser.prototype = {
b.removeAttribute(this.kALLOW_COLLAPSE);
break;
case 'extensions.treestyletab.tabbar.autoHide.enabled':
case 'extensions.treestyletab.tabbar.autoHide.mode':
var pos = b.getAttribute(this.kTABBAR_POSITION);
if (value/* && (pos == 'left' || pos == 'right')*/)
if (value != this.kAUTOHIDE_MODE_DISABLED/* && (pos == 'left' || pos == 'right')*/)
this.startAutoHide();
else
this.endAutoHide();
@ -1622,7 +1622,7 @@ TreeStyleTabBrowser.prototype = {
if (this.getTreePref('show.'+this.kMENUITEM_AUTOHIDE)/* &&
(pos == 'left' || pos == 'right')*/) {
autohide.removeAttribute('hidden');
if (this.getTreePref('tabbar.autoHide.enabled'))
if (this.autoHideEnabled)
autohide.setAttribute('checked', true);
else
autohide.removeAttribute('checked');
@ -2685,7 +2685,7 @@ TreeStyleTabBrowser.prototype = {
get tabbarWidth()
{
if (this.tabbarShown) {
if (this.autoHideMode != this.kAUTOHIDE_MODE_HIDE && this.tabbarShown) {
var b = this.mTabBrowser;
var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
this._tabbarWidth = b.mStrip.boxObject.width +
@ -2719,35 +2719,69 @@ TreeStyleTabBrowser.prototype = {
{
fullScreenCanvas.show();
var b = this.mTabBrowser;
if (this.tabbarShown) {
var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
this.tabbarHeight = b.mStrip.boxObject.height;
this.tabbarWidth = b.mStrip.boxObject.width +
(splitter ? splitter.boxObject.width : 0 );
this.container.style.margin = 0;
b.setAttribute(this.kAUTOHIDE, 'hidden');
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
this.tabbarShown = false;
}
else {
switch (b.getAttribute(this.kTABBAR_POSITION))
{
case 'left':
this.container.style.marginRight = '-'+this.tabbarWidth+'px';
break;
case 'right':
this.container.style.marginLeft = '-'+this.tabbarWidth+'px';
break;
case 'bottom':
this.container.style.marginTop = '-'+this.tabbarHeight+'px';
break;
default:
this.container.style.marginBottom = '-'+this.tabbarHeight+'px';
break;
}
if (this.isGecko18) b.setAttribute(this.kAUTOHIDE, 'show');
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
this.tabbarShown = true;
switch (this.autoHideMode)
{
case this.kAUTOHIDE_MODE_HIDE:
if (this.tabbarShown) {
var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
this.tabbarHeight = b.mStrip.boxObject.height;
this.tabbarWidth = b.mStrip.boxObject.width +
(splitter ? splitter.boxObject.width : 0 );
this.container.style.margin = 0;
b.setAttribute(this.kAUTOHIDE, 'hidden');
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
this.tabbarShown = false;
}
else {
switch (b.getAttribute(this.kTABBAR_POSITION))
{
case 'left':
this.container.style.marginRight = '-'+this.tabbarWidth+'px';
break;
case 'right':
this.container.style.marginLeft = '-'+this.tabbarWidth+'px';
break;
case 'bottom':
this.container.style.marginTop = '-'+this.tabbarHeight+'px';
break;
default:
this.container.style.marginBottom = '-'+this.tabbarHeight+'px';
break;
}
if (this.isGecko18) b.setAttribute(this.kAUTOHIDE, 'show');
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
this.tabbarShown = true;
}
break;
case this.kAUTOHIDE_MODE_SHRINK:
if (this.tabbarShown) {
this.tabbarShown = false;
this.tabbarWidth = this.getTreePref('tabbar.shrunken.width');
}
else {
this.tabbarShown = true;
this.tabbarWidth = this.getTreePref('tabbar.width');
}
this.updateTabbarTransparency();
switch (b.getAttribute(this.kTABBAR_POSITION))
{
case 'left':
this.container.style.marginRight = '-'+this.tabbarWidth+'px';
break;
case 'right':
this.container.style.marginLeft = '-'+this.tabbarWidth+'px';
break;
case 'bottom':
this.container.style.marginTop = '-'+this.tabbarHeight+'px';
break;
default:
this.container.style.marginBottom = '-'+this.tabbarHeight+'px';
break;
}
if (this.isGecko18) b.setAttribute(this.kAUTOHIDE, 'show');
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
break;
}
this.redrawContentArea();
window.setTimeout(function(aSelf) {
@ -2794,15 +2828,20 @@ TreeStyleTabBrowser.prototype = {
)
);
if (this.mTabBrowser.hasAttribute(this.kTRANSPARENT) &&
this.mTabBrowser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE])
this.mTabBrowser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE]) {
this.drawTabbarCanvas();
else
}
else {
this.clearTabbarCanvas();
if (this.autoHideMode == this.kAUTOHIDE_MODE_SHRINK)
this.container.style.margin = 0;
}
}
else {
v.move(window.outerWidth,window.outerHeight);
v.move(0,0);
this.clearTabbarCanvas();
if (this.autoHideMode == this.kAUTOHIDE_MODE_HIDE)
this.clearTabbarCanvas();
}
}
catch(e) {
@ -2873,20 +2912,39 @@ TreeStyleTabBrowser.prototype = {
)
)
];
if (pos != 'top' &&
this.getTreePref('tabbar.autoHide.enabled') &&
style != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE])
if (
pos != 'top' &&
style != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE] &&
(
this.autoHideMode == this.kAUTOHIDE_MODE_HIDE ||
this.autoHideMode == this.kAUTOHIDE_MODE_SHRINK && this.tabbarHidden
)
)
this.mTabBrowser.setAttribute(this.kTRANSPARENT, style);
else
this.mTabBrowser.removeAttribute(this.kTRANSPARENT);
},
/* auto hide */
autoHideEnabled : false,
// backward compatibility
get autoHideEnabled()
{
return this._autoHideEnabled && this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED;
},
set autoHideEnabled(aValue)
{
this._autoHideEnabled = aValue;
return aValue;
},
_autoHideEnabled : false,
get areaPadding()
{
return this.getTreePref('tabbar.autoHide.area');
var area = this.getTreePref('tabbar.autoHide.area');
if (this.autoHideMode == this.kAUTOHIDE_MODE_SHRINK)
area -= this.getTreePref('autoHide.area.shrunkenOffset');
return area;
},
startAutoHide : function()

View File

@ -1,4 +1,5 @@
pref("extensions.treestyletab.tabbar.width", 200);
pref("extensions.treestyletab.tabbar.shrunkenWidth", 100);
pref("extensions.treestyletab.tabbar.position", "left");
pref("extensions.treestyletab.tabbar.multirow", false);
pref("extensions.treestyletab.tabbar.invertScrollbar", true);
@ -7,9 +8,11 @@ pref("extensions.treestyletab.tabbar.hideAlltabsButton", true);
pref("extensions.treestyletab.tabbar.scroll.smooth", true);
pref("extensions.treestyletab.tabbar.scroll.timeout", 250);
pref("extensions.treestyletab.tabbar.style", "mixed");
pref("extensions.treestyletab.tabbar.autoHide.enabled", false);
pref("extensions.treestyletab.tabbar.autoHide.mode", 0);
pref("extensions.treestyletab.tabbar.autoHide.mode.toggle", 2);
pref("extensions.treestyletab.tabbar.autoHide.delay", 50);
pref("extensions.treestyletab.tabbar.autoHide.area", 25);
pref("extensions.treestyletab.tabbar.autoHide.area.shrunkenOffset", 7);
pref("extensions.treestyletab.tabbar.autoHide.expandArea", false);
// 0 = not transparent, 1 = partial transparent, 2 = completely transparent
pref("extensions.treestyletab.tabbar.transparent.style", 1);