|
ArchitectureTo facilitate modularity the split window tool is split into two levels, a bottom level and a top level. It should be possible to use the bottom level split window if one wants fine-grained control of the behaviour of the split window. And use the top-level window if one wants the tools to take hand of the details and one can live with the default behaviour. The top level split window is to be implemented on top of the bottom level split window. Bottom Level Split WindowThe bottom level handles the placement of the windows in the split window. It resizes the child windows when the rows and columns change sizes. The code prefix in the bottom level is "splitwin". Split Window CreationFirst the split window is created (invisible) then its different properties are set and the panes are created and finally the split window is made visible by the splitwin_Show call. The bottom level splitwin_create predicate takes the callback predicates as arguments whereas the top level split_create predicate does not. Resize callbackWhen the cursor is placed over a resize bar the splitwin_resize_cb predicate is called to find out if the resize bar is fixed and if it's not how much it should be possible to move it in each direction. There are three possibilities
If the callback fails the bar should not be moved. If the allowable movement is negative the bar can be moved freely in that direction. Update callbackCalled to draw the resize bars and the margins. The bottom level asks the top level to draw the resize bars and the margins. Setting the Pane Size ProgrammaticallyThe problem with setting the pane sizes programmatically is that the total size of the windows will have to fit inside the split window. Setting the size of a pane works like dragging the right bottom cross of that pane. Of course without the visual feedback Inserting a Column or a RowInserting a column at position N push the column to the right just like resizing does. It also changes the coordinates of all the panes to the right of that column. If we have three columns (numbered 0,1,2) inserting a column at position 1 moves the column 1 and 2 to be column 2 and 3. If the column is inserted as the rightmost column it pushes to the old rightmost column now the column to the left of the newly inserted column. Insertion of rows works the same way. Deleting a Column or a RowDeleting a column changes the coordinates of the columns to the right of the column. If we have a split window with three columns 0,1,2 and delete column 1 column 2 becomes column 1. The column to the right takes the space freed. Rows are deleted like columns. Top level Split WindowIn the top level split window you set some properties and it takes care of the communication with the bottom level split window. So a user of the top-level split window should not take care of any callback predicates. Visual Appearance of Resize BarsIt should be possible to choose between 3D resize bars, plain 2D resize bars. |