Add more assertions.
[tagua/yd.git] / src / movelist_p.h
blobe1aeee05f975eec05d44cefe268cb9ee4acb4919
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef MOVELIST_P_H
12 #define MOVELIST_P_H
14 #include <map>
15 #include <vector>
16 #include <boost/shared_ptr.hpp>
17 #include <QFont>
18 #include <QFontMetrics>
19 #include <QString>
20 #include <QColor>
21 #include "index.h"
22 #include "decoratedmove.h"
23 #include "kgamecanvas.h"
25 namespace MoveList {
27 typedef boost::shared_ptr<class Entry> EntryPtr;
28 typedef boost::shared_ptr<class Brace> BracePtr;
29 typedef boost::shared_ptr<class Text> TextPtr;
30 typedef boost::shared_ptr<class Comment> CommentPtr;
31 typedef std::vector<EntryPtr> History;
32 typedef std::map<int, History> Variations;
33 typedef std::map<int, BracePtr> Braces;
34 typedef std::map<int, CommentPtr> VComments;
36 class Settings {
37 public:
38 bool anim_enabled;
39 bool anim_moving;
40 bool anim_hideshow;
41 bool anim_highlight;
42 int anim_speed;
43 int anim_smoothness;
44 double anim_time;
45 QColor select_color;
46 QColor comment_color;
47 QString icons;
49 bool use_mv_font;
50 bool use_comm_font;
51 QFont mv_font;
52 QFontMetrics mv_fmetrics;
53 QFont sel_mv_font;
54 QFontMetrics sel_mv_fmetrics;
55 QFont comm_font;
56 QFontMetrics comm_fmetrics;
58 Settings()
59 : mv_fmetrics(QFont())
60 , sel_mv_fmetrics(QFont())
61 , comm_fmetrics(QFont()) {}
63 void load();
64 void save();
67 class FancyItem : public KGameCanvasItem {
68 public:
69 int time_pos;
70 QPoint target_pos;
71 QPoint old_pos;
73 int time_opacity;
74 int target_opacity;
75 int old_opacity;
77 bool highlighted;
78 int curr_highlight;
79 int time_highlight;
80 int target_highlight;
81 int old_highlight;
83 FancyItem(KGameCanvasAbstract* c = NULL)
84 : KGameCanvasItem(c)
85 , time_pos(-1)
86 , time_opacity(-1)
87 , highlighted(false)
88 , curr_highlight(0)
89 , time_highlight(-1) { }
90 bool showing();
91 void appear();
92 void disappear();
93 void goTo(QPoint pos);
94 void setHighlight(bool h);
95 virtual bool canStop() { return time_highlight==-1 && time_pos==-1 && time_opacity==-1; }
96 virtual void advance(int time);
97 virtual bool layered() const;
100 class Brace : public FancyItem {
101 public:
102 int width;
103 int height;
104 int depth;
105 Entry* entry;
106 int variation;
107 int time_height;
108 int target_height;
109 int old_height;
111 virtual void paint (QPainter *p);
112 virtual QRect rect () const;
113 void setHeight(int h);
114 virtual bool canStop() { return time_height==-1 && FancyItem::canStop(); }
115 virtual void advance(int time);
117 Brace(Entry* e, int var, KGameCanvasAbstract* c = NULL)
118 : FancyItem(c)
119 , width(0)
120 , height(0)
121 , entry(e)
122 , variation(var)
123 , time_height(-1) {
127 class Text : public FancyItem {
128 public:
129 int width;
130 int height;
131 int type;
132 bool selected;
133 QString text;
134 Entry *entry;
135 bool needs_update;
137 void doUpdate();
138 virtual void paint (QPainter *p);
139 virtual QRect rect () const;
141 Text(Entry* e, int t, KGameCanvasAbstract* c = NULL)
142 : FancyItem(c)
143 , width(0)
144 , height(0)
145 , type(t)
146 , selected(false)
147 , entry(e)
148 , needs_update(true) {}
151 class Comment : public FancyItem {
152 public:
153 int width;
154 int height;
155 QString text;
156 Entry *entry;
157 int variation;
158 bool needs_update;
160 void doUpdate();
161 virtual void paint (QPainter *p);
162 virtual QRect rect () const;
164 Comment(Entry* e, KGameCanvasAbstract* c = NULL, int v = -1)
165 : FancyItem(c)
166 , width(0)
167 , height(0)
168 , entry(e)
169 , variation(v)
170 , needs_update(true) {}
173 class Entry : public FancyItem {
174 public:
175 bool expanded;
176 bool hide_next;
177 bool selected;
178 QRect m_rect;
179 int m_ascent;
180 int childs_height;
181 int move_turn;
182 DecoratedMove move;
183 Index index;
184 bool needs_update;
186 TextPtr number;
187 TextPtr fregna;
188 CommentPtr comment;
190 Variations variations;
191 Braces braces;
192 VComments vcomments;
194 void doUpdate();
195 virtual void paint (QPainter *p);
196 virtual QRect rect () const;
197 virtual bool canStop() { return time_highlight==-1 && FancyItem::canStop(); }
199 Entry(int turn, const DecoratedMove& m, const Index& i, KGameCanvasAbstract* c = NULL)
200 : FancyItem(c)
201 , expanded(true)
202 , hide_next(false)
203 , selected(false)
204 , move_turn(turn)
205 , move(m)
206 , index(i)
207 , needs_update(true) {}
212 #endif //MOVELIST_P_H