From 2c0f8621e5fa77f8b272a0529b9af71405356581 Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Sun, 12 Apr 2015 09:11:42 -0400 Subject: [PATCH] fixed explorer misalignment issue --- editor/src/Unison/Editor.elm | 6 +++--- editor/src/Unison/Styles.elm | 18 ++++++++---------- editor/src/Unison/TermExplorer.elm | 1 - 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/editor/src/Unison/Editor.elm b/editor/src/Unison/Editor.elm index 987544bab..f5370a607 100644 --- a/editor/src/Unison/Editor.elm +++ b/editor/src/Unison/Editor.elm @@ -76,10 +76,10 @@ model sink term0 = let offset term e = case Moore.extract term |> .selection of Nothing -> Element.empty - Just region -> Styles.padNW region.topLeft.x (region.topLeft.y + region.height) e + Just region -> Styles.padNW (region.topLeft.x - Styles.selectionBorderWidth) (region.topLeft.y + region.height) e explorerXY term (x,y) = case Moore.extract term |> .selection of Nothing -> (x,y) - Just region -> (x - region.topLeft.x, y - (region.topLeft.y + region.height)) + Just region -> (x - region.topLeft.x - Styles.selectionBorderWidth, y - (region.topLeft.y + region.height)) out term explorer = { term = Moore.extract term |> .term , view = Element.layers [ Moore.extract term |> .layout |> Layout.element @@ -276,7 +276,7 @@ main = outs : Signal Out outs = Signals.tagEvent actions Window.width - |> Signal.map (\(e,w) -> { event = Maybe.withDefault Nothing e, availableWidth = w, topLeft = (15,15) }) + |> Signal.map (\(e,w) -> { event = Maybe.withDefault Nothing e, availableWidth = w, topLeft = (16,16) }) |> Moore.transform (model (Signal.send searchbox) term0) requests = Signals.justs (Signal.map .request outs) |> Signal.map (Signal.send reqChan) diff --git a/editor/src/Unison/Styles.elm b/editor/src/Unison/Styles.elm index 20367b778..5b4ebf545 100644 --- a/editor/src/Unison/Styles.elm +++ b/editor/src/Unison/Styles.elm @@ -102,9 +102,6 @@ chain1 x c = carotUp : Int -> Color -> Element carotUp x c = - --let block = E.spacer x x |> E.color c - -- sep = E.spacer 1 1 - --in E.flow E.down [ sep, block, sep, block, sep, block, sep ] let r = ceiling (toFloat x * sqrt 2.0) in C.collage r r [ C.rotate (degrees 45) (C.filled c (C.square (toFloat x))) ] |> E.height (ceiling (toFloat x * sqrt 2.0 / 2.0)) @@ -148,16 +145,17 @@ explorerOutline color e = e |> L.transform (\e -> E.layers [ E.spacer (E.widthOf e) (E.heightOf e) |> E.color bg , e - , outlineOf color 8 e ]) + , outlineOf color selectionBorderWidth e ]) + +selectionBorderWidth : Int +selectionBorderWidth = 8 selection : Region -> Element selection r = - let n = 8 - in E.container (r.topLeft.x + r.width + 12) - (r.topLeft.y + r.height + 12) - (E.topLeftAt (E.absolute (r.topLeft.x - 6)) (E.absolute (r.topLeft.y - 6))) - (outline' okColor n (r.width + 12) (r.height + 12)) - -- selectionLayer highlight + E.container (r.topLeft.x + r.width + selectionBorderWidth * 2) + (r.topLeft.y + r.height + selectionBorderWidth * 2) + (E.topLeftAt (E.absolute (r.topLeft.x - selectionBorderWidth)) (E.absolute (r.topLeft.y - selectionBorderWidth))) + (outline' okColor selectionBorderWidth (r.width + selectionBorderWidth * 2) (r.height + selectionBorderWidth * 2)) explorerSelection : Region -> Element explorerSelection = selectionLayer highlightExplorer diff --git a/editor/src/Unison/TermExplorer.elm b/editor/src/Unison/TermExplorer.elm index e6832d2b7..578f31627 100644 --- a/editor/src/Unison/TermExplorer.elm +++ b/editor/src/Unison/TermExplorer.elm @@ -232,7 +232,6 @@ layout md path searchbox keyedCompletions sel content infoLayout = resultsBox = Layout.above Nothing (Layout.embed Nothing above) below |> Styles.explorerOutline (Styles.statusColor ok) - |> Layout.transform (\e -> Element.flow Element.right [e]) inputBox = Layout.embed Nothing (viewField searchbox ok content (Just (Layout.widthOf resultsBox))) result = Layout.above Nothing inputBox resultsBox sel' = Moore.feed sel { layout = result, event = Just (Selection1D.Values (List.map snd valids)) }