1 module unde.guitk.background;
2 
3 import derelict.sdl2.sdl;
4 import derelict.sdl2.ttf;
5 import derelict.sdl2.image;
6 
7 import std.stdio;
8 import std..string;
9 
10 import unde.global_state;
11 import unde.guitk.lib;
12 import unde.keybar.lib;
13 import unde.lib;
14 
15 class Background:UIEntry
16 {
17     private SDL_Rect _rect;
18     private UIPage _page;
19     private bool _focus;
20 
21     private string label;
22     private SDL_Color color;
23     private int fontsize;
24     
25     this(UIPage page, GlobalState gs)
26     {
27         _page = page;
28         _rect.x = 0;
29         _rect.y = 0;
30         _rect.w = gs.screen.w;
31         _rect.h = gs.screen.h;
32     }
33 
34     @property SDL_Rect rect() {return _rect;}
35     
36     void on_draw(GlobalState gs)
37     {
38         auto r = SDL_RenderCopy(gs.renderer, gs.texture_black, null, &_rect);
39         if (r < 0)
40         {
41             writefln( "Background.on_draw(), 1: Error while render copy: %s",
42                     SDL_GetError().fromStringz() );
43         }
44     }
45 
46     void process_event(GlobalState gs, SDL_Event event)
47     {
48     }
49 
50     @property UIPage page() {return _page;}
51 
52     @property ref bool focus() {return _focus;}
53 
54     void on_set_focus(GlobalState gs)
55     {
56     }
57 
58     void on_unset_focus(GlobalState gs)
59     {
60     }
61 
62     private void
63     close_page(GlobalState gs)
64     {
65         _page.show = false;
66     }
67 
68     void set_keybar(GlobalState gs)
69     {
70         gs.keybar.handlers.clear();
71         gs.keybar.handlers_down.clear();
72         gs.keybar.handlers_double.clear();
73 
74         gs.keybar.handlers[SDL_SCANCODE_ESCAPE] = KeyHandler(&close_page, "Close layouts settings", "Esc");
75     }
76 }
77