]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Code improvements to make possible to keep the zoom state while browsing the images...
authorterencehill <piuntn@gmail.com>
Sun, 5 Feb 2012 19:09:38 +0000 (20:09 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 5 Feb 2012 19:09:38 +0000 (20:09 +0100)
qcsrc/menu/item/image.c
qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c
qcsrc/menu/xonotic/dialog_multiplayer_screenshot_screenshotviewer.c
qcsrc/menu/xonotic/screenshotimage.c

index 68b9ad93feb2f8626b92ab5ec0333c8403136905..c7d1ae894198202796f7764f1b1b0e246f2ee78c 100644 (file)
@@ -5,6 +5,7 @@ CLASS(Image) EXTENDS(Item)
        METHOD(Image, toString, string(entity))
        METHOD(Image, resizeNotify, void(entity, vector, vector, vector, vector))
        METHOD(Image, updateAspect, void(entity))
+       METHOD(Image, initZoom, void(entity))
        METHOD(Image, setZoom, void(entity, float, float))
        METHOD(Image, drag_setStartPos, float(entity, vector))
        METHOD(Image, drag, float(entity, vector))
@@ -32,6 +33,9 @@ string Image_toString(entity me)
 void Image_configureImage(entity me, string path)
 {
        me.src = path;
+}
+void Image_initZoom(entity me)
+{
        me.zoomOffset = '0.5 0.5 0';
        me.zoomFactor = 1;
        if (me.forcedAspect == -2)
@@ -39,6 +43,7 @@ void Image_configureImage(entity me, string path)
        if (me.zoomLimitedByTheBox)
                me.zoomMax = -1; // calculate zoomMax at the first updateAspect call
 }
+
 void Image_draw(entity me)
 {
        if(me.imgSize_x > 1 || me.imgSize_y > 1)
index 94e7d6548bd17feac34e8b3314826d7bad27e1d3..94b9f55529b61afd011d9c6a72f720d63f089255 100644 (file)
@@ -29,7 +29,7 @@ void XonoticScreenshotBrowserTab_loadPreviewScreenshot(entity me, string scrImag
        if (me.currentScrPath)
                strunzone(me.currentScrPath);
        me.currentScrPath = strzone(scrImage);
-       me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath);
+       me.screenshotImage.load(me.screenshotImage, me.currentScrPath);
 }
 void XonoticScreenshotBrowserTab_fill(entity me)
 {
index 1ff4c340a41f5eac4d5a008df6a22d8691bcb558..1a123c891e7f189ba45a599901aff9047b428375 100644 (file)
@@ -25,7 +25,7 @@ void XonoticScreenshotViewerDialog_loadScreenshot(entity me, string scrImage)
        if (me.currentScrPath)
                strunzone(me.currentScrPath);
        me.currentScrPath = strzone(scrImage);
-       me.screenshotImage.configureXonoticScreenshotImage(me.screenshotImage, me.currentScrPath);
+       me.screenshotImage.load(me.screenshotImage, me.currentScrPath);
        me.frame.setText(me.frame, me.screenshotImage.screenshotTitle);
 }
 void prevScreenshot_Click(entity btn, entity me)
index fa6be93f23bcad7dd3511d3f80b200e866952a6f..adde95b87cbed97360d6aac5c41f80d37c4c5d30 100644 (file)
@@ -1,6 +1,7 @@
 #ifdef INTERFACE
-CLASS(XonoticScreenshotImage) EXTENDS(Image)
-       METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity, string))
+CLASS(XonoticScreenshotImage) EXTENDS(XonoticImage)
+       METHOD(XonoticScreenshotImage, configureXonoticScreenshotImage, void(entity))
+       METHOD(XonoticScreenshotImage, load, void(entity, string))
        METHOD(XonoticScreenshotImage, draw, void(entity))
        ATTRIB(XonoticScreenshotImage, focusable, float, 1) // mousePress and mouseDrag work only if focusable is set
        METHOD(XonoticScreenshotImage, mousePress, float(entity, vector))
@@ -21,20 +22,26 @@ entity makeXonoticScreenshotImage()
 {
        entity me;
        me = spawnXonoticScreenshotImage();
-       me.configureXonoticScreenshotImage(me, string_null);
+       me.configureXonoticScreenshotImage(me);
        return me;
 }
 
-void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me, string theImage)
+void XonoticScreenshotImage_configureXonoticScreenshotImage(entity me)
+{
+       me.configureXonoticImage(me, string_null, -2);
+}
+
+void XonoticScreenshotImage_load(entity me, string theImage)
 {
-       me.configureImage(me, theImage);
-       me.forcedAspect = -2;
        //me.zoomLimitedByTheBox = 1;
        me.screenshotTime = time;
-       me.updateAspect(me);
+       me.src = theImage;
        if (me.screenshotTitle)
                strunzone(me.screenshotTitle);
        me.screenshotTitle = strzone(substring(me.src, 13, strlen(theImage) - 13)); //strip "/screenshots/"
+
+       me.initZoom(me); // this image may have a different size
+       me.setZoom(me, 0, 0);
 }
 
 float XonoticScreenshotImage_mousePress(entity me, vector coords)