Scroll from the window when rendering entire file

Since we are rendering the entire file, we can give the normal window
scroll bar. Now that the height of CodeMirror is the full height of
the browser window, the side bar gutter is useless. Disable the gutter
when the entire file is displayed.

Change-Id: I97fb563571ab7b5541e8e18284feb90d5501cc1a
This commit is contained in:
Colby Ranger
2014-01-07 16:31:53 -08:00
committed by Shawn Pearce
parent 156f4f6fce
commit b07a26f2eb
4 changed files with 38 additions and 13 deletions

View File

@@ -56,6 +56,7 @@ class DiffTable extends Composite {
@UiField Element patchSetNavRow;
@UiField Element patchSetNavCellA;
@UiField Element patchSetNavCellB;
@UiField Element sidePanelCell;
@UiField FlowPanel widgets;
@UiField static DiffTableStyle style;

View File

@@ -44,6 +44,10 @@ limitations under the License.
width: auto;
}
.difftable .CodeMirror {
height: auto;
}
/* Preserve space for underscores. If this changes
* see ChunkManager.addPadding() and adjust there.
*/
@@ -150,7 +154,9 @@ limitations under the License.
</tr>
</table>
</td>
<td class='{style.sidePanelCell}'><d:SidePanel ui:field='sidePanel'/></td>
<td ui:field='sidePanelCell' class='{style.sidePanelCell}'>
<d:SidePanel ui:field='sidePanel'/>
</td>
</tr>
</table>
<g:FlowPanel ui:field='widgets' visible='false'/>

View File

@@ -33,6 +33,7 @@ limitations under the License.
font-family: arial,sans-serif;
font-weight: bold;
overflow: hidden;
position: fixed !important;
text-align: left;
text-shadow: 1px 1px 7px #000000;
min-width: 300px;

View File

@@ -52,6 +52,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwtexpui.globalkey.client.GlobalKey;
import com.google.gwtexpui.globalkey.client.KeyCommand;
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
@@ -202,7 +203,8 @@ public class SideBySide2 extends Screen {
@Override
public void onShowView() {
super.onShowView();
Window.enableScrolling(false);
Window.enableScrolling(prefs.renderEntireFile());
UIObject.setVisible(diffTable.sidePanelCell, !prefs.renderEntireFile());
if (prefs.hideTopMenu()) {
Gerrit.setHeaderVisible(false);
}
@@ -217,8 +219,10 @@ public class SideBySide2 extends Screen {
operation(new Runnable() {
@Override
public void run() {
cmA.setHeight(height);
cmB.setHeight(height);
if (!prefs.renderEntireFile()) {
cmA.setHeight(height);
cmB.setHeight(height);
}
cmA.refresh();
cmB.refresh();
}
@@ -471,11 +475,13 @@ public class SideBySide2 extends Screen {
operation(new Runnable() {
public void run() {
// Estimate initial CM3 height, fixed up in onShowView.
int height = Window.getClientHeight()
- (Gerrit.getHeaderFooterHeight() + 18);
cmA.setHeight(height);
cmB.setHeight(height);
if (!prefs.renderEntireFile()) {
// Estimate initial CM3 height, fixed up in onShowView.
int height = Window.getClientHeight()
- (Gerrit.getHeaderFooterHeight() + 18);
cmA.setHeight(height);
cmB.setHeight(height);
}
render(diff);
commentManager.render(comments, prefs.expandAllComments());
@@ -623,6 +629,9 @@ public class SideBySide2 extends Screen {
return new Runnable() {
@Override
public void run() {
if (prefs.renderEntireFile()) {
return;
}
Viewport fromTo = cm.getViewport();
int size = fromTo.getTo() - fromTo.getFrom() + 1;
if (cm.getOldViewportSize() == size) {
@@ -762,17 +771,25 @@ public class SideBySide2 extends Screen {
if (prefs.renderEntireFile()) {
cmA.addKeyMap(RENDER_ENTIRE_FILE_KEYMAP);
cmB.addKeyMap(RENDER_ENTIRE_FILE_KEYMAP);
cmA.setHeight("");
cmB.setHeight("");
}
cmA.setOption("viewportMargin", prefs.renderEntireFile() ? POSITIVE_INFINITY : 10);
cmB.setOption("viewportMargin", prefs.renderEntireFile() ? POSITIVE_INFINITY : 10);
Window.enableScrolling(prefs.renderEntireFile());
UIObject.setVisible(diffTable.sidePanelCell, !prefs.renderEntireFile());
resizeCodeMirror();
}
void resizeCodeMirror() {
int height = getCodeMirrorHeight();
cmA.setHeight(height);
cmB.setHeight(height);
diffTable.sidePanel.adjustGutters(cmB);
if (!prefs.renderEntireFile()) {
int height = getCodeMirrorHeight();
cmA.setHeight(height);
cmB.setHeight(height);
diffTable.sidePanel.adjustGutters(cmB);
}
}
private int getCodeMirrorHeight() {