Hey,
Another patch from the noob; this one adds an undo/toggle button to the
top of the alpha slider in IDiff. I think this is a much more intuitive
way to toggle the alpha value back and forth when comparing two images.
I've also added an accelerator that does this with the space bar.
I also read the discussion in the archives about the idea of adding a
plug-in library for file types. Is anybody working on that, or can I
give it a shot? (Assuming, of course, that I can find the time.)
Cheers,
-Rick-
Index: src/TortoiseIDiff/MainWindow.cpp
===================================================================
--- src/TortoiseIDiff/MainWindow.cpp (revision 8631)
+++ src/TortoiseIDiff/MainWindow.cpp (working copy)
@@ -335,7 +335,7 @@
picWindow1.StopTimer();
picWindow2.StopTimer();
picWindow1.SetSecondPic(picWindow2.GetPic(), rightpictitle, rightpicpath);
- picWindow1.SetSecondPicAlpha(127);
+ picWindow1.SetSecondPicAlpha(127, true);
}
else
{
@@ -375,14 +375,17 @@
}
break;
case ID_VIEW_ALPHA0:
- picWindow1.SetSecondPicAlpha(0);
+ picWindow1.SetSecondPicAlpha(0, true);
break;
case ID_VIEW_ALPHA255:
- picWindow1.SetSecondPicAlpha(255);
+ picWindow1.SetSecondPicAlpha(255, true);
break;
case ID_VIEW_ALPHA127:
- picWindow1.SetSecondPicAlpha(127);
+ picWindow1.SetSecondPicAlpha(127, true);
break;
+ case ID_VIEW_ALPHATOGGLE:
+ picWindow1.SetSecondPicAlpha(picWindow1.GetSecondPicAlphaLast(), true);
+ break;
case ID_VIEW_FITIMAGESINWINDOW:
{
picWindow1.FitImageInWindow();
Index: src/TortoiseIDiff/PicWindow.cpp
===================================================================
--- src/TortoiseIDiff/PicWindow.cpp (revision 8631)
+++ src/TortoiseIDiff/PicWindow.cpp (working copy)
@@ -57,12 +57,15 @@
{
if (pSecondPic)
{
- MoveWindow(hwndAlphaSlider, m_inforect.left-SLIDER_WIDTH-4, m_inforect.top-4, SLIDER_WIDTH, m_inforect.bottom-m_inforect.top+8, true);
+ MoveWindow(hwndAlphaSlider, m_inforect.left-SLIDER_WIDTH-4, m_inforect.top-4+SLIDER_WIDTH, SLIDER_WIDTH, m_inforect.bottom-m_inforect.top-SLIDER_WIDTH+8, true);
ShowWindow(hwndAlphaSlider, SW_SHOW);
+ MoveWindow(hwndAlphaToggleBtn, m_inforect.left-SLIDER_WIDTH-4, m_inforect.top-4, SLIDER_WIDTH, SLIDER_WIDTH, true);
+ ShowWindow(hwndAlphaToggleBtn, SW_SHOW);
}
else
{
ShowWindow(hwndAlphaSlider, SW_HIDE);
+ ShowWindow(hwndAlphaToggleBtn, SW_HIDE);
}
}
@@ -97,7 +100,7 @@
::SetTimer(*this, TIMER_ALPHASLIDER, 50, NULL);
}
else
- SetSecondPicAlpha((BYTE)SendMessage(hwndAlphaSlider, TBM_GETPOS, 0, 0));
+ SetSecondPicAlpha((BYTE)SendMessage(hwndAlphaSlider, TBM_GETPOS, 0, 0), true);
}
else
{
@@ -224,6 +227,12 @@
return 0;
}
break;
+ case ALPHATOGGLEBUTTON_ID:
+ {
+ SetSecondPicAlpha(alphalast, true);
+ return 0;
+ }
+ break;
}
// pass the message to our parent
SendMessage(GetParent(*this), WM_COMMAND, wParam, lParam);
@@ -246,7 +255,7 @@
break;
case TIMER_ALPHASLIDER:
{
- SetSecondPicAlpha((BYTE)SendMessage(hwndAlphaSlider, TBM_GETPOS, 0, 0));
+ SetSecondPicAlpha((BYTE)SendMessage(hwndAlphaSlider, TBM_GETPOS, 0, 0), false);
KillTimer(*this, TIMER_ALPHASLIDER);
}
break;
@@ -581,16 +590,14 @@
if ((fwKeys & MK_SHIFT)&&(fwKeys & MK_CONTROL)&&(pSecondPic))
{
// ctrl+shift+wheel: change the alpha channel
- int overflow = alpha; // use an int to detect overflows
- alpha -= (zDelta / 12);
+ int overflow = alphalive; // use an int to detect overflows
+ alphalive -= (zDelta / 12);
overflow -= (zDelta / 12);
if (overflow > 255)
- alpha = 255;
+ alphalive = 255;
if (overflow < 0)
- alpha = 0;
- if (hwndAlphaSlider)
- SendMessage(hwndAlphaSlider, TBM_SETPOS, 1, alpha);
- InvalidateRect(*this, NULL, FALSE);
+ alphalive = 0;
+ SetSecondPicAlpha(alphalive, true);
}
else if (fwKeys & MK_SHIFT)
{
@@ -826,7 +833,7 @@
blender.AlphaFormat = 0;
blender.BlendFlags = 0;
blender.BlendOp = AC_SRC_OVER;
- blender.SourceConstantAlpha = alpha;
+ blender.SourceConstantAlpha = alphalive;
AlphaBlend(memDC,
rect.left,
rect.top,
@@ -978,6 +985,20 @@
hPlay = (HICON)LoadImage(hResource, MAKEINTRESOURCE(IDI_START), IMAGE_ICON, 16, 16, LR_LOADTRANSPARENT);
hStop = (HICON)LoadImage(hResource, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, 16, 16, LR_LOADTRANSPARENT);
SendMessage(hwndPlayBtn, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hPlay);
+ hwndAlphaToggleBtn = CreateWindowEx(0,
+ _T("BUTTON"),
+ (LPCTSTR)NULL,
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_ICON | BS_FLAT,
+ 0, 0, 0, 0,
+ *this,
+ (HMENU)ALPHATOGGLEBUTTON_ID,
+ hResource,
+ NULL);
+ if (hwndAlphaToggleBtn == INVALID_HANDLE_VALUE)
+ return false;
+ hAlphaToggle = (HICON)LoadImage(hResource, MAKEINTRESOURCE(IDI_UNDOICON), IMAGE_ICON, 16, 16, LR_LOADTRANSPARENT);
+ SendMessage(hwndAlphaToggleBtn, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hAlphaToggle);
+
return true;
}
Index: src/TortoiseIDiff/PicWindow.h
===================================================================
--- src/TortoiseIDiff/PicWindow.h (revision 8631)
+++ src/TortoiseIDiff/PicWindow.h (working copy)
@@ -27,9 +27,10 @@
#define ID_ANIMATIONTIMER 100
#define TIMER_ALPHASLIDER 101
-#define LEFTBUTTON_ID 101
-#define RIGHTBUTTON_ID 102
-#define PLAYBUTTON_ID 103
+#define LEFTBUTTON_ID 101
+#define RIGHTBUTTON_ID 102
+#define PLAYBUTTON_ID 103
+#define ALPHATOGGLEBUTTON_ID 104
#define TRACKBAR_ID 101
#define SLIDER_HEIGHT 30
@@ -58,7 +59,9 @@
, nVScrollPos(0)
, picscale(1.0)
, pSecondPic(NULL)
- , alpha(255)
+ , alphalive(255)
+ , alphacurr(255)
+ , alphalast(255)
, bShowInfo(true)
, nDimensions(0)
, nCurrentDimension(1)
@@ -90,12 +93,20 @@
void StopTimer() {KillTimer(*this, ID_ANIMATIONTIMER);}
/// Returns the currently used alpha blending value (0-255)
- BYTE GetSecondPicAlpha() {return alpha;}
+ BYTE GetSecondPicAlpha() {return alphalive;}
+ /// Returns the last alpha blending value (0-255)
+ BYTE GetSecondPicAlphaLast() {return alphalast;}
/// Sets the alpha blending value
- void SetSecondPicAlpha(BYTE a)
+ void SetSecondPicAlpha(BYTE a, bool saveundo)
{
- SendMessage(hwndAlphaSlider, TBM_SETPOS, (WPARAM)1, (LPARAM)a);
- alpha = a;
+ alphalive = a;
+ if (hwndAlphaSlider)
+ SendMessage(hwndAlphaSlider, TBM_SETPOS, (WPARAM)1, (LPARAM)a);
+ if(saveundo && alphacurr != a)
+ {
+ alphalast = alphacurr;
+ alphacurr = alphalive;
+ }
InvalidateRect(*this, NULL, FALSE);
}
/// Resizes the image to fit into the window. Small images are not enlarged.
@@ -160,7 +171,9 @@
bool bLinked; ///< if true, the two pic windows are linked together for scrolling/zooming/...
stdstring pictitle2; ///< the title of the second picture
stdstring picpath2; ///< the path of the second picture
- BYTE alpha; ///< the alpha value for the transparency of the second picture
+ BYTE alphalive; ///< the alpha value for the transparency live-preview of the second picture
+ BYTE alphacurr; ///< the alpha value for the transparency of the second picture that was most recently 'set' (not currently being dragged)
+ BYTE alphalast; ///< the alpha value previously used for the transparency of the second picture that the user can undo to
bool bShowInfo; ///< true if the info rectangle of the image should be shown
// scrollbar info
int nVScrollPos; ///< vertical scroll position
@@ -177,10 +190,12 @@
HWND hwndRightBtn;
HWND hwndPlayBtn;
HWND hwndAlphaSlider;
+ HWND hwndAlphaToggleBtn;
HICON hLeft;
HICON hRight;
HICON hPlay;
HICON hStop;
+ HICON hAlphaToggle;
bool bPlaying;
RECT m_inforect;
};
Index: src/TortoiseIDiff/resource.h
===================================================================
--- src/TortoiseIDiff/resource.h (revision 8631)
+++ src/TortoiseIDiff/resource.h (working copy)
@@ -33,6 +33,7 @@
#define IDI_STOP 143
#define IDI_VERTICAL 144
#define IDI_LINK 145
+#define IDI_UNDOICON 146
#define IDC_LEFTIMAGE 1000
#define IDC_RIGHTIMAGE 1001
#define IDC_LEFTBROWSE 1002
@@ -52,6 +53,7 @@
#define ID_VIEW_ALPHA0 32798
#define ID_VIEW_ALPHA255 32799
#define ID_VIEW_ALPHA127 32800
+#define ID_VIEW_ALPHATOGGLE 32806
#define IDC_STATIC -1
// Next default values for new objects
@@ -59,8 +61,8 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 146
-#define _APS_NEXT_COMMAND_VALUE 32803
+#define _APS_NEXT_RESOURCE_VALUE 147
+#define _APS_NEXT_COMMAND_VALUE 32808
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 110
#endif
Index: src/TortoiseIDiff/TortoiseIDiff.rc
===================================================================
--- src/TortoiseIDiff/TortoiseIDiff.rc (revision 8631)
+++ src/TortoiseIDiff/TortoiseIDiff.rc (working copy)
@@ -45,6 +45,7 @@
IDI_STOP ICON "player_stop.ico"
IDI_VERTICAL ICON "vertical.ico"
IDI_LINK ICON "link.ico"
+IDI_UNDOICON ICON "..\\Resources\\menurevert.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -159,6 +160,7 @@
VK_DOWN, ID_VIEW_ALPHA255, VIRTKEY, NOINVERT
VK_LEFT, ID_VIEW_ALPHA127, VIRTKEY, NOINVERT
VK_RIGHT, ID_VIEW_ALPHA127, VIRTKEY, NOINVERT
+ VK_SPACE, ID_VIEW_ALPHATOGGLE, VIRTKEY, NOINVERT
END
Index: src/TortoiseIDiff/TortoiseIDiff.vcproj
===================================================================
--- src/TortoiseIDiff/TortoiseIDiff.vcproj (revision 8631)
+++ src/TortoiseIDiff/TortoiseIDiff.vcproj (working copy)
@@ -489,6 +489,10 @@
>
</File>
<File
+ RelativePath="..\Resources\menurevert.ico"
+ >
+ </File>
+ <File
RelativePath=".\origsize.ico"
>
</File>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Fri Feb 2 16:34:46 2007