summaryrefslogtreecommitdiff
path: root/src/dialog.h
blob: dd52bbe364252dff0fe0c696035d236b26caf27f (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
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
/**
 *
 * dialog.h
 *
 * Copyright (c) 2008 Douglas Young <rcxdude@gmail.com>
 * Input shaping adapted from FreeWins plugin
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 **/

#include <core/core.h>
#include <composite/composite.h>
#include <opengl/opengl.h>

#include "dialog_options.h"

#define ANIMATE_UP 1
#define ANIMATE_DOWN 2
#define ANIMATE_NONE 0

class DialogScreen :
    public PluginClassHandler <DialogScreen, CompScreen>,
    public ScreenInterface,
    public CompositeScreenInterface,
    public DialogOptions
{
    public:

	DialogScreen (CompScreen *s);

    public:

	CompositeScreen *cScreen;
	GLScreen	*gScreen;

	void
	preparePaint (int);

	void
	handleEvent (XEvent *);

	void
	optionChanged (CompOption *opt,
		       DialogOptions::Options);
};

class DialogWindow :
    public PluginClassHandler <DialogWindow, CompWindow>,
    public GLWindowInterface
{
    public:

	DialogWindow (CompWindow *);

    public:

	CompWindow *window;
	CompositeWindow *cWindow;
	GLWindow	*gWindow;
	bool		mFaded;

	Window		mOldTransient;

	bool		shouldFade ();

	bool
	glPaint (const GLWindowPaintAttrib &,
		 const GLMatrix		   &,
		 const CompRegion	   &,
		 unsigned int		     );
};

#define DIALOG_SCREEN(s)						       \
    DialogScreen *ds = DialogScreen::get (s);

#define DIALOG_WINDOW(w)						       \
    DialogWindow *dw = DialogWindow::get (w);

#define WIN_X(w) ((w)->x () - (w)->border ().left)
#define WIN_Y(w) ((w)->y () - (w)->border ().top)
#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)

#define SPEED (optionGetSpeed () * 0.0005f)

class DialogPluginVTable :
    public CompPlugin::VTableForScreenAndWindow <DialogScreen, DialogWindow>
{
    public:

	bool init ();
};