Skip to content

Commit 8a9b395

Browse files
committed
fix: pixInof on top of cutMask
1 parent 966997f commit 8a9b395

File tree

5 files changed

+427
-416
lines changed

5 files changed

+427
-416
lines changed

res/res.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ IDI_LOGO ICON "logo.ico"
88
IDR_ICON_FONT ICON_FONT "icon.ttf"
99

1010
VS_VERSION_INFO VERSIONINFO
11-
FILEVERSION 2,1,9,0
12-
PRODUCTVERSION 2,1,9,0
11+
FILEVERSION 2,1,10,0
12+
PRODUCTVERSION 2,1,10,0
1313
FILEFLAGSMASK 0x3fL
1414
#ifdef _DEBUG
1515
FILEFLAGS 0x1L
@@ -26,12 +26,12 @@ BEGIN
2626
BEGIN
2727
VALUE "CompanyName", "GitHub xland"
2828
VALUE "FileDescription", "ScreenCapture"
29-
VALUE "FileVersion", "2.1.9.0"
29+
VALUE "FileVersion", "2.1.10.0"
3030
VALUE "InternalName", "ScreenCapture.exe"
3131
VALUE "LegalCopyright", "Copyright (C) LiuXiaolun 2023-2024"
3232
VALUE "OriginalFilename", "ScreenCapture.exe"
3333
VALUE "ProductName", "ScreenCapture"
34-
VALUE "ProductVersion", "2.1.9.0"
34+
VALUE "ProductVersion", "2.1.10.0"
3535
END
3636
END
3737
BLOCK "VarFileInfo"

src/PixelInfo.cpp

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "PixelInfo.h"
1+
#include "PixelInfo.h"
22
#include "App.h"
33
#include "WindowBase.h"
44
#include "include/core/SkRegion.h"
@@ -28,24 +28,36 @@ PixelInfo* PixelInfo::Get()
2828
return pixelInfo;
2929
}
3030

31-
bool PixelInfo::OnMouseMove(const int& x, const int& y)
31+
bool PixelInfo::OnMouseMove(const int& x, const int& y) {
32+
auto win = App::GetWin();
33+
if (win->IsMouseDown || win->state >= State::mask)
34+
{
35+
return false;
36+
}
37+
win->Refresh();
38+
}
39+
40+
bool PixelInfo::OnPaint(SkCanvas* canvas)
3241
{
3342
auto win = App::GetWin();
3443
if (win->IsMouseDown || win->state >= State::mask)
3544
{
3645
return false;
3746
}
38-
float width = 200.0f;
39-
float height = 200.0f;
47+
float width{ 200.0f },height{ 200.0f },x,y;
48+
{
49+
POINT mousePos;
50+
GetCursorPos(&mousePos);
51+
x = (float)mousePos.x;
52+
y = (float)mousePos.y;
53+
}
4054
rect.setXYWH(x + 10, y + 10, width, height);
4155
if (rect.fLeft + width > win->w) {
4256
rect.offset(0 - width - 20, 0);
4357
}
4458
if (rect.fTop + height > win->h) {
4559
rect.offset(0, 0 - height - 20);
4660
}
47-
auto canvas = win->surfaceFront->getCanvas();
48-
canvas->clear(SK_ColorTRANSPARENT);
4961
SkPaint paint;
5062
paint.setColor(SkColorSetARGB(168, 0, 0, 0));
5163
canvas->drawRect(rect, paint);
@@ -109,8 +121,6 @@ bool PixelInfo::OnMouseMove(const int& x, const int& y)
109121

110122
data = str.data();
111123
canvas->drawSimpleText(data, str.size()*2, SkTextEncoding::kUTF16, rect.fLeft + 8, rect.fTop + 186, *font, paint);
112-
113-
win->Refresh();
114124
return false;
115125
}
116126

src/PixelInfo.h

+20-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
#pragma once
2-
#include "include/core/SkSurface.h"
3-
#include "include/core/SkCanvas.h"
4-
#include "include/core/SkRect.h"
5-
#include "include/core/SkPoint.h"
6-
#include "include/core/SkPath.h"
7-
#include <vector>
8-
9-
class PixelInfo
10-
{
11-
public:
12-
~PixelInfo();
13-
static void Init();
14-
static PixelInfo *Get();
15-
bool OnMouseMove(const int &x, const int &y);
16-
17-
private:
18-
PixelInfo();
19-
SkRect rect;
1+
#pragma once
2+
#include "include/core/SkSurface.h"
3+
#include "include/core/SkCanvas.h"
4+
#include "include/core/SkRect.h"
5+
#include "include/core/SkPoint.h"
6+
#include "include/core/SkPath.h"
7+
#include <vector>
8+
9+
class PixelInfo
10+
{
11+
public:
12+
~PixelInfo();
13+
static void Init();
14+
static PixelInfo *Get();
15+
bool OnPaint(SkCanvas* canvas);
16+
bool OnMouseMove(const int& x, const int& y);
17+
18+
private:
19+
PixelInfo();
20+
SkRect rect;
2021
};

0 commit comments

Comments
 (0)