summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/screen/screen.c
blob: 52015be7c0cb9bf1c10fd8624b5c0c5b9844b4c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdlib.h>
#include <string.h>

#include "eve.h"
#include "eve_kbd.h"

#include "screen.h"
#include "window.h"

int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h) {
    memset(screen, 0, sizeof(EVEScreen));
    screen->w = w;
    screen->h = h;
}

void eve_screen_set_kbd(EVEScreen *screen, EVEKbd *kbd) {
    screen->kbd = kbd;
}

EVEKbd *eve_screen_get_kbd(EVEScreen *screen) {
    return screen->kbd;
}

void eve_screen_show_kbd(EVEScreen *screen) {
    screen->kbd_active = 1;
}

void eve_screen_hide_kbd(EVEScreen *screen) {
    screen->kbd_active = 0;
}

int eve_screen_win_insert(EVEScreen *screen, EVEWindow *window, int idx) {
    if (idx) {
        int i;
        EVEWindow *h = screen->win_head;

        for (i=1; i<idx; i++) {
            h = h->next;
            if (h == NULL) return EVE_ERR;
        }
        window->next = h->next;
        h->next = window;
    } else {
        window->next = screen->win_head;
        screen->win_head = window;
    }
    if (window->next == NULL) screen->win_tail = window;
    return EVE_OK;
}

int eve_screen_win_remove(EVEScreen *screen, EVEWindow *window) {
    EVEWindow *h = screen->win_head;
    if (h == NULL) return EVE_ERR;
    if (h == window) {
        screen->win_head = window->next;
        if (screen->win_head == NULL) screen->win_tail = NULL;
    } else {
        while (h->next && (h->next != window)) h = h->next;
        if (h->next == NULL) return EVE_ERR;

        h->next = window->next;
        if (h->next == NULL) screen->win_tail = h;
    }
}

void eve_screen_win_append(EVEScreen *screen, EVEWindow *window) {
    screen->win_tail->next = window;
    screen->win_tail = window;
}

void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) {
    eve_touch_clear_opt();
}