Skip to content

Commit

Permalink
feat(layout/#592): layout tabs - part 1 (#2013)
Browse files Browse the repository at this point in the history
* add layouts to model

* add layout command

* previous/next layout commands

* refactor: move views to View module

* add layout tab bar

* wire up tabnew/tabedit (incomplete)

* configuration settings

* hide layout tabs in zen mode

* RemoveLastBlocked -> RemoveLastWasBlocked

* fix off by one bug

* fix "missing default value" warnings

* labeled ~index on Tabs.render

* fix closing behaviour
  • Loading branch information
glennsl authored Jun 26, 2020
1 parent 720228b commit d9ba249
Show file tree
Hide file tree
Showing 14 changed files with 1,174 additions and 727 deletions.
9 changes: 7 additions & 2 deletions src/Components/Tabs.re
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let schedulePostRender = f => postRenderQueue := [f, ...postRenderQueue^];
let component = React.Expert.component("Tabs");
let make =
(
~children as render: 'a => element,
~children as render: (~isSelected: bool, ~index: int, 'a) => element,
~items: list('a),
~selectedIndex: option(int),
~style,
Expand Down Expand Up @@ -117,7 +117,12 @@ let make =
ref={r => setOuterRef(_ => Some(r))}
style=outerStyle>
<View onDimensionsChanged=postRender style=innerStyle>
{List.map(render, items) |> React.listToElement}
{List.mapi(
index =>
render(~isSelected=Some(index) == selectedIndex, ~index),
items,
)
|> React.listToElement}
</View>
</View>,
hooks,
Expand Down
59 changes: 59 additions & 0 deletions src/Feature/Layout/Configuration.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
open Oni_Core;
open Config.Schema;

module Codec: {
let showLayoutTabs: Config.Schema.codec([ | `always | `smart | `off]);
let layoutTabPosition: Config.Schema.codec([ | `top | `bottom]);
} = {
let showLayoutTabs =
custom(
~decode=
Json.Decode.(
string
|> map(
fun
| "always" => `always
| "smart" => `smart
| "off" => `off
| _ => `smart,
)
),
~encode=
Json.Encode.(
fun
| `always => string("always")
| `smart => string("smart")
| `off => string("off")
),
);

let layoutTabPosition =
custom(
~decode=
Json.Decode.(
string
|> map(
fun
| "top" => `top
| "bottom" => `bottom
| _ => `bottom,
)
),
~encode=
Json.Encode.(
fun
| `top => string("top")
| `bottom => string("bottom")
),
);
};

let showLayoutTabs =
setting("oni.layout.showLayoutTabs", Codec.showLayoutTabs, ~default=`smart);

let layoutTabPosition =
setting(
"oni.layout.layoutTabPosition",
Codec.layoutTabPosition,
~default=`bottom,
);
95 changes: 0 additions & 95 deletions src/Feature/Layout/EditorGroupView.re

This file was deleted.

208 changes: 0 additions & 208 deletions src/Feature/Layout/EditorTab.re

This file was deleted.

Loading

0 comments on commit d9ba249

Please sign in to comment.