diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-08-03 08:42:30 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-08-03 08:42:30 +0000 |
commit | a83adc7d6d0a16d08687a903da8a992e3affedcc (patch) | |
tree | 0ed81dca47756ac17bdfb9fad0e5e373d1358595 | |
parent | dad9810fe5fe813c4960d8790651a5ad6adf2651 (diff) | |
download | rockbox-a83adc7d6d0a16d08687a903da8a992e3affedcc.tar.gz rockbox-a83adc7d6d0a16d08687a903da8a992e3affedcc.zip |
Theme Editor: Removed markup comments from CodeEditor files (it was originally a Nokia example, so it was marked up with comments for their documentation), implemented the beginnings of drag and drop editing. Viewports are now movable, but don't invoke code generation yet
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27675 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 27 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 3 | ||||
-rw-r--r-- | utils/themeeditor/gui/codeeditor.cpp | 27 | ||||
-rw-r--r-- | utils/themeeditor/gui/codeeditor.h | 7 | ||||
-rw-r--r-- | utils/themeeditor/gui/skinviewer.cpp | 1 |
5 files changed, 30 insertions, 35 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index e9c58eb6fb..f7b1bc4ca2 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -21,6 +21,11 @@ | |||
21 | 21 | ||
22 | #include <QPainter> | 22 | #include <QPainter> |
23 | #include <QPainterPath> | 23 | #include <QPainterPath> |
24 | #include <QGraphicsSceneMouseEvent> | ||
25 | #include <QTransform> | ||
26 | |||
27 | #include <QDebug> | ||
28 | |||
24 | #include <cmath> | 29 | #include <cmath> |
25 | 30 | ||
26 | #include "rbviewport.h" | 31 | #include "rbviewport.h" |
@@ -40,6 +45,8 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
40 | statusBarTexture(":/render/statusbar.png"), | 45 | statusBarTexture(":/render/statusbar.png"), |
41 | leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) | 46 | leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) |
42 | { | 47 | { |
48 | setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); | ||
49 | |||
43 | if(!node->tag) | 50 | if(!node->tag) |
44 | { | 51 | { |
45 | /* Default viewport takes up the entire screen */ | 52 | /* Default viewport takes up the entire screen */ |
@@ -290,6 +297,26 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start, | |||
290 | } | 297 | } |
291 | } | 298 | } |
292 | 299 | ||
300 | QVariant RBViewport::itemChange(GraphicsItemChange change, | ||
301 | const QVariant &value) | ||
302 | { | ||
303 | if(change == ItemPositionChange) | ||
304 | { | ||
305 | QPointF pos = value.toPointF(); | ||
306 | QRectF bound = parentItem()->boundingRect(); | ||
307 | |||
308 | pos.setX(qMax(0., pos.x())); | ||
309 | pos.setX(qMin(pos.x(), bound.width() - boundingRect().width())); | ||
310 | |||
311 | pos.setY(qMax(0., pos.y())); | ||
312 | pos.setY(qMin(pos.y(), bound.height() - boundingRect().height())); | ||
313 | |||
314 | return pos; | ||
315 | } | ||
316 | |||
317 | return QGraphicsItem::itemChange(change, value); | ||
318 | } | ||
319 | |||
293 | void RBViewport::alignLeft() | 320 | void RBViewport::alignLeft() |
294 | { | 321 | { |
295 | int y = textOffset.y(); | 322 | int y = textOffset.y(); |
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index c665108618..ea47225f09 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -77,6 +77,9 @@ public: | |||
77 | void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3, | 77 | void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3, |
78 | skin_element* noId3); | 78 | skin_element* noId3); |
79 | 79 | ||
80 | protected: | ||
81 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); | ||
82 | |||
80 | private: | 83 | private: |
81 | 84 | ||
82 | void alignLeft(); | 85 | void alignLeft(); |
diff --git a/utils/themeeditor/gui/codeeditor.cpp b/utils/themeeditor/gui/codeeditor.cpp index 3858460385..9a2a0182f2 100644 --- a/utils/themeeditor/gui/codeeditor.cpp +++ b/utils/themeeditor/gui/codeeditor.cpp | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #include "codeeditor.h" | 39 | #include "codeeditor.h" |
40 | 40 | ||
41 | //![constructor] | ||
42 | |||
43 | CodeEditor::CodeEditor(QWidget *parent) | 41 | CodeEditor::CodeEditor(QWidget *parent) |
44 | : QPlainTextEdit(parent), completer(this) | 42 | : QPlainTextEdit(parent), completer(this) |
45 | { | 43 | { |
@@ -58,10 +56,6 @@ CodeEditor::CodeEditor(QWidget *parent) | |||
58 | settings.beginGroup("CodeEditor"); | 56 | settings.beginGroup("CodeEditor"); |
59 | } | 57 | } |
60 | 58 | ||
61 | //![constructor] | ||
62 | |||
63 | //![extraAreaWidth] | ||
64 | |||
65 | int CodeEditor::lineNumberAreaWidth() | 59 | int CodeEditor::lineNumberAreaWidth() |
66 | { | 60 | { |
67 | int digits = 1; | 61 | int digits = 1; |
@@ -76,19 +70,12 @@ int CodeEditor::lineNumberAreaWidth() | |||
76 | return space; | 70 | return space; |
77 | } | 71 | } |
78 | 72 | ||
79 | //![extraAreaWidth] | ||
80 | |||
81 | //![slotUpdateExtraAreaWidth] | ||
82 | 73 | ||
83 | void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) | 74 | void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) |
84 | { | 75 | { |
85 | setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); | 76 | setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); |
86 | } | 77 | } |
87 | 78 | ||
88 | //![slotUpdateExtraAreaWidth] | ||
89 | |||
90 | //![slotUpdateRequest] | ||
91 | |||
92 | void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) | 79 | void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) |
93 | { | 80 | { |
94 | if (dy) | 81 | if (dy) |
@@ -100,8 +87,6 @@ void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) | |||
100 | updateLineNumberAreaWidth(0); | 87 | updateLineNumberAreaWidth(0); |
101 | } | 88 | } |
102 | 89 | ||
103 | //![slotUpdateRequest] | ||
104 | |||
105 | void CodeEditor::cursorMoved() | 90 | void CodeEditor::cursorMoved() |
106 | { | 91 | { |
107 | /* Closing the completer if the cursor has moved out of its bounds */ | 92 | /* Closing the completer if the cursor has moved out of its bounds */ |
@@ -138,8 +123,6 @@ void CodeEditor::insertTag() | |||
138 | completer.hide(); | 123 | completer.hide(); |
139 | } | 124 | } |
140 | 125 | ||
141 | //![resizeEvent] | ||
142 | |||
143 | void CodeEditor::resizeEvent(QResizeEvent *e) | 126 | void CodeEditor::resizeEvent(QResizeEvent *e) |
144 | { | 127 | { |
145 | QPlainTextEdit::resizeEvent(e); | 128 | QPlainTextEdit::resizeEvent(e); |
@@ -149,8 +132,6 @@ void CodeEditor::resizeEvent(QResizeEvent *e) | |||
149 | lineNumberAreaWidth(), cr.height())); | 132 | lineNumberAreaWidth(), cr.height())); |
150 | } | 133 | } |
151 | 134 | ||
152 | //![resizeEvent] | ||
153 | |||
154 | void CodeEditor::keyPressEvent(QKeyEvent *event) | 135 | void CodeEditor::keyPressEvent(QKeyEvent *event) |
155 | { | 136 | { |
156 | 137 | ||
@@ -256,23 +237,16 @@ void CodeEditor::keyPressEvent(QKeyEvent *event) | |||
256 | 237 | ||
257 | } | 238 | } |
258 | 239 | ||
259 | //![extraAreaPaintEvent_0] | ||
260 | |||
261 | void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) | 240 | void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) |
262 | { | 241 | { |
263 | QPainter painter(lineNumberArea); | 242 | QPainter painter(lineNumberArea); |
264 | painter.fillRect(event->rect(), Qt::lightGray); | 243 | painter.fillRect(event->rect(), Qt::lightGray); |
265 | 244 | ||
266 | //![extraAreaPaintEvent_0] | ||
267 | |||
268 | //![extraAreaPaintEvent_1] | ||
269 | QTextBlock block = firstVisibleBlock(); | 245 | QTextBlock block = firstVisibleBlock(); |
270 | int blockNumber = block.blockNumber(); | 246 | int blockNumber = block.blockNumber(); |
271 | int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); | 247 | int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); |
272 | int bottom = top + (int) blockBoundingRect(block).height(); | 248 | int bottom = top + (int) blockBoundingRect(block).height(); |
273 | //![extraAreaPaintEvent_1] | ||
274 | 249 | ||
275 | //![extraAreaPaintEvent_2] | ||
276 | while (block.isValid() && top <= event->rect().bottom()) { | 250 | while (block.isValid() && top <= event->rect().bottom()) { |
277 | if (block.isVisible() && bottom >= event->rect().top()) { | 251 | if (block.isVisible() && bottom >= event->rect().top()) { |
278 | QString number = QString::number(blockNumber + 1); | 252 | QString number = QString::number(blockNumber + 1); |
@@ -293,5 +267,4 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) | |||
293 | ++blockNumber; | 267 | ++blockNumber; |
294 | } | 268 | } |
295 | } | 269 | } |
296 | //![extraAreaPaintEvent_2] | ||
297 | 270 | ||
diff --git a/utils/themeeditor/gui/codeeditor.h b/utils/themeeditor/gui/codeeditor.h index 21f1c561cf..9968cf5093 100644 --- a/utils/themeeditor/gui/codeeditor.h +++ b/utils/themeeditor/gui/codeeditor.h | |||
@@ -51,8 +51,6 @@ QT_END_NAMESPACE | |||
51 | 51 | ||
52 | class LineNumberArea; | 52 | class LineNumberArea; |
53 | 53 | ||
54 | //![codeeditordefinition] | ||
55 | |||
56 | class CodeEditor : public QPlainTextEdit | 54 | class CodeEditor : public QPlainTextEdit |
57 | { | 55 | { |
58 | Q_OBJECT | 56 | Q_OBJECT |
@@ -91,9 +89,6 @@ private: | |||
91 | int docLength; | 89 | int docLength; |
92 | }; | 90 | }; |
93 | 91 | ||
94 | //![codeeditordefinition] | ||
95 | //![extraarea] | ||
96 | |||
97 | class LineNumberArea : public QWidget | 92 | class LineNumberArea : public QWidget |
98 | { | 93 | { |
99 | public: | 94 | public: |
@@ -114,6 +109,4 @@ private: | |||
114 | CodeEditor *codeEditor; | 109 | CodeEditor *codeEditor; |
115 | }; | 110 | }; |
116 | 111 | ||
117 | //![extraarea] | ||
118 | |||
119 | #endif | 112 | #endif |
diff --git a/utils/themeeditor/gui/skinviewer.cpp b/utils/themeeditor/gui/skinviewer.cpp index 95caf1e393..1d5c84c519 100644 --- a/utils/themeeditor/gui/skinviewer.cpp +++ b/utils/themeeditor/gui/skinviewer.cpp | |||
@@ -35,7 +35,6 @@ SkinViewer::SkinViewer(QWidget *parent) : | |||
35 | QObject::connect(ui->zoomEvenButton, SIGNAL(pressed()), | 35 | QObject::connect(ui->zoomEvenButton, SIGNAL(pressed()), |
36 | this, SLOT(zoomEven())); | 36 | this, SLOT(zoomEven())); |
37 | 37 | ||
38 | ui->viewer->setDragMode(QGraphicsView::ScrollHandDrag); | ||
39 | } | 38 | } |
40 | 39 | ||
41 | SkinViewer::~SkinViewer() | 40 | SkinViewer::~SkinViewer() |