|
| 1 | +Views |
| 2 | +===== |
| 3 | + |
| 4 | +**Views** within a window are used to layout controls or other views. |
| 5 | + |
| 6 | +Note: a Panel view is a collapsable view. |
| 7 | + |
| 8 | +Collection View |
| 9 | +--------------- |
| 10 | + |
| 11 | +A [**collection** view](../nimx/collection_view.nim) will layout a collection (sequence) of items in a direction of either left-to-right or top-down, |
| 12 | +where items is a pre-defined size on the screen. |
| 13 | + |
| 14 | +Each item is wrapped in a subview. |
| 15 | + |
| 16 | +[See Test 7 code](../test/sample07_collections.nim) |
| 17 | + |
| 18 | +Expanding View |
| 19 | +-------------- |
| 20 | + |
| 21 | +An [**expanding** view](../nimx/expanding_view.nim) has a button that can be clicked to expand the view to display (or hide) the full content of the view. |
| 22 | + |
| 23 | +[See Test 11 code](../test/sample11_expanded_views.nim) |
| 24 | + |
| 25 | +Form View |
| 26 | +--------- |
| 27 | + |
| 28 | +A **form** view lays out a specified number of label/Text_Field pairs. The labels and values of the Text Fields can then be set with the `setValue()` |
| 29 | +or retrieved with the `inputValue()` procs. |
| 30 | + |
| 31 | +Currently, to have different input types other than a Text Field would require overloading the [FormView definition](../nimx/form_view.nim). |
| 32 | + |
| 33 | + |
| 34 | +Horizontal List View |
| 35 | +-------------------- |
| 36 | + |
| 37 | +A scrollable [horizontal list](../nimx/horizontal_list_view.nim) of views |
| 38 | + |
| 39 | + |
| 40 | +Image View |
| 41 | +---------- |
| 42 | + |
| 43 | +[Image view](../nimx/image_view.nim) is a view for drawing static images. |
| 44 | + |
| 45 | +Filling rules: |
| 46 | + - **NoFill** is drawn from the top-left corner with its size |
| 47 | + - **Stretch** is stretched to the view size |
| 48 | + - **Tile** all of the view |
| 49 | + - **FitWidth** to the view's width |
| 50 | + - **FitHeight** to the view's height |
| 51 | + - **NinePartImage** |
| 52 | + |
| 53 | +Inspector View |
| 54 | +-------------- |
| 55 | + |
| 56 | +A vertical layout [view](../nimx/inspector_view.nim) for inspecting object properties. |
| 57 | + |
| 58 | +Outline View |
| 59 | +------------ |
| 60 | + |
| 61 | +An [**Outline** view](../nimx/outline_view.nim) allows dragging of child elements to different levels of a hierarchical list. |
| 62 | + |
| 63 | +Panel View |
| 64 | +---------- |
| 65 | + |
| 66 | +A collapseable [view](../nimx/panel_view.nim) that allows the showing/hiding of its content. |
| 67 | + |
| 68 | +The [inspector Panel](../nimx/inspector_panel.nim) is collapseable Inspector View. |
| 69 | + |
| 70 | +Scroll View |
| 71 | +----------- |
| 72 | + |
| 73 | +[See the main test code](../test/main.nim) |
| 74 | + |
| 75 | +Split View |
| 76 | +----------- |
| 77 | + |
| 78 | +A [view](../nimx/split_view.nim) with a movable divider between sections for resizing the sub-views. |
| 79 | + |
| 80 | +``` |
| 81 | +import nimx / [ window, layout, button, text_field, split_view, scroll_view, context ] |
| 82 | +
|
| 83 | +let red = newColor(1, 0, 0) |
| 84 | +let blue = newColor(0, 0, 1) |
| 85 | +let yellow = newColor(1, 1, 0) |
| 86 | +
|
| 87 | +runApplication: |
| 88 | + let w = newWindow(newRect(50, 50, 500, 150)) |
| 89 | + w.makeLayout: # DSL follows |
| 90 | + - SplitView: |
| 91 | + frame == inset(super, 10) |
| 92 | +
|
| 93 | + - ScrollView: |
| 94 | + backgroundColor: blue |
| 95 | + size >= [200, 500] |
| 96 | + - View: |
| 97 | + backgroundColor: red |
| 98 | + size == [100, 900] |
| 99 | +
|
| 100 | + - View: |
| 101 | + backgroundColor: yellow |
| 102 | + width >= 100 |
| 103 | +``` |
| 104 | + |
| 105 | +Stack View |
| 106 | +---------- |
| 107 | + |
| 108 | +A [vertical linear](../nimx/stack_view.nim) view. |
| 109 | + |
| 110 | +Table View |
| 111 | +---------- |
| 112 | + |
| 113 | +A [table or grid](../nimx/table_view.nim) view, with controls/view arranged in a rows and columns. |
0 commit comments