fixed explorer misalignment issue

This commit is contained in:
Paul Chiusano 2015-04-12 09:11:42 -04:00
parent 2ad7cc588f
commit 2c0f8621e5
3 changed files with 11 additions and 14 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)) }