| 1 | /*
|
|---|
| 2 | * Copyright (c) 2021 Jiri Svoboda
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /** @addtogroup nav
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /**
|
|---|
| 33 | * @file Navigator panel types
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef TYPES_PANEL_H
|
|---|
| 37 | #define TYPES_PANEL_H
|
|---|
| 38 |
|
|---|
| 39 | #include <adt/list.h>
|
|---|
| 40 | #include <gfx/color.h>
|
|---|
| 41 | #include <gfx/coord.h>
|
|---|
| 42 | #include <ipc/loc.h>
|
|---|
| 43 | #include <ui/window.h>
|
|---|
| 44 | #include <stdint.h>
|
|---|
| 45 |
|
|---|
| 46 | /** Panel entry attributes */
|
|---|
| 47 | typedef struct {
|
|---|
| 48 | /** File name */
|
|---|
| 49 | const char *name;
|
|---|
| 50 | /** File size */
|
|---|
| 51 | uint64_t size;
|
|---|
| 52 | /** @c true iff entry is a directory */
|
|---|
| 53 | bool isdir;
|
|---|
| 54 | /** Service number for service special entries */
|
|---|
| 55 | service_id_t svc;
|
|---|
| 56 | } panel_entry_attr_t;
|
|---|
| 57 |
|
|---|
| 58 | /** Panel entry */
|
|---|
| 59 | typedef struct {
|
|---|
| 60 | /** Containing panel */
|
|---|
| 61 | struct panel *panel;
|
|---|
| 62 | /** Link to @c panel->entries */
|
|---|
| 63 | link_t lentries;
|
|---|
| 64 | /** File name */
|
|---|
| 65 | char *name;
|
|---|
| 66 | /** File size */
|
|---|
| 67 | uint64_t size;
|
|---|
| 68 | /** @c true iff entry is a directory */
|
|---|
| 69 | bool isdir;
|
|---|
| 70 | /** Service number for service special entries */
|
|---|
| 71 | service_id_t svc;
|
|---|
| 72 | } panel_entry_t;
|
|---|
| 73 |
|
|---|
| 74 | /** Navigator panel
|
|---|
| 75 | *
|
|---|
| 76 | * This is a custom UI control.
|
|---|
| 77 | */
|
|---|
| 78 | typedef struct panel {
|
|---|
| 79 | /** Base control object */
|
|---|
| 80 | struct ui_control *control;
|
|---|
| 81 |
|
|---|
| 82 | /** Containing window */
|
|---|
| 83 | ui_window_t *window;
|
|---|
| 84 |
|
|---|
| 85 | /** Callbacks */
|
|---|
| 86 | struct panel_cb *cb;
|
|---|
| 87 |
|
|---|
| 88 | /** Callback argument */
|
|---|
| 89 | void *cb_arg;
|
|---|
| 90 |
|
|---|
| 91 | /** Panel rectangle */
|
|---|
| 92 | gfx_rect_t rect;
|
|---|
| 93 |
|
|---|
| 94 | /** Panel color */
|
|---|
| 95 | gfx_color_t *color;
|
|---|
| 96 |
|
|---|
| 97 | /** Panel cursor color */
|
|---|
| 98 | gfx_color_t *curs_color;
|
|---|
| 99 |
|
|---|
| 100 | /** Active border color */
|
|---|
| 101 | gfx_color_t *act_border_color;
|
|---|
| 102 |
|
|---|
| 103 | /** Directory-type entry color */
|
|---|
| 104 | gfx_color_t *dir_color;
|
|---|
| 105 |
|
|---|
| 106 | /** Service-type entry color */
|
|---|
| 107 | gfx_color_t *svc_color;
|
|---|
| 108 |
|
|---|
| 109 | /** Panel entries (list of panel_entry_t) */
|
|---|
| 110 | list_t entries;
|
|---|
| 111 |
|
|---|
| 112 | /** Number of entries */
|
|---|
| 113 | size_t entries_cnt;
|
|---|
| 114 |
|
|---|
| 115 | /** First entry of current page */
|
|---|
| 116 | panel_entry_t *page;
|
|---|
| 117 |
|
|---|
| 118 | /** Index of first entry of current page */
|
|---|
| 119 | size_t page_idx;
|
|---|
| 120 |
|
|---|
| 121 | /** Cursor position */
|
|---|
| 122 | panel_entry_t *cursor;
|
|---|
| 123 |
|
|---|
| 124 | /** Index of entry under cursor */
|
|---|
| 125 | size_t cursor_idx;
|
|---|
| 126 |
|
|---|
| 127 | /** @c true iff the panel is active */
|
|---|
| 128 | bool active;
|
|---|
| 129 |
|
|---|
| 130 | /** Directory */
|
|---|
| 131 | char *dir;
|
|---|
| 132 | } panel_t;
|
|---|
| 133 |
|
|---|
| 134 | /** Panel callbacks */
|
|---|
| 135 | typedef struct panel_cb {
|
|---|
| 136 | /** Request panel activation */
|
|---|
| 137 | void (*activate_req)(void *, panel_t *);
|
|---|
| 138 | } panel_cb_t;
|
|---|
| 139 |
|
|---|
| 140 | #endif
|
|---|
| 141 |
|
|---|
| 142 | /** @}
|
|---|
| 143 | */
|
|---|