move horizontal scrollbar always visible setting to window model

This commit is contained in:
Fabian Jakobs 2011-07-27 15:27:53 +02:00
commit 069293b3ff
5 changed files with 31 additions and 22 deletions

View file

@ -339,7 +339,7 @@ define(function(require, exports, module) {
showGutterEl.checked = editor.getShowGutter();
showPrintMarginEl.checked = editor.getShowPrintMargin();
highlightSelectedWordE.checked = editor.getHighlightSelectedWord();
showHScrollEl.checked = editor.renderer.getHScrollBarAlwaysVisible();
showHScrollEl.checked = editor.getHScrollBarAlwaysVisible();
softTabEl.checked = session.getUseSoftTabs();
behavioursEl.checked = editor.getBehavioursEnabled()
}
@ -418,7 +418,7 @@ define(function(require, exports, module) {
});
bindCheckbox("show_hscroll", function(checked) {
env.editor.renderer.setHScrollBarAlwaysVisible(checked);
env.editor.setHScrollBarAlwaysVisible(checked);
});
bindCheckbox("soft_tab", function(checked) {

View file

@ -650,6 +650,14 @@ var Editor = function(windowView, buffer) {
this.getShowGutter = function() {
return this.windowModel.getShowGutter();
};
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
this.windowModel.setHScrollBarAlwaysVisible(alwaysVisible);
};
this.getHScrollBarAlwaysVisible = function() {
return this.windowModel.getHScrollBarAlwaysVisible();
};
this.$readOnly = false;
this.setReadOnly = function(readOnly) {

View file

@ -76,6 +76,7 @@ var Window = exports.Window = function() {
this.printMarginColumn = 80;
this.showGutter = true;
this.padding = 4;
this.horizScrollAlwaysVisible = false;
};
(function() {
@ -150,8 +151,20 @@ var Window = exports.Window = function() {
this.getPadding = function() {
return this.padding;
}
};
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
if (this.horizScrollAlwaysVisible == alwaysVisible)
return;
this.horizScrollAlwaysVisible = alwaysVisible;
this._emit("changeHorizScroll");
};
this.getHScrollBarAlwaysVisible = function() {
return this.horizScrollAlwaysVisible;
};
}).call(Window.prototype);
});

View file

@ -89,20 +89,13 @@ var WindowView = function(windowModel, container, theme) {
this.$cursorLayer = new CursorLayer(windowModel, this.content);
this.$cursorPadding = 8;
// Indicates whether the horizontal scrollbar is visible
this.$horizScroll = true;
this.$horizScrollAlwaysVisible = true;
this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
this.scrollTop = 0;
this.cursorPos = {
row : 0,
column : 0
};
var _self = this;
this.$textLayer.addEventListener("changeCharaterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth();
@ -120,6 +113,7 @@ var WindowView = function(windowModel, container, theme) {
this.updatePadding();
this.updatePrintMargin();
this.updateHorizScroll();
};
(function() {
@ -323,17 +317,10 @@ var WindowView = function(windowModel, container, theme) {
this.$loop.schedule(this.CHANGE_FULL);
this.updatePrintMargin();
};
this.getHScrollBarAlwaysVisible = function() {
return this.$horizScrollAlwaysVisible;
};
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
this.$horizScrollAlwaysVisible = alwaysVisible;
if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
this.$loop.schedule(this.CHANGE_SCROLL);
}
this.updateHorizScroll = function() {
if (!this.model.horizScrollAlwaysVisible || !this.$horizScroll)
this.$loop.schedule(this.CHANGE_SCROLL);
};
this.onScroll = function(e) {
@ -425,7 +412,7 @@ var WindowView = function(windowModel, container, theme) {
var longestLine = this.$getLongestLine();
var widthChanged = this.model.layerConfig.width != longestLine;
var horizScroll = this.$horizScrollAlwaysVisible || this.model.size.scrollerWidth - longestLine < 0;
var horizScroll = this.model.horizScrollAlwaysVisible || this.model.size.scrollerWidth - longestLine < 0;
var horizScrollChanged = this.$horizScroll !== horizScroll;
this.$horizScroll = horizScroll;
if (horizScrollChanged)

View file

@ -45,6 +45,7 @@ var WindowController = exports.WindowController = function(model, view) {
model.on("changePrintMargin", view.updatePrintMargin.bind(view));
model.on("changeShowGutter", view.updateShowGutter.bind(view));
model.on("changePadding", view.updatePadding.bind(view));
model.on("changeHorizScroll", view.updateHorizScroll.bind(view));
};
(function() {