Don't expand the tab bar too much on resizing #1002
This commit is contained in:
parent
8b8410a58a
commit
27a8a8f2e0
@ -42,6 +42,7 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import('resource://gre/modules/Timer.jsm');
|
||||
Cu.import('resource://treestyletab-modules/lib/inherit.jsm');
|
||||
Cu.import('resource://treestyletab-modules/constants.js');
|
||||
Cu.import('resource://treestyletab-modules/ReferenceCounter.js');
|
||||
@ -289,6 +290,7 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
},
|
||||
set tabbarWidth(aValue)
|
||||
{
|
||||
log('setting "width" to '+aValue+' (expanded='+this.expanded+')');
|
||||
if (this.expanded)
|
||||
return this.expandedWidth = aValue;
|
||||
else
|
||||
@ -303,16 +305,9 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
},
|
||||
set expandedWidth(aValue)
|
||||
{
|
||||
var newWidth = this.treeStyleTab.calculateCorrectExpandedAndShrunkenWidth({
|
||||
expanded : aValue,
|
||||
shrunken : this.shrunkenWidth
|
||||
}, 'expanded');
|
||||
if (newWidth.corrected) {
|
||||
this.shrunkenWidth = newWidth.shrunken;
|
||||
aValue = newWidth.expanded;
|
||||
}
|
||||
this.treeStyleTab.setWindowValue(this.kTABBAR_EXPANDED_WIDTH, aValue);
|
||||
utils.setTreePref('tabbar.width', aValue);
|
||||
this.reserveFixWidth('expanded');
|
||||
return aValue;
|
||||
},
|
||||
get shrunkenWidth()
|
||||
@ -324,19 +319,30 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
},
|
||||
set shrunkenWidth(aValue)
|
||||
{
|
||||
var newWidth = this.treeStyleTab.calculateCorrectExpandedAndShrunkenWidth({
|
||||
expanded : this.expandedWidth,
|
||||
shrunken : aValue
|
||||
}, 'shrunken');
|
||||
if (newWidth.corrected) {
|
||||
this.expandedWidth = newWidth.expanded;
|
||||
aValue = newWidth.shrunken;
|
||||
}
|
||||
this.treeStyleTab.setWindowValue(this.kTABBAR_SHRUNKEN_WIDTH, aValue);
|
||||
utils.setTreePref('tabbar.shrunkenWidth', aValue);
|
||||
this.reserveFixWidth('shrunken');
|
||||
return aValue;
|
||||
},
|
||||
|
||||
reserveFixWidth : function(aTrigger)
|
||||
{
|
||||
if (this._collectingTabbarWidth)
|
||||
clearTimeout(this._collectingTabbarWidth);
|
||||
var stack = new Error().stack;
|
||||
this._collectingTabbarWidth = setTimeout((function() {
|
||||
log('reserveFixWidth: \n'+stack);
|
||||
var newWidth = this.treeStyleTab.calculateCorrectExpandedAndShrunkenWidth({
|
||||
expanded : this.expandedWidth,
|
||||
shrunken : this.shrunkenWidth
|
||||
}, aTrigger);
|
||||
if (this.shrunkenWidth != newWidth.shrunken)
|
||||
this.shrunkenWidth = newWidth.shrunken;
|
||||
if (this.expandedWidth != newWidth.expanded)
|
||||
this.expandedWidth = newWidth.expanded;
|
||||
}).bind(this), 100);
|
||||
},
|
||||
|
||||
resetWidth : function AHB_resetWidth()
|
||||
{
|
||||
this.expandedWidth = utils.getTreePref('tabbar.width.default');
|
||||
|
@ -2246,10 +2246,6 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
Services.obs.notifyObservers(null, this.kTOPIC_INDENT_MODIFIED, value);
|
||||
return;
|
||||
|
||||
case 'extensions.treestyletab.tabbar.width':
|
||||
case 'extensions.treestyletab.tabbar.shrunkenWidth':
|
||||
return this.correctMismatchedTabWidthPrefs(aPrefName);
|
||||
|
||||
case 'extensions.stm.tabBarMultiRows': // Super Tab Mode
|
||||
if (this.prefOverriding)
|
||||
return;
|
||||
@ -2319,6 +2315,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
},
|
||||
calculateCorrectExpandedAndShrunkenWidth : function TSTBase_calculateCorrectExpandedAndShrunkenWidth(aSource, aModifiedTarget)
|
||||
{
|
||||
log('calculateCorrectExpandedAndShrunkenWidth '+JSON.stringify(aSource)+' / '+aModifiedTarget);
|
||||
var size = {
|
||||
expanded : aSource.expanded,
|
||||
shrunken : aSource.shrunken,
|
||||
@ -2328,6 +2325,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
var originalShrunken = size.shrunken;
|
||||
var maxSize = this.browserWindow.gBrowser.boxObject.width * this.MAX_TABBAR_SIZE_RATIO;
|
||||
if (aModifiedTarget.indexOf('shrunken') > -1) {
|
||||
log('fixsing expanded size');
|
||||
if (size.expanded <= size.shrunken)
|
||||
size.expanded = parseInt(size.shrunken / this.DEFAULT_SHRUNKEN_WIDTH_RATIO);
|
||||
if (size.expanded > maxSize) {
|
||||
@ -2337,6 +2335,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
}
|
||||
}
|
||||
else {
|
||||
log('fixsing shrunken size');
|
||||
if (size.expanded > maxSize)
|
||||
size.expanded = maxSize;
|
||||
if (size.expanded <= size.shrunken)
|
||||
@ -2348,6 +2347,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
size.expanded != originalExpanded ||
|
||||
size.shrunken != originalShrunken
|
||||
);
|
||||
log(' => '+JSON.stringify(size));
|
||||
return size;
|
||||
},
|
||||
|
||||
|
@ -2784,7 +2784,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
case 'extensions.treestyletab.tabbar.width.override':
|
||||
if (!this.autoHide.isResizing && this.isVertical) {
|
||||
this.removeTabStripAttribute('width');
|
||||
this.tabbarWidth = value;
|
||||
if (aPrefName.indexOf('shrunken') > -1)
|
||||
this.shrunkenWidth = value;
|
||||
else
|
||||
this.expandedWidth = value;
|
||||
this.setTabStripAttribute('width', this.autoHide.placeHolderWidthFromMode);
|
||||
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE);
|
||||
}
|
||||
|
@ -1080,6 +1080,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
width += (pos == 'left' ? delta : -delta );
|
||||
width = this.maxTabbarWidth(width, b);
|
||||
if (expanded || b.treeStyleTab.autoHide.expanded) {
|
||||
log('onTabbarResizing: setting expanded width to '+width);
|
||||
// b.treeStyleTab.tabbarWidth = width;
|
||||
b.treeStyleTab.autoHide.expandedWidth = width;
|
||||
if (b.treeStyleTab.autoHide.mode == b.treeStyleTab.autoHide.kMODE_SHRINK &&
|
||||
@ -1087,6 +1088,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', b.treeStyleTab.autoHide.shrunkenWidth);
|
||||
}
|
||||
else {
|
||||
log('onTabbarResizing: setting shrunken width to '+width);
|
||||
b.treeStyleTab.autoHide.shrunkenWidth = width;
|
||||
}
|
||||
}
|
||||
@ -1094,6 +1096,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
let delta = aEvent.screenY - this.tabbarResizeStartY;
|
||||
height += (pos == 'top' ? delta : -delta );
|
||||
height = this.maxTabbarHeight(height, b);
|
||||
log('onTabbarResizing: setting height to '+height);
|
||||
b.treeStyleTab.tabbarHeight = height;
|
||||
}
|
||||
b.treeStyleTab.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_TABBAR_RESIZE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user