eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot/qt board_widget.cpp board_widget.h


From: Olivier Teulière
Subject: [Eliot-dev] eliot/qt board_widget.cpp board_widget.h
Date: Fri, 22 Oct 2010 16:57:59 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>       10/10/22 16:57:59

Modified files:
        qt             : board_widget.cpp board_widget.h 

Log message:
        Handle arrows again

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/board_widget.cpp?cvsroot=eliot&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/board_widget.h?cvsroot=eliot&r1=1.8&r2=1.9

Patches:
Index: board_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/board_widget.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- board_widget.cpp    22 Oct 2010 16:56:32 -0000      1.19
+++ board_widget.cpp    22 Oct 2010 16:57:59 -0000      1.20
@@ -198,7 +198,12 @@
 {
     if (m_game != NULL)
     {
+        // XXX: in the future, this code could be changed to use signals
+        // emitted from the core. This would allow repainting only the needed
+        // tiles (the same performance improvement could be done with caching
+        // in the TileWidget class, though)
         const Board &board = m_game->getBoard();
+        const Coord &markCoord = m_coordModel.getCoord();
         for (unsigned int row = BOARD_MIN; row <= BOARD_MAX; ++row)
         {
             for (unsigned int col = BOARD_MIN; col <= BOARD_MAX; ++col)
@@ -207,7 +212,9 @@
                         board.getTile(row, col),
                         board.isJoker(row, col),
                         board.isTestChar(row, col),
-                        false, false);
+                        markCoord.isValid() && markCoord.getRow() == row &&
+                            markCoord.getCol() == col,
+                        markCoord.getDir() == Coord::VERTICAL);
             }
         }
     }
@@ -226,45 +233,11 @@
     QPainter painter(this);
     QRect rect = ((BoardLayout*)layout())->getBoardRect();
     painter.drawRect(rect);
-
-#if 0
-    const int size = std::min(width(), height());
-    const int squareSize = lrint(floor((size - 1) / (BOARD_MAX - BOARD_MIN + 
2)));
-
-    // Draw the arrow
-    const Coord &markCoord = m_coordModel.getCoord();
-    if (m_game != NULL && markCoord.isValid())
-    {
-        const unsigned int xPos = (markCoord.getCol() - BOARD_MIN + 1) * 
squareSize + 1;
-        const unsigned int yPos = (markCoord.getRow() - BOARD_MIN + 1) * 
squareSize + 1;
-        painter.setPen(QPen(ArrowColour, 0));
-        painter.setBrush(ArrowColour);
-        const int mid = squareSize / 2;
-        const int fifth = squareSize / 5;
-        const int width = squareSize / 16;
-        painter.translate(xPos + mid, yPos + mid);
-        if (markCoord.getDir() == Coord::VERTICAL)
-            painter.rotate(90);
-        const QPoint points[] =
-        {
-            QPoint(-mid + fifth, -width),
-            QPoint(-mid + 3*fifth, -width),
-            QPoint(-mid + 3*fifth, -fifth),
-            QPoint(-mid + 4*fifth, 0),
-            QPoint(-mid + 3*fifth, fifth),
-            QPoint(-mid + 3*fifth, width),
-            QPoint(-mid + fifth, width)
-        };
-        painter.drawPolygon(points, 7);
-
-        painter.setPen(QPen());
-        painter.setBrush(NormalColour);
-    }
-#endif
+    painter.drawRect(rect.adjusted(-1, -1, 1, 1));
 }
 
 
-/*
+
 void BoardWidget::mousePressEvent(QMouseEvent *iEvent)
 {
     if (m_game == NULL)
@@ -363,5 +336,5 @@
         m_coordModel.clear();
 #endif
 }
-*/
+
 

Index: board_widget.h
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/board_widget.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- board_widget.h      22 Oct 2010 16:56:33 -0000      1.8
+++ board_widget.h      22 Oct 2010 16:57:59 -0000      1.9
@@ -47,7 +47,7 @@
     /// Paint the board
     virtual void paintEvent(QPaintEvent *iEvent);
     /// Catch mouse clicks on the board
-    //virtual void mousePressEvent(QMouseEvent *iEvent);
+    virtual void mousePressEvent(QMouseEvent *iEvent);
 
 private slots:
     void updateArrow(const Coord &iCoord);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]