幅を半分にする機能

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

@ -65,6 +65,11 @@ var TreeStyleTabService = {
kTRANSPARENT_FULL : 2, 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_FISRT : 0,
kINSERT_LAST : 1, kINSERT_LAST : 1,
@ -470,8 +475,11 @@ var TreeStyleTabService = {
toggleAutoHide : function() toggleAutoHide : function()
{ {
this.setTreePref('tabbar.autoHide.enabled', this.setTreePref('tabbar.autoHide.mode',
!this.getTreePref('tabbar.autoHide.enabled')); this.getTreePref('tabbar.autoHide.mode') == this.kAUTOHIDE_MODE_DISABLED ?
this.getTreePref('tabbar.autoHide.mode.toggle') :
this.kAUTOHIDE_MODE_DISABLED
);
}, },
toggleFixed : function() toggleFixed : function()
@ -815,7 +823,7 @@ var TreeStyleTabService = {
this.overrideExtensionsOnInitAfter(); // hacks.js this.overrideExtensionsOnInitAfter(); // hacks.js
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin'); 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.link.open_newwindow.restriction.override');
this.observe(null, 'nsPref:changed', 'browser.tabs.loadFolderAndReplace.override'); this.observe(null, 'nsPref:changed', 'browser.tabs.loadFolderAndReplace.override');
}, },
@ -1376,11 +1384,13 @@ catch(e) {
onTabbarResized : function(aEvent) onTabbarResized : function(aEvent)
{ {
this.setPref( var b = this.getTabBrowserFromChild(aEvent.currentTarget);
'extensions.treestyletab.tabbar.width', if (b.treeStyleTab.tabbarShrunken) {
TreeStyleTabService.getTabBrowserFromChild(aEvent.currentTarget) this.setTreePref('tabbar.shrunkenWidth', b.mStrip.boxObject.width);
.mStrip.boxObject.width }
); else {
this.setTreePref('tabbar.width', b.mStrip.boxObject.width);
}
}, },
initContextMenu : function() initContextMenu : function()
@ -1630,12 +1640,13 @@ catch(e) {
this.ObserverService.notifyObservers(null, 'TreeStyleTab:levelMarginModified', value); this.ObserverService.notifyObservers(null, 'TreeStyleTab:levelMarginModified', value);
break; break;
case 'extensions.treestyletab.tabbar.autoHide.enabled': case 'extensions.treestyletab.tabbar.autoHide.mode':
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown': case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
case 'extensions.treestyletab.tabbar.autoShow.tabSwitch': case 'extensions.treestyletab.tabbar.autoShow.tabSwitch':
case 'extensions.treestyletab.tabbar.autoShow.feedback': case 'extensions.treestyletab.tabbar.autoShow.feedback':
this.autoHideMode = this.getTreePref('tabbar.autoHide.mode');
if ( if (
this.getTreePref('tabbar.autoHide.enabled') && this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED &&
( (
this.getTreePref('tabbar.autoShow.accelKeyDown') || this.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.getTreePref('tabbar.autoShow.tabSwitch') || 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.fixed');
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.transparent.style'); this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.transparent.style');
window.setTimeout(function() { 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); }, 0);
delete i; delete i;
@ -873,9 +873,9 @@ TreeStyleTabBrowser.prototype = {
b.removeAttribute(this.kALLOW_COLLAPSE); b.removeAttribute(this.kALLOW_COLLAPSE);
break; break;
case 'extensions.treestyletab.tabbar.autoHide.enabled': case 'extensions.treestyletab.tabbar.autoHide.mode':
var pos = b.getAttribute(this.kTABBAR_POSITION); 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(); this.startAutoHide();
else else
this.endAutoHide(); this.endAutoHide();
@ -1622,7 +1622,7 @@ TreeStyleTabBrowser.prototype = {
if (this.getTreePref('show.'+this.kMENUITEM_AUTOHIDE)/* && if (this.getTreePref('show.'+this.kMENUITEM_AUTOHIDE)/* &&
(pos == 'left' || pos == 'right')*/) { (pos == 'left' || pos == 'right')*/) {
autohide.removeAttribute('hidden'); autohide.removeAttribute('hidden');
if (this.getTreePref('tabbar.autoHide.enabled')) if (this.autoHideEnabled)
autohide.setAttribute('checked', true); autohide.setAttribute('checked', true);
else else
autohide.removeAttribute('checked'); autohide.removeAttribute('checked');
@ -2685,7 +2685,7 @@ TreeStyleTabBrowser.prototype = {
get tabbarWidth() get tabbarWidth()
{ {
if (this.tabbarShown) { if (this.autoHideMode != this.kAUTOHIDE_MODE_HIDE && this.tabbarShown) {
var b = this.mTabBrowser; var b = this.mTabBrowser;
var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER); var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
this._tabbarWidth = b.mStrip.boxObject.width + this._tabbarWidth = b.mStrip.boxObject.width +
@ -2719,6 +2719,9 @@ TreeStyleTabBrowser.prototype = {
{ {
fullScreenCanvas.show(); fullScreenCanvas.show();
var b = this.mTabBrowser; var b = this.mTabBrowser;
switch (this.autoHideMode)
{
case this.kAUTOHIDE_MODE_HIDE:
if (this.tabbarShown) { if (this.tabbarShown) {
var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER); var splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
this.tabbarHeight = b.mStrip.boxObject.height; this.tabbarHeight = b.mStrip.boxObject.height;
@ -2749,6 +2752,37 @@ TreeStyleTabBrowser.prototype = {
this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN; this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN;
this.tabbarShown = true; 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(); this.redrawContentArea();
window.setTimeout(function(aSelf) { window.setTimeout(function(aSelf) {
if (!aSelf.isGecko18 && aSelf.tabbarShown) { if (!aSelf.isGecko18 && aSelf.tabbarShown) {
@ -2794,14 +2828,19 @@ TreeStyleTabBrowser.prototype = {
) )
); );
if (this.mTabBrowser.hasAttribute(this.kTRANSPARENT) && 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(); this.drawTabbarCanvas();
else }
else {
this.clearTabbarCanvas(); this.clearTabbarCanvas();
if (this.autoHideMode == this.kAUTOHIDE_MODE_SHRINK)
this.container.style.margin = 0;
}
} }
else { else {
v.move(window.outerWidth,window.outerHeight); v.move(window.outerWidth,window.outerHeight);
v.move(0,0); v.move(0,0);
if (this.autoHideMode == this.kAUTOHIDE_MODE_HIDE)
this.clearTabbarCanvas(); this.clearTabbarCanvas();
} }
} }
@ -2873,20 +2912,39 @@ TreeStyleTabBrowser.prototype = {
) )
) )
]; ];
if (pos != 'top' && if (
this.getTreePref('tabbar.autoHide.enabled') && pos != 'top' &&
style != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE]) 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); this.mTabBrowser.setAttribute(this.kTRANSPARENT, style);
else else
this.mTabBrowser.removeAttribute(this.kTRANSPARENT); this.mTabBrowser.removeAttribute(this.kTRANSPARENT);
}, },
/* auto hide */ /* 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() 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() startAutoHide : function()

View File

@ -1,4 +1,5 @@
pref("extensions.treestyletab.tabbar.width", 200); pref("extensions.treestyletab.tabbar.width", 200);
pref("extensions.treestyletab.tabbar.shrunkenWidth", 100);
pref("extensions.treestyletab.tabbar.position", "left"); pref("extensions.treestyletab.tabbar.position", "left");
pref("extensions.treestyletab.tabbar.multirow", false); pref("extensions.treestyletab.tabbar.multirow", false);
pref("extensions.treestyletab.tabbar.invertScrollbar", true); 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.smooth", true);
pref("extensions.treestyletab.tabbar.scroll.timeout", 250); pref("extensions.treestyletab.tabbar.scroll.timeout", 250);
pref("extensions.treestyletab.tabbar.style", "mixed"); 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.delay", 50);
pref("extensions.treestyletab.tabbar.autoHide.area", 25); pref("extensions.treestyletab.tabbar.autoHide.area", 25);
pref("extensions.treestyletab.tabbar.autoHide.area.shrunkenOffset", 7);
pref("extensions.treestyletab.tabbar.autoHide.expandArea", false); pref("extensions.treestyletab.tabbar.autoHide.expandArea", false);
// 0 = not transparent, 1 = partial transparent, 2 = completely transparent // 0 = not transparent, 1 = partial transparent, 2 = completely transparent
pref("extensions.treestyletab.tabbar.transparent.style", 1); pref("extensions.treestyletab.tabbar.transparent.style", 1);