From 1ee2cddf1a64f62a57af6e10a95f0f9642027d7f Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Thu, 12 Aug 2010 23:05:53 +0000 Subject: Theme Editor: Implemented some basic viewport/text mirroring with the %ax tag git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27795 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbscreen.cpp | 2 +- utils/themeeditor/graphics/rbscreen.h | 5 +++++ utils/themeeditor/graphics/rbviewport.cpp | 21 ++++++++++++++++++--- utils/themeeditor/graphics/rbviewport.h | 2 ++ utils/themeeditor/models/parsetreenode.cpp | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp index 2b63a6bdfe..c66d4f82b2 100644 --- a/utils/themeeditor/graphics/rbscreen.cpp +++ b/utils/themeeditor/graphics/rbscreen.cpp @@ -32,7 +32,7 @@ RBScreen::RBScreen(const RBRenderInfo& info, bool remote, QGraphicsItem *parent) :QGraphicsItem(parent), backdrop(0), project(project), - albumArt(0), customUI(0), defaultView(0) + albumArt(0), customUI(0), defaultView(0), ax(false) { setAcceptHoverEvents(true); diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h index c9ae2cf350..3a9a6ddeb3 100644 --- a/utils/themeeditor/graphics/rbscreen.h +++ b/utils/themeeditor/graphics/rbscreen.h @@ -90,6 +90,9 @@ public: void endSbsRender(); void breakSBS(); + void RtlMirror(){ ax = true; } + bool isRtlMirrored(){ bool ret = ax; ax = false; return ret; } + protected: void hoverMoveEvent(QGraphicsSceneHoverEvent *event); @@ -116,6 +119,8 @@ private: RBViewport* defaultView; QList sbsChildren; + + bool ax; }; #endif // RBSCREEN_H diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index a986127987..5cac806c3d 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -48,6 +48,9 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info, leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0), node(pNode), doc(info.document()) { + mirrored = info.screen()->isRtlMirrored() + && info.device()->data("rtl").toBool(); + if(!node->tag) { /* Default viewport takes up the entire screen */ @@ -147,6 +150,12 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info, y -= screen->parentItem()->pos().y(); } + /* Mirroring if necessary */ + if(mirrored) + { + x = parentItem()->boundingRect().width() - w - x; + } + if(node->params[++param].type == skin_tag_parameter::DEFAULT) font = screen->getFont(1); else @@ -226,15 +235,21 @@ void RBViewport::write(QString text) if(textOffset.x() < 0) return; - if(textAlign == Left) + Alignment align = textAlign; + if(mirrored && align == Left) + align = Right; + else if(mirrored && align == Right) + align = Left; + + if(align == Left) { leftText.append(text); } - else if(textAlign == Center) + else if(align == Center) { centerText.append(text); } - else if(textAlign == Right) + else if(align == Right) { rightText.append(text); } diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 8544ad3c1f..cc47e41666 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h @@ -120,6 +120,8 @@ private: int baseParam; ParseTreeNode* node; SkinDocument* doc; + + bool mirrored; }; #endif // RBVIEWPORT_H diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 0888bc47e9..ad80ac6f2e 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp @@ -665,6 +665,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport) case 'x': /* %ax */ + info.screen()->RtlMirror(); return true; case 'L': -- cgit v1.2.3