File: README.md

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (154 lines) | stat: -rw-r--r-- 3,711 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# lsp-ws-lib

LSP window subsystem core library.

This library provides abstraction layer for working with
window subsystem of the target software platform.

This library does not provide or use any global variables and can be
easily used with other versions of itself. Factroy function should be
used to build most suitable display instance.

It provides:
* Common event format definition and constants.
* Factory for building most suitable display.
* ws::IDisplay interface for accessing the graphics display.
* ws::IWindow interface for accessing windows.
* ws::IR3DBackend for accessing accelerated 3D rendering backends.
* Asynchronous data flow primitives:
  * IDataSource as a data source.
  * IDataSink as a data collector.
  * IEventHandler for handling events.
* Drawing primitives:
  * ws::Font to manage font properties.
  * ws::IGradient to manage gradients.
  * ws::ISurface to use drawing surfaces.

Requirements
======

The following packages need to be installed for building:

* gcc >= 4.9 (All OS)
* make >= 4.0 (All OS)
* cairo >= 1.14 (Linux, BSD)
* sndfile >= 1.0.25 (Linux, BSD)
* freetype (Linux, BSD)
* xlib (Linux, BSD)

Building
======

To build the library, perform the following commands:

```bash
make config # Configure the build
make fetch # Fetch dependencies from Git repository
make
sudo make install
```

To get more build options, run:

```bash
make help
```

To uninstall library, simply issue:

```bash
make uninstall
```

To clean all binary files, run:

```bash
make clean
```

To clean the whole project tree including configuration files, run:

```bash
make prune
```

Usage
======
```C++
#include <lsp-plug.in/ws/ws.h>

using namespace lsp;

// Event handler class for window events
class Handler: public ws::IEventHandler
{
    private:
        ws::IWindow    *pWnd;

    public:
        inline Handler(ws::IWindow *wnd)
        {
            pWnd        = wnd;
        }

        virtual status_t handle_event(const ws::event_t *ev)
        {
            // Triggered redraw request, just fill the window with some color
            if (ev->nType == ws::UIE_REDRAW)
            {
                Color c(0.0f, 0.5f, 0.75f);
                ws::ISurface *s = pWnd->get_surface();
                if (s != NULL)
                    s->clear(&c);

                return STATUS_OK;
            }
            
            // Triggered close request, force display to quit main loop
            if (ev->nType == ws::UIE_CLOSE)
            {
                pWnd->hide();
                pWnd->display()->quit_main();
            }
            
            // Call parent handler (can be omitted since 
            // IEventHandler::handle_event is just a stub method)
            return IEventHandler::handle_event(ev);
        }
};

int main(int argc, const char **argv)
{
	// Create display
    ws::IDisplay *dpy = ws::create_display(argc, &argv[1]);
    
    // Create window and initialize
    ws::IWindow *wnd = dpy->create_window();
    wnd->init();
    wnd->set_caption("Test window", "Test window");
    wnd->set_border_style(ws::BS_DIALOG);
    wnd->set_window_actions(ws::WA_MOVE | ws::WA_RESIZE | ws::WA_CLOSE);
    wnd->resize(320, 200);
    wnd->set_size_constraints(160, 100, 640, 400)

    // Show the window at the center of the screen
    ssize_t sw, sh;
    size_t screen = wnd->screen();
    dpy->screen_size(screen, &sw, &sh);
    wnd->move((sw - wnd->width()) / 2, (sh - wnd->height()) / 2);
    wnd->show();

	// Setup handler for the window
    Handler h(wnd);
    wnd->set_handler(&h);

    // Enter the main event loop
    dpy->main();

    // Destroy window and display
    wnd->destroy();
    delete wnd;
    ws::free_display(dpy);
}
    
```