Skip to content

Commit 5f8f9e4

Browse files
committed
2 parents 8002c9e + 621d2e4 commit 5f8f9e4

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

resource/MainWindow.rc

2.3 KB
Binary file not shown.

resource/resource.h

242 Bytes
Binary file not shown.

source/DrawingCanvas.ixx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ void DrawingCanvas::DrawGrid(uint32_t color, uint32_t step)
700700
{
701701
xLineMod = 0;
702702
}
703-
// Duplicate the alpha channel in the other three color channels.
704703
destRow[x] = pixelColor;
705704
}
706705
++yMod;
@@ -863,7 +862,9 @@ namespace
863862
return S_OK;
864863
}
865864

866-
uint32_t GetSolidLineCount(
865+
// Using the top left pixel as a reference color (like chroma key), and which direction to start from,
866+
// count how many ignorable padding lines there are of the same color.
867+
uint32_t GetIgnorablePaddingLineCount(
867868
uint32_t* pixels,
868869
size_t bytesPerRow,
869870
uint32_t width,
@@ -963,10 +964,10 @@ namespace
963964
{
964965
const size_t bytesPerRow = sourceBitmapInfo.dsBm.bmWidthBytes;
965966
uint32_t* pixels = reinterpret_cast<uint32_t*>(sourceBitmapInfo.dsBm.bmBits);
966-
top = GetSolidLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapHeight, 0);
967-
bottom -= GetSolidLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapHeight - top, 1);
968-
left = GetSolidLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapWidth, 2);
969-
right -= GetSolidLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapWidth - left, 3);
967+
top = GetIgnorablePaddingLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapHeight, 0);
968+
bottom -= GetIgnorablePaddingLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapHeight - top, 1);
969+
left = GetIgnorablePaddingLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapWidth, 2);
970+
right -= GetIgnorablePaddingLineCount(pixels, bytesPerRow, bitmapWidth, bitmapHeight, bitmapWidth - left, 3);
970971

971972
top = std::max(int32_t(top - padding), 0);
972973
bottom = std::min(int32_t(bottom + padding), int32_t(bitmapHeight));

source/DrawingCanvasControl.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ LRESULT CALLBACK DrawingCanvasControl::WindowProc(HWND hwnd, UINT message, WPARA
9595
}
9696
break;
9797

98-
case WM_DESTROY:
98+
case WM_NCDESTROY:
9999
{
100100
LRESULT result = DefWindowProc(hwnd, message, wParam, lParam);
101101
delete this;

source/MainWindow.ixx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void MainWindow::RegisterCustomClasses()
167167
INITCOMMONCONTROLSEX icex;
168168
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
169169
icex.dwICC = ICC_LISTVIEW_CLASSES;
170-
InitCommonControlsEx(&icex);
170+
InitCommonControlsEx(&icex);
171171

172172
DrawingCanvasControl::RegisterWindowClass(Application::g_hModule);
173173
}
@@ -187,6 +187,7 @@ MainWindow* MainWindow::GetClass(HWND hwnd)
187187

188188
INT_PTR CALLBACK MainWindow::StaticDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
189189
{
190+
// Create the window the first time.
190191
MainWindow* window = GetClassFromDialog<MainWindow>(hwnd);
191192
if (window == nullptr)
192193
{
@@ -478,10 +479,11 @@ INT_PTR MainWindow::InitializeMainDialog()
478479
// UpdateAttributesListView();
479480
// UpdateAttributeValuesListView();
480481

481-
AppendLog(u"Mouse wheel scrolls, middle button drag pans, right click opens menu, left click selects object (ctrl to toggle). "
482-
u"You can select multiple objects in the list to change an attribute across all.\r\n"
483-
u"Double click cell to edit. Press delete key to delete selected object. Press delete in attribute list to clear value.\r\n"
484-
);
482+
AppendLog(
483+
u"Mouse wheel scrolls, middle button drag pans, right click opens menu, left click selects object (ctrl to toggle). "
484+
u"You can select multiple objects in the list to change an attribute across all.\r\n"
485+
u"Double click cell to edit. Press delete key to delete selected object. Press delete in attribute list to clear value.\r\n"
486+
);
485487

486488
uint32_t controlIdToSetFocusTo = 0;
487489
static_assert(SettingsVisibilityTotal == 3, "");

0 commit comments

Comments
 (0)