From bf7038f5061b13779fed80a7ccbd9a4c791fd122 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 13 Jan 2017 14:52:08 +0100 Subject: [PATCH] Adapt review panel line height to editor --- services/web/app/views/project/editor/editor.jade | 1 + .../coffee/ide/editor/directives/aceEditor.coffee | 9 +++++++++ .../controllers/ReviewPanelController.coffee | 1 + .../review-panel/directives/reviewPanelSorted.coffee | 11 +++++++---- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/services/web/app/views/project/editor/editor.jade b/services/web/app/views/project/editor/editor.jade index 4988e56dc4..d31be444af 100644 --- a/services/web/app/views/project/editor/editor.jade +++ b/services/web/app/views/project/editor/editor.jade @@ -55,6 +55,7 @@ div.full-size( track-changes-enabled="trackChangesFeatureFlag", track-changes= "editor.trackChanges", doc-id="editor.open_doc_id" + renderer-data="reviewPanel.rendererData" ) include ./review-panel diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index 8a3b00a61e..41c70b4dee 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -57,6 +57,7 @@ define [ trackChanges: "=" trackChangesEnabled: "=" docId: "=" + rendererData: "=" } link: (scope, element, attrs) -> # Don't freak out if we're already in an apply callback @@ -317,6 +318,14 @@ define [ doc = session.getDocument() doc.off "change", onChange + + editor.renderer.on "changeCharacterSize", () -> + scope.$apply () -> + scope.rendererData.lineHeight = editor.renderer.lineHeight + + scope.$watch "rendererData", (rendererData) -> + if rendererData? + rendererData.lineHeight = editor.renderer.lineHeight template: """
diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 6dae528436..1db13c291e 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -23,6 +23,7 @@ define [ commentThreads: {} resolvedThreadIds: {} layoutToLeft: false + rendererData: {} $scope.$on "layout:pdf:linked", (event, state) -> $scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed) diff --git a/services/web/public/coffee/ide/review-panel/directives/reviewPanelSorted.coffee b/services/web/public/coffee/ide/review-panel/directives/reviewPanelSorted.coffee index 72fd0f1a58..2bd66c723e 100644 --- a/services/web/public/coffee/ide/review-panel/directives/reviewPanelSorted.coffee +++ b/services/web/public/coffee/ide/review-panel/directives/reviewPanelSorted.coffee @@ -32,6 +32,8 @@ define [ return if entries.length == 0 + line_height = scope.reviewPanel.rendererData.lineHeight + focused_entry_index = Math.min(previous_focused_entry_index, entries.length - 1) for entry, i in entries if entry.scope.entry.focused @@ -57,15 +59,13 @@ define [ previousMinTop += PADDING + height min_tops.reverse() - line_height = 15 - positionLayoutEl = ($callout_el, original_top, top) -> if original_top <= top $callout_el.removeClass("rp-entry-callout-inverted") - $callout_el.css(top: original_top + line_height, height: top - original_top) + $callout_el.css(top: original_top + line_height - 1, height: top - original_top) else $callout_el.addClass("rp-entry-callout-inverted") - $callout_el.css(top: top + line_height + 1, height: original_top - top) + $callout_el.css(top: top + line_height, height: original_top - top) # Put the focused entry as close to where it wants to be as possible focused_entry_top = Math.max(previousMinTop, focused_entry.scope.entry.screenPos.y) @@ -104,6 +104,9 @@ define [ scope.$on "review-panel:layout", () -> scope.$applyAsync () -> layout() + + scope.$watch "reviewPanel.rendererData.lineHeight", () -> + layout() ## Scroll lock with Ace scroller = element