]> Shamusworld >> Repos - ttedit/blobdiff - src/toolwindow.cpp
Add ability to move points with the arrow keys.
[ttedit] / src / toolwindow.cpp
index 75eaa0e1a3c129aec0d176ac9f7979e0cfb1c956..13d3754d6429e1e7a039d5b1ec68422bd53dd11f 100755 (executable)
 #define DEBUGTP                                // Toolpalette debugging...
 
 #include "toolwindow.h"
-#include "types.h"
 
 
 ToolWindow::ToolWindow(void): QWidget(NULL, Qt::Window | Qt::FramelessWindowHint),
        prevTool(TOOLNone)
 {
-       img = QImage(":/res/toolpal1.xpm");
+//     img = QImage(":/res/toolpal1.xpm");
+       img = QImage(":/res/toolpal1.png");
 
        // Set up sizes
 
        sizeTPBM.rx() = img.width(), sizeTPBM.ry() = img.height();
-       sizeStamp.rx() = sizeTPBM.x() / 4, sizeStamp.ry() = sizeTPBM.y() / 2;
+       sizeStamp.rx() = sizeTPBM.x() / 4, sizeStamp.ry() = sizeTPBM.y() / 3;
 
        setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        setVisible(false);
@@ -54,7 +54,8 @@ void ToolWindow::paintEvent(QPaintEvent * event)
        {
            //need ul corner of bitmap, ul corner of dest, width/height
                p.setCompositionMode(QPainter::RasterOp_NotSource);
-               QPoint pt(sizeStamp.x() * (prevTool & 0x03), sizeStamp.y() * (prevTool >> 2));
+//             QPoint pt(sizeStamp.x() * (prevTool & 0x03), sizeStamp.y() * (prevTool >> 2));
+               QPoint pt(sizeStamp.x() * (prevTool % 4), sizeStamp.y() * (prevTool / 4));
                p.drawImage(pt.x(), pt.y(), img, pt.x(), pt.y(), sizeStamp.x(), sizeStamp.y());
        }
 }
@@ -70,14 +71,18 @@ ToolType ToolWindow::FindSelectedTool(void)
 //printf("pt = %u, %u\n", pt.x(), pt.y());
 
        // Divide mouse coords by the bitmap stamp size to find which one is pointed to
-       uint32 x = (uint32)pt.x() / sizeStamp.x(), y = (uint32)pt.y() / sizeStamp.y();
+       uint32_t x = (uint32_t)pt.x() / sizeStamp.x(), y = (uint32_t)pt.y() / sizeStamp.y();
 
        // Preset failure into newTool, in case no new tool is selected
        ToolType newTool = TOOLNone;
 
        // NOTE: This works because x and y are UNSIGNED
-       if (x < 4 && y < 2)
+       if (x < 4 && y < 3)
                newTool = (ToolType)((y * 4) + x);
 
+       // We don't have 11 yet, so fix this if the user selected the blank space
+       if (newTool > 10)
+               newTool = TOOLNone;
+
        return newTool;
 }