Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/OverviewGrid.js

Issue 2404143002: DevTools: move overview grid window curtains handling into said window (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui_lazy/TimelineGrid.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 this.element = createElement("div"); 37 this.element = createElement("div");
38 this.element.id = prefix + "-overview-container"; 38 this.element.id = prefix + "-overview-container";
39 39
40 this._grid = new WebInspector.TimelineGrid(); 40 this._grid = new WebInspector.TimelineGrid();
41 this._grid.element.id = prefix + "-overview-grid"; 41 this._grid.element.id = prefix + "-overview-grid";
42 this._grid.setScrollTop(0); 42 this._grid.setScrollTop(0);
43 43
44 this.element.appendChild(this._grid.element); 44 this.element.appendChild(this._grid.element);
45 45
46 this._window = new WebInspector.OverviewGrid.Window(this.element, this._grid .dividersLabelBarElement); 46 this._window = new WebInspector.OverviewGrid.Window(this.element, this._grid .dividersLabelBarElement);
47 this._window.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged , this._onWindowChanged, this);
48 } 47 }
49 48
50 WebInspector.OverviewGrid.prototype = { 49 WebInspector.OverviewGrid.prototype = {
51 /** 50 /**
52 * @return {number} 51 * @return {number}
53 */ 52 */
54 clientWidth: function() 53 clientWidth: function()
55 { 54 {
56 return this.element.clientWidth; 55 return this.element.clientWidth;
57 }, 56 },
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 { 125 {
127 this._window._zoom(zoomFactor, referencePoint); 126 this._window._zoom(zoomFactor, referencePoint);
128 }, 127 },
129 128
130 /** 129 /**
131 * @param {boolean} enabled 130 * @param {boolean} enabled
132 */ 131 */
133 setResizeEnabled: function(enabled) 132 setResizeEnabled: function(enabled)
134 { 133 {
135 this._window.setEnabled(enabled); 134 this._window.setEnabled(enabled);
136 },
137
138 _onWindowChanged: function()
139 {
140 this._grid.showCurtains(this.windowLeft(), this.windowRight());
141 } 135 }
142 } 136 }
143 137
144 138
145 WebInspector.OverviewGrid.MinSelectableSize = 14; 139 WebInspector.OverviewGrid.MinSelectableSize = 14;
146 140
147 WebInspector.OverviewGrid.WindowScrollSpeedFactor = .3; 141 WebInspector.OverviewGrid.WindowScrollSpeedFactor = .3;
148 142
149 WebInspector.OverviewGrid.ResizerOffset = 3.5; // half pixel because offset valu es are not rounded but ceiled 143 WebInspector.OverviewGrid.ResizerOffset = 3.5; // half pixel because offset valu es are not rounded but ceiled
150 144
151 /** 145 /**
152 * @constructor 146 * @constructor
153 * @extends {WebInspector.Object} 147 * @extends {WebInspector.Object}
154 * @param {!Element} parentElement 148 * @param {!Element} parentElement
155 * @param {!Element=} dividersLabelBarElement 149 * @param {!Element=} dividersLabelBarElement
156 */ 150 */
157 WebInspector.OverviewGrid.Window = function(parentElement, dividersLabelBarEleme nt) 151 WebInspector.OverviewGrid.Window = function(parentElement, dividersLabelBarEleme nt)
158 { 152 {
159 this._parentElement = parentElement; 153 this._parentElement = parentElement;
160 154
161 WebInspector.installDragHandle(this._parentElement, this._startWindowSelecto rDragging.bind(this), this._windowSelectorDragging.bind(this), this._endWindowSe lectorDragging.bind(this), "text", null); 155 WebInspector.installDragHandle(this._parentElement, this._startWindowSelecto rDragging.bind(this), this._windowSelectorDragging.bind(this), this._endWindowSe lectorDragging.bind(this), "text", null);
162 if (dividersLabelBarElement) 156 if (dividersLabelBarElement)
163 WebInspector.installDragHandle(dividersLabelBarElement, this._startWindo wDragging.bind(this), this._windowDragging.bind(this), null, "-webkit-grabbing", "-webkit-grab"); 157 WebInspector.installDragHandle(dividersLabelBarElement, this._startWindo wDragging.bind(this), this._windowDragging.bind(this), null, "-webkit-grabbing", "-webkit-grab");
164 158
165 this.windowLeft = 0.0;
166 this.windowRight = 1.0;
167
168 this._parentElement.addEventListener("mousewheel", this._onMouseWheel.bind(t his), true); 159 this._parentElement.addEventListener("mousewheel", this._onMouseWheel.bind(t his), true);
169 this._parentElement.addEventListener("dblclick", this._resizeWindowMaximum.b ind(this), true); 160 this._parentElement.addEventListener("dblclick", this._resizeWindowMaximum.b ind(this), true);
170 WebInspector.appendStyle(this._parentElement, "ui_lazy/overviewGrid.css"); 161 WebInspector.appendStyle(this._parentElement, "ui_lazy/overviewGrid.css");
171 162
172 this._leftResizeElement = parentElement.createChild("div", "overview-grid-wi ndow-resizer"); 163 this._leftResizeElement = parentElement.createChild("div", "overview-grid-wi ndow-resizer");
173 this._leftResizeElement.style.left = "0";
174 WebInspector.installDragHandle(this._leftResizeElement, this._resizerElement StartDragging.bind(this), this._leftResizeElementDragging.bind(this), null, "ew- resize"); 164 WebInspector.installDragHandle(this._leftResizeElement, this._resizerElement StartDragging.bind(this), this._leftResizeElementDragging.bind(this), null, "ew- resize");
165 this._rightResizeElement = parentElement.createChild("div", "overview-grid-w indow-resizer");
166 WebInspector.installDragHandle(this._rightResizeElement, this._resizerElemen tStartDragging.bind(this), this._rightResizeElementDragging.bind(this), null, "e w-resize");
175 167
176 this._rightResizeElement = parentElement.createChild("div", "overview-grid-w indow-resizer"); 168 this._leftCurtainElement = parentElement.createChild("div", "window-curtain- left");
177 this._rightResizeElement.style.right = "0"; 169 this._rightCurtainElement = parentElement.createChild("div", "window-curtain -right");
178 WebInspector.installDragHandle(this._rightResizeElement, this._resizerElemen tStartDragging.bind(this), this._rightResizeElementDragging.bind(this), null, "e w-resize"); 170 this.reset();
179 this.setEnabled(true);
180 } 171 }
181 172
182 /** @enum {symbol} */ 173 /** @enum {symbol} */
183 WebInspector.OverviewGrid.Events = { 174 WebInspector.OverviewGrid.Events = {
184 WindowChanged: Symbol("WindowChanged"), 175 WindowChanged: Symbol("WindowChanged"),
185 Click: Symbol("Click") 176 Click: Symbol("Click")
186 } 177 }
187 178
188 WebInspector.OverviewGrid.Window.prototype = { 179 WebInspector.OverviewGrid.Window.prototype = {
189 reset: function() 180 reset: function()
190 { 181 {
191 this.windowLeft = 0.0; 182 this.windowLeft = 0.0;
192 this.windowRight = 1.0; 183 this.windowRight = 1.0;
193 this._leftResizeElement.style.left = "0%";
194 this._rightResizeElement.style.left = "100%";
195 this.setEnabled(true); 184 this.setEnabled(true);
185 this._updateCurtains();
196 }, 186 },
197 187
198 /** 188 /**
199 * @param {boolean} enabled 189 * @param {boolean} enabled
200 */ 190 */
201 setEnabled: function(enabled) 191 setEnabled: function(enabled)
202 { 192 {
203 this._enabled = enabled; 193 this._enabled = enabled;
204 }, 194 },
205 195
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 { 327 {
338 this._setWindowPosition(0, this._parentElement.clientWidth); 328 this._setWindowPosition(0, this._parentElement.clientWidth);
339 }, 329 },
340 330
341 /** 331 /**
342 * @param {number} windowLeft 332 * @param {number} windowLeft
343 * @param {number} windowRight 333 * @param {number} windowRight
344 */ 334 */
345 _setWindow: function(windowLeft, windowRight) 335 _setWindow: function(windowLeft, windowRight)
346 { 336 {
347 var left = windowLeft; 337 this.windowLeft = windowLeft;
348 var right = windowRight; 338 this.windowRight = windowRight;
349 var width = windowRight - windowLeft; 339 this._updateCurtains();
340 this.dispatchEventToListeners(WebInspector.OverviewGrid.Events.WindowCha nged);
341 },
342
343 _updateCurtains: function()
344 {
345 var left = this.windowLeft;
346 var right = this.windowRight;
347 var width = right - left;
350 348
351 // We allow actual time window to be arbitrarily small but don't want th e UI window to be too small. 349 // We allow actual time window to be arbitrarily small but don't want th e UI window to be too small.
352 var widthInPixels = width * this._parentElement.clientWidth; 350 var widthInPixels = width * this._parentElement.clientWidth;
353 var minWidthInPixels = WebInspector.OverviewGrid.MinSelectableSize / 2; 351 var minWidthInPixels = WebInspector.OverviewGrid.MinSelectableSize / 2;
354 if (widthInPixels < minWidthInPixels) { 352 if (widthInPixels < minWidthInPixels) {
355 var factor = minWidthInPixels / widthInPixels; 353 var factor = minWidthInPixels / widthInPixels;
356 left = ((windowRight + windowLeft) - width * factor) / 2; 354 left = ((this.windowRight + this.windowLeft) - width * factor) / 2;
357 right = ((windowRight + windowLeft) + width * factor) / 2; 355 right = ((this.windowRight + this.windowLeft) + width * factor) / 2;
358 } 356 }
357 this._leftResizeElement.style.left = (100 * left).toFixed(2) + "%";
358 this._rightResizeElement.style.left = (100 * right).toFixed(2) + "%";
359 359
360 this.windowLeft = windowLeft; 360 this._leftCurtainElement.style.width = (100 * left).toFixed(2) + "%";
361 this._leftResizeElement.style.left = left * 100 + "%"; 361 this._rightCurtainElement.style.width = (100 * (1 - right)).toFixed(2) + "%";
362 this.windowRight = windowRight;
363 this._rightResizeElement.style.left = right * 100 + "%";
364
365 this.dispatchEventToListeners(WebInspector.OverviewGrid.Events.WindowCha nged);
366 }, 362 },
367 363
368 /** 364 /**
369 * @param {?number} start 365 * @param {?number} start
370 * @param {?number} end 366 * @param {?number} end
371 */ 367 */
372 _setWindowPosition: function(start, end) 368 _setWindowPosition: function(start, end)
373 { 369 {
374 var clientWidth = this._parentElement.clientWidth; 370 var clientWidth = this._parentElement.clientWidth;
375 var windowLeft = typeof start === "number" ? start / clientWidth : this. windowLeft; 371 var windowLeft = typeof start === "number" ? start / clientWidth : this. windowLeft;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 position = Math.max(0, Math.min(position, this._width)); 456 position = Math.max(0, Math.min(position, this._width));
461 if (position < this._startPosition) { 457 if (position < this._startPosition) {
462 this._windowSelector.style.left = position + "px"; 458 this._windowSelector.style.left = position + "px";
463 this._windowSelector.style.right = this._width - this._startPosition + "px"; 459 this._windowSelector.style.right = this._width - this._startPosition + "px";
464 } else { 460 } else {
465 this._windowSelector.style.left = this._startPosition + "px"; 461 this._windowSelector.style.left = this._startPosition + "px";
466 this._windowSelector.style.right = this._width - position + "px"; 462 this._windowSelector.style.right = this._width - position + "px";
467 } 463 }
468 } 464 }
469 } 465 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui_lazy/TimelineGrid.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698