SplitView.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Terminal.Gui.Graphs;
  5. namespace Terminal.Gui {
  6. /// <summary>
  7. /// A <see cref="View"/> consisting of a moveable bar that divides
  8. /// the display area into resizeable views.
  9. /// </summary>
  10. public class SplitView : View {
  11. SplitView parentSplitView;
  12. /// TODO: Might be able to make Border virtual and override here
  13. /// To make this more API friendly
  14. /// <summary>
  15. /// Use this field instead of Border to create an integrated
  16. /// Border in which lines connect with subviews and splitters
  17. /// seamlessly
  18. /// </summary>
  19. public BorderStyle IntegratedBorder { get; set; }
  20. public class Tile {
  21. public View View { get; internal set; }
  22. public int MinSize { get; set; }
  23. public string Title { get; set; }
  24. public Tile ()
  25. {
  26. View = new View () { Width = Dim.Fill (), Height = Dim.Fill () };
  27. Title = string.Empty;
  28. MinSize = 0;
  29. }
  30. }
  31. List<Tile> tiles;
  32. private List<Pos> splitterDistances;
  33. private List<SplitContainerLineView> splitterLines;
  34. /// <summary>
  35. /// The sub sections hosted by the view
  36. /// </summary>
  37. public IReadOnlyCollection<Tile> Tiles => tiles.AsReadOnly ();
  38. /// <summary>
  39. /// The splitter locations. Note that there will be N-1 splitters where
  40. /// N is the number of <see cref="Tiles"/>.
  41. /// </summary>
  42. public IReadOnlyCollection<Pos> SplitterDistances => splitterDistances.AsReadOnly ();
  43. private Orientation orientation = Orientation.Vertical;
  44. /// <summary>
  45. /// Creates a new instance of the SplitContainer class.
  46. /// </summary>
  47. public SplitView () : this (2)
  48. {
  49. }
  50. public SplitView (int tiles)
  51. {
  52. CanFocus = true;
  53. RebuildForTileCount (tiles);
  54. }
  55. /// <summary>
  56. /// Invoked when the <see cref="SplitterDistance"/> is changed
  57. /// </summary>
  58. public event SplitterEventHandler SplitterMoved;
  59. /// <summary>
  60. /// Raises the <see cref="SplitterMoved"/> event
  61. /// </summary>
  62. protected virtual void OnSplitterMoved (int idx)
  63. {
  64. SplitterMoved?.Invoke (this, new SplitterEventArgs (this, idx, splitterDistances [idx]));
  65. }
  66. /// <summary>
  67. /// Scraps all <see cref="Tiles"/> and creates <paramref name="count"/> new tiles
  68. /// in orientation <see cref="Orientation"/>
  69. /// </summary>
  70. /// <param name="count"></param>
  71. public void RebuildForTileCount (int count)
  72. {
  73. tiles = new List<Tile> ();
  74. // TODO: keep these if growing
  75. splitterDistances = new List<Pos> ();
  76. splitterLines = new List<SplitContainerLineView> ();
  77. RemoveAll ();
  78. tiles.Clear ();
  79. splitterDistances.Clear ();
  80. if (count == 0) {
  81. return;
  82. }
  83. for (int i = 0; i < count; i++) {
  84. var tile = new Tile ();
  85. tiles.Add (tile);
  86. Add (tile.View);
  87. if (i > 0) {
  88. var currentPos = Pos.Percent ((100 / count) * i);
  89. splitterDistances.Add (currentPos);
  90. var line = new SplitContainerLineView (this, i-1);
  91. Add (line);
  92. splitterLines.Add (line);
  93. }
  94. }
  95. LayoutSubviews ();
  96. }
  97. /// <summary>
  98. /// Orientation of the dividing line (Horizontal or Vertical).
  99. /// </summary>
  100. public Orientation Orientation {
  101. get { return orientation; }
  102. set {
  103. orientation = value;
  104. LayoutSubviews ();
  105. }
  106. }
  107. public override void LayoutSubviews ()
  108. {
  109. var contentArea = Bounds;
  110. if (HasBorder ()) {
  111. // TODO: Bound with Max/Min
  112. contentArea = new Rect (
  113. contentArea.X + 1,
  114. contentArea.Y + 1,
  115. Math.Max (0, contentArea.Width - 2),
  116. Math.Max (0, contentArea.Height - 2));
  117. } else if (HasAnyTitles () && IsRootSplitContainer ()) {
  118. // TODO: Bound with Max/Min
  119. contentArea = new Rect (
  120. contentArea.X,
  121. contentArea.Y + 1,
  122. contentArea.Width,
  123. Math.Max (0, contentArea.Height - 1));
  124. }
  125. Setup (contentArea);
  126. base.LayoutSubviews ();
  127. }
  128. /// <summary>
  129. /// <para>Distance Horizontally or Vertically to the splitter line when
  130. /// neither view is collapsed.
  131. /// </para>
  132. /// <para>Only absolute values (e.g. 10) and percent values (i.e. <see cref="Pos.Percent(float)"/>)
  133. /// are supported for this property.</para>
  134. /// </summary>
  135. public void SetSplitterPos (int idx, Pos value)
  136. {
  137. if (!(value is Pos.PosAbsolute) && !(value is Pos.PosFactor)) {
  138. throw new ArgumentException ($"Only Percent and Absolute values are supported. Passed value was {value.GetType ().Name}");
  139. }
  140. splitterDistances [idx] = value;
  141. GetRootSplitContainer ().LayoutSubviews ();
  142. OnSplitterMoved (idx);
  143. }
  144. /// <inheritdoc/>
  145. public override bool OnEnter (View view)
  146. {
  147. Driver.SetCursorVisibility (CursorVisibility.Invisible);
  148. return base.OnEnter (view);
  149. }
  150. /// <inheritdoc/>
  151. public override void Redraw (Rect bounds)
  152. {
  153. var childTitles = new List<ChildSplitterLine> ();
  154. Driver.SetAttribute (ColorScheme.Normal);
  155. Clear ();
  156. base.Redraw (bounds);
  157. var lc = new LineCanvas ();
  158. var allLines = GetAllChildSplitContainerLineViewRecursively (this);
  159. if (IsRootSplitContainer ()) {
  160. if (HasBorder ()) {
  161. lc.AddLine (new Point (0, 0), bounds.Width - 1, Orientation.Horizontal, IntegratedBorder);
  162. lc.AddLine (new Point (0, 0), bounds.Height - 1, Orientation.Vertical, IntegratedBorder);
  163. lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Width + 1, Orientation.Horizontal, IntegratedBorder);
  164. lc.AddLine (new Point (bounds.Width - 1, bounds.Height - 1), -bounds.Height + 1, Orientation.Vertical, IntegratedBorder);
  165. }
  166. foreach (var line in allLines.Where (l => l.Visible)) {
  167. bool isRoot = splitterLines.Contains (line);
  168. line.ViewToScreen (0, 0, out var x1, out var y1);
  169. var origin = ScreenToView (x1, y1);
  170. var length = line.Orientation == Orientation.Horizontal ?
  171. line.Frame.Width - 1 :
  172. line.Frame.Height - 1;
  173. if (!isRoot) {
  174. if (line.Orientation == Orientation.Horizontal) {
  175. origin.X -= 1;
  176. } else {
  177. origin.Y -= 1;
  178. }
  179. length += 2;
  180. childTitles.Add (
  181. new ChildSplitterLine (line));
  182. }
  183. lc.AddLine (origin, length, line.Orientation, IntegratedBorder);
  184. }
  185. }
  186. Driver.SetAttribute (ColorScheme.Normal);
  187. lc.Draw (this, bounds);
  188. // Redraw the lines so that focus/drag symbol renders
  189. foreach (var line in allLines) {
  190. line.DrawSplitterSymbol ();
  191. }
  192. foreach (var child in childTitles) {
  193. child.DrawTitles ();
  194. }
  195. // Draw Titles over Border
  196. for (int i = 0; i < tiles.Count; i++) {
  197. var tile = tiles [i];
  198. if (tile.View.Visible && tile.Title.Length > 0) {
  199. var screen = i == 0 ?
  200. ViewToScreen (new Rect (0, 0, bounds.Width, 1)) :
  201. ViewToScreen (splitterLines [i - 1].Frame);
  202. Driver.SetAttribute (tile.View.HasFocus ? ColorScheme.HotNormal : ColorScheme.Normal);
  203. Driver.DrawWindowTitle (new Rect (screen.X, screen.Y, tile.View.Frame.Width, 0), tile.Title, 0, 0, 0, 0);
  204. }
  205. }
  206. }
  207. /// <summary>
  208. /// Converts <see cref="View1"/> from a regular <see cref="View"/>
  209. /// container to a new nested <see cref="SplitView"/>. If <see cref="View1"/>
  210. /// is already a <see cref="SplitView"/> then returns false.
  211. /// </summary>
  212. /// <remarks>After successful splitting, the returned container's <see cref="View1"/>
  213. /// will contain the original content and <see cref="View1Title"/> (if any) while
  214. /// <see cref="View2"/> will be empty and available for adding to.
  215. /// for adding to.</remarks>
  216. /// <param name="result">The new <see cref="SplitView"/> now showing in
  217. /// <see cref="View1"/> or the existing one if it was already been converted before.</param>
  218. /// <returns><see langword="true"/> if a <see cref="View"/> was converted to a new nested
  219. /// <see cref="SplitView"/>. <see langword="false"/> if it was already a nested
  220. /// <see cref="SplitView"/></returns>
  221. public bool TrySplitView(int idx, out SplitView result)
  222. {
  223. // when splitting a view into 2 sub views we will need to migrate
  224. // the title too
  225. var tile = tiles [idx];
  226. var title = tile.Title;
  227. View toMove = tile.View;
  228. if (toMove is SplitView existing) {
  229. result = existing;
  230. return false;
  231. }
  232. var newContainer = new SplitView {
  233. Width = Dim.Fill (),
  234. Height = Dim.Fill (),
  235. parentSplitView = this,
  236. };
  237. // Take everything out of the View we are moving
  238. var childViews = toMove.Subviews.ToArray();
  239. toMove.RemoveAll ();
  240. // Remove the view itself and replace it with the new SplitContainer
  241. Remove (toMove);
  242. Add (newContainer);
  243. tile.View = newContainer;
  244. var newTileView1 = newContainer.tiles [0].View;
  245. // Add the original content into the first view of the new container
  246. foreach (var childView in childViews) {
  247. newTileView1.Add (childView);
  248. }
  249. result = newContainer;
  250. return true;
  251. }
  252. private List<SplitContainerLineView> GetAllChildSplitContainerLineViewRecursively (View v)
  253. {
  254. var lines = new List<SplitContainerLineView> ();
  255. foreach (var sub in v.Subviews) {
  256. if (sub is SplitContainerLineView s) {
  257. if (s.Parent.GetRootSplitContainer () == this) {
  258. lines.Add (s);
  259. }
  260. } else {
  261. lines.AddRange (GetAllChildSplitContainerLineViewRecursively (sub));
  262. }
  263. }
  264. return lines;
  265. }
  266. private bool IsRootSplitContainer ()
  267. {
  268. // TODO: don't want to layout subviews since the parent recursively lays them all out
  269. return parentSplitView == null;
  270. }
  271. private SplitView GetRootSplitContainer ()
  272. {
  273. SplitView root = this;
  274. while (root.parentSplitView != null) {
  275. root = root.parentSplitView;
  276. }
  277. return root;
  278. }
  279. private void Setup (Rect bounds)
  280. {
  281. if (bounds.IsEmpty) {
  282. return;
  283. }
  284. for (int i = 0; i < splitterLines.Count; i++) {
  285. var line = splitterLines[i];
  286. line.Orientation = Orientation;
  287. line.Width = orientation == Orientation.Vertical
  288. ? 1 : Dim.Fill ();
  289. line.Height = orientation == Orientation.Vertical
  290. ? Dim.Fill () : 1;
  291. line.LineRune = orientation == Orientation.Vertical ?
  292. Driver.VLine : Driver.HLine;
  293. if (orientation == Orientation.Vertical) {
  294. line.X = splitterDistances [i];
  295. }
  296. else {
  297. line.Y = splitterDistances [i];
  298. }
  299. }
  300. RespectMinimumTileSizes ();
  301. for (int i = 0; i < tiles.Count; i++) {
  302. var tile = tiles [i];
  303. // TODO: Deal with lines being Visibility false
  304. if (Orientation == Orientation.Vertical) {
  305. tile.View.X = i == 0 ? 0 : Pos.Right (splitterLines [i - 1]);
  306. tile.View.Y = bounds.Y;
  307. tile.View.Height = bounds.Height;
  308. // Take a copy so it is const for the lamda
  309. int i2 = i;
  310. // if it is not the last tile then fill horizontally right to next line
  311. tile.View.Width = i + 1 < tiles.Count
  312. ? new Dim.DimFunc (
  313. () => splitterDistances [i2].Anchor (bounds.Width))
  314. : Dim.Fill (HasBorder () ? 1 : 0);
  315. } else {
  316. tile.View.X = bounds.X;
  317. tile.View.Y = i == 0 ? 0 : Pos.Bottom (splitterLines [i - 1]);
  318. tile.View.Width = bounds.Width;
  319. // Take a copy so it is const for the lamda
  320. int i2 = i;
  321. // if it is not the last tile then fill vertically down to next line
  322. tile.View.Height = i + 1 < tiles.Count
  323. ? new Dim.DimFunc (
  324. () => splitterDistances [i2].Anchor (bounds.Height))
  325. : Dim.Fill (HasBorder () ? 1 : 0);
  326. }
  327. }
  328. }
  329. private void RespectMinimumTileSizes ()
  330. {
  331. // TODO: implement this
  332. /*
  333. // if we are not yet initialized then we don't know
  334. // how big we are and therefore cannot sensibly calculate
  335. // how big the views will be with a given SplitterDistance
  336. if (!IsInitialized) {
  337. return pos;
  338. }
  339. var view1MinSize = View1MinSize;
  340. var view2MinSize = View2MinSize;
  341. // how much space is there?
  342. var availableSpace = Orientation == Orientation.Horizontal
  343. ? this.Bounds.Height
  344. : this.Bounds.Width;
  345. // if there is a border then there is less space
  346. // for the views so we need to make size restrictions
  347. // tighter.
  348. if (HasBorder ()) {
  349. view1MinSize++;
  350. view2MinSize++;
  351. }
  352. // we probably haven't finished layout even if IsInitialized is true :(
  353. if (availableSpace <= 0) {
  354. return pos;
  355. }
  356. var idealPosition = pos.Anchor (availableSpace);
  357. // bad position because not enough space for View1
  358. if (idealPosition < view1MinSize) {
  359. // TODO: we should preserve Absolute/Percent status here not just force it to absolute
  360. return (Pos)Math.Min (view1MinSize, availableSpace);
  361. }
  362. // bad position because not enough space for View2
  363. if (availableSpace - idealPosition <= view2MinSize) {
  364. // TODO: we should preserve Absolute/Percent status here not just force it to absolute
  365. // +1 is to allow space for the splitter
  366. return (Pos)Math.Max (availableSpace - (view2MinSize + 1), 0);
  367. }
  368. // this splitter position is fine, there is enough space for everyone
  369. return pos;*/
  370. }
  371. private class SplitContainerLineView : LineView {
  372. public SplitView Parent { get; private set; }
  373. public int Idx { get; }
  374. Point? dragPosition;
  375. Pos dragOrignalPos;
  376. public Point? moveRuneRenderLocation;
  377. public SplitContainerLineView (SplitView parent, int idx)
  378. {
  379. CanFocus = true;
  380. TabStop = true;
  381. this.Parent = parent;
  382. Idx = idx;
  383. base.AddCommand (Command.Right, () => {
  384. return MoveSplitter (1, 0);
  385. });
  386. base.AddCommand (Command.Left, () => {
  387. return MoveSplitter (-1, 0);
  388. });
  389. base.AddCommand (Command.LineUp, () => {
  390. return MoveSplitter (0, -1);
  391. });
  392. base.AddCommand (Command.LineDown, () => {
  393. return MoveSplitter (0, 1);
  394. });
  395. AddKeyBinding (Key.CursorRight, Command.Right);
  396. AddKeyBinding (Key.CursorLeft, Command.Left);
  397. AddKeyBinding (Key.CursorUp, Command.LineUp);
  398. AddKeyBinding (Key.CursorDown, Command.LineDown);
  399. }
  400. public override bool ProcessKey (KeyEvent kb)
  401. {
  402. if (!CanFocus || !HasFocus) {
  403. return base.ProcessKey (kb);
  404. }
  405. var result = InvokeKeybindings (kb);
  406. if (result != null)
  407. return (bool)result;
  408. return base.ProcessKey (kb);
  409. }
  410. public override void PositionCursor ()
  411. {
  412. base.PositionCursor ();
  413. var location = moveRuneRenderLocation ??
  414. new Point (Bounds.Width / 2, Bounds.Height / 2);
  415. Move (location.X, location.Y);
  416. }
  417. public override bool OnEnter (View view)
  418. {
  419. Driver.SetCursorVisibility (CursorVisibility.Default);
  420. PositionCursor ();
  421. return base.OnEnter (view);
  422. }
  423. public override void Redraw (Rect bounds)
  424. {
  425. base.Redraw (bounds);
  426. DrawSplitterSymbol ();
  427. }
  428. public void DrawSplitterSymbol ()
  429. {
  430. if (CanFocus && HasFocus) {
  431. var location = moveRuneRenderLocation ??
  432. new Point (Bounds.Width / 2, Bounds.Height / 2);
  433. AddRune (location.X, location.Y, Driver.Diamond);
  434. }
  435. }
  436. public override bool MouseEvent (MouseEvent mouseEvent)
  437. {
  438. if (!CanFocus) {
  439. return true;
  440. }
  441. if (!dragPosition.HasValue && (mouseEvent.Flags == MouseFlags.Button1Pressed)) {
  442. // Start a Drag
  443. SetFocus ();
  444. Application.EnsuresTopOnFront ();
  445. if (mouseEvent.Flags == MouseFlags.Button1Pressed) {
  446. dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
  447. dragOrignalPos = Orientation == Orientation.Horizontal ? Y : X;
  448. Application.GrabMouse (this);
  449. if (Orientation == Orientation.Horizontal) {
  450. } else {
  451. moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Bounds.Height - 2, mouseEvent.Y)));
  452. }
  453. }
  454. return true;
  455. } else if (
  456. dragPosition.HasValue &&
  457. (mouseEvent.Flags == (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition))) {
  458. // Continue Drag
  459. // how far has user dragged from original location?
  460. if (Orientation == Orientation.Horizontal) {
  461. int dy = mouseEvent.Y - dragPosition.Value.Y;
  462. Parent.splitterDistances [Idx] = Offset (Y, dy);
  463. moveRuneRenderLocation = new Point (mouseEvent.X, 0);
  464. } else {
  465. int dx = mouseEvent.X - dragPosition.Value.X;
  466. Parent.splitterDistances [Idx] = Offset (X, dx);
  467. moveRuneRenderLocation = new Point (0, Math.Max (1, Math.Min (Bounds.Height - 2, mouseEvent.Y)));
  468. }
  469. Parent.SetNeedsDisplay ();
  470. return true;
  471. }
  472. if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Released) && dragPosition.HasValue) {
  473. // End Drag
  474. Application.UngrabMouse ();
  475. Driver.UncookMouse ();
  476. FinalisePosition (
  477. dragOrignalPos,
  478. Orientation == Orientation.Horizontal ? Y : X);
  479. dragPosition = null;
  480. moveRuneRenderLocation = null;
  481. }
  482. return false;
  483. }
  484. private bool MoveSplitter (int distanceX, int distanceY)
  485. {
  486. if (Orientation == Orientation.Vertical) {
  487. // Cannot move in this direction
  488. if (distanceX == 0) {
  489. return false;
  490. }
  491. var oldX = X;
  492. FinalisePosition (oldX, (Pos)Offset (X, distanceX));
  493. return true;
  494. } else {
  495. // Cannot move in this direction
  496. if (distanceY == 0) {
  497. return false;
  498. }
  499. var oldY = Y;
  500. FinalisePosition (oldY, (Pos)Offset (Y, distanceY));
  501. return true;
  502. }
  503. }
  504. private Pos Offset (Pos pos, int delta)
  505. {
  506. var posAbsolute = pos.Anchor (Orientation == Orientation.Horizontal ?
  507. Parent.Bounds.Height : Parent.Bounds.Width);
  508. return posAbsolute + delta;
  509. }
  510. /// <summary>
  511. /// <para>
  512. /// Moves <see cref="Parent"/> <see cref="SplitView.SplitterDistance"/> to
  513. /// <see cref="Pos"/> <paramref name="newValue"/> preserving <see cref="Pos"/> format
  514. /// (absolute / relative) that <paramref name="oldValue"/> had.
  515. /// </para>
  516. /// <remarks>This ensures that if splitter location was e.g. 50% before and you move it
  517. /// to absolute 5 then you end up with 10% (assuming a parent had 50 width). </remarks>
  518. /// </summary>
  519. /// <param name="oldValue"></param>
  520. /// <param name="newValue"></param>
  521. private void FinalisePosition (Pos oldValue, Pos newValue)
  522. {
  523. if (oldValue is Pos.PosFactor) {
  524. if (Orientation == Orientation.Horizontal) {
  525. Parent.splitterDistances [Idx] = ConvertToPosFactor (newValue, Parent.Bounds.Height);
  526. } else {
  527. Parent.splitterDistances [Idx] = ConvertToPosFactor (newValue, Parent.Bounds.Width);
  528. }
  529. } else {
  530. Parent.splitterDistances [Idx] = newValue;
  531. }
  532. }
  533. /// <summary>
  534. /// <para>
  535. /// Determines the absolute position of <paramref name="p"/> and
  536. /// returns a <see cref="Pos.PosFactor"/> that describes the percentage of that.
  537. /// </para>
  538. /// <para>Effectively turning any <see cref="Pos"/> into a <see cref="Pos.PosFactor"/>
  539. /// (as if created with <see cref="Pos.Percent(float)"/>)</para>
  540. /// </summary>
  541. /// <param name="p">The <see cref="Pos"/> to convert to <see cref="Pos.Percent(float)"/></param>
  542. /// <param name="parentLength">The Height/Width that <paramref name="p"/> lies within</param>
  543. /// <returns></returns>
  544. private Pos ConvertToPosFactor (Pos p, int parentLength)
  545. {
  546. // calculate position in the 'middle' of the cell at p distance along parentLength
  547. float position = p.Anchor (parentLength) + 0.5f;
  548. return new Pos.PosFactor (position / parentLength);
  549. }
  550. }
  551. private bool HasBorder ()
  552. {
  553. return IntegratedBorder != BorderStyle.None;
  554. }
  555. private bool HasAnyTitles ()
  556. {
  557. return tiles.Any (t => t.Title.Length > 0);
  558. }
  559. private class ChildSplitterLine {
  560. readonly SplitContainerLineView currentLine;
  561. internal ChildSplitterLine (SplitContainerLineView currentLine)
  562. {
  563. this.currentLine = currentLine;
  564. }
  565. internal void DrawTitles ()
  566. {
  567. //TODO: Implement this
  568. /*if(currentLine.Orientation == Orientation.Horizontal)
  569. {
  570. var screenRect = currentLine.ViewToScreen (
  571. new Rect(0,0,currentLine.Frame.Width,currentLine.Frame.Height));
  572. Driver.DrawWindowTitle (screenRect, currentLine.Parent.View2Title, 0, 0, 0, 0);
  573. }*/
  574. }
  575. }
  576. }
  577. /// <summary>
  578. /// Provides data for <see cref="SplitContainer"/> events.
  579. /// </summary>
  580. public class SplitterEventArgs : EventArgs {
  581. /// <summary>
  582. /// Creates a new instance of the <see cref="SplitterEventArgs"/> class.
  583. /// </summary>
  584. /// <param name="splitContainer"></param>
  585. /// <param name="splitterDistance"></param>
  586. public SplitterEventArgs (SplitView splitContainer, int idx, Pos splitterDistance)
  587. {
  588. SplitterDistance = splitterDistance;
  589. SplitContainer = splitContainer;
  590. Idx = idx;
  591. }
  592. /// <summary>
  593. /// New position of the <see cref="SplitView.SplitterDistance"/>
  594. /// </summary>
  595. public Pos SplitterDistance { get; }
  596. /// <summary>
  597. /// Container (sender) of the event.
  598. /// </summary>
  599. public SplitView SplitContainer { get; }
  600. /// <summary>
  601. /// The splitter that is being moved (use when <see cref="SplitContainer"/>
  602. /// has more than 2 panels).
  603. /// </summary>
  604. public int Idx { get; }
  605. }
  606. /// <summary>
  607. /// Represents a method that will handle splitter events.
  608. /// </summary>
  609. public delegate void SplitterEventHandler (object sender, SplitterEventArgs e);
  610. }