Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
Bonzomatic
Commits
c4d0ea8c
Commit
c4d0ea8c
authored
Jan 31, 2015
by
Gargaj
Browse files
add mouse down/move/up for click-drag text selection
parent
8c65bdeb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Renderer.h
View file @
c4d0ea8c
...
...
@@ -82,6 +82,12 @@ namespace Renderer
extern
KeyEvent
keyEventBuffer
[
512
];
extern
int
keyEventBufferCount
;
enum
MOUSEEVENTTYPE
{
MOUSEEVENTTYPE_DOWN
=
0
,
MOUSEEVENTTYPE_MOVE
,
MOUSEEVENTTYPE_UP
,
};
enum
MOUSEBUTTON
{
MOUSEBUTTON_LEFT
=
0
,
...
...
@@ -90,6 +96,7 @@ namespace Renderer
};
struct
MouseEvent
{
MOUSEEVENTTYPE
eventType
;
int
x
;
int
y
;
MOUSEBUTTON
button
;
...
...
ShaderEditor.cpp
View file @
c4d0ea8c
...
...
@@ -10,6 +10,7 @@ ShaderEditor::ShaderEditor( Scintilla::Surface *s )
surfaceWindow
=
s
;
sFontFile
=
""
;
nFontSize
=
16
;
bHasMouseCapture
=
false
;
}
void
ShaderEditor
::
SetAStyle
(
int
style
,
Scintilla
::
ColourDesired
fore
,
Scintilla
::
ColourDesired
back
,
int
size
,
const
char
*
face
)
...
...
@@ -197,12 +198,12 @@ void ShaderEditor::CopyToClipboard( const Scintilla::SelectionText &selectedText
void
ShaderEditor
::
SetMouseCapture
(
bool
on
)
{
bHasMouseCapture
=
on
;
}
bool
ShaderEditor
::
HaveMouseCapture
()
{
return
fals
e
;
return
bHasMouseCaptur
e
;
}
sptr_t
ShaderEditor
::
DefWndProc
(
unsigned
int
iMessage
,
uptr_t
wParam
,
sptr_t
lParam
)
...
...
@@ -306,3 +307,19 @@ void ShaderEditor::ButtonDown( Scintilla::Point pt, unsigned int curTime, bool s
pt
.
y
-=
rect
.
top
;
Scintilla
::
Editor
::
ButtonDown
(
pt
,
curTime
,
shift
,
ctrl
,
alt
);
}
void
ShaderEditor
::
ButtonMovePublic
(
Scintilla
::
Point
pt
)
{
Scintilla
::
PRectangle
rect
=
wMain
.
GetPosition
();
pt
.
x
-=
rect
.
left
;
pt
.
y
-=
rect
.
top
;
ButtonMove
(
pt
);
}
void
ShaderEditor
::
ButtonUp
(
Scintilla
::
Point
pt
,
unsigned
int
curTime
,
bool
ctrl
)
{
Scintilla
::
PRectangle
rect
=
wMain
.
GetPosition
();
pt
.
x
-=
rect
.
left
;
pt
.
y
-=
rect
.
top
;
Scintilla
::
Editor
::
ButtonUp
(
pt
,
curTime
,
ctrl
);
}
ShaderEditor.h
View file @
c4d0ea8c
...
...
@@ -61,6 +61,7 @@ class ShaderEditor : public Scintilla::Editor
bool
bReadOnly
;
std
::
string
sFontFile
;
int
nFontSize
;
bool
bHasMouseCapture
;
public:
ShaderEditor
(
Scintilla
::
Surface
*
surfaceWindow
);
...
...
@@ -88,6 +89,8 @@ public:
void
Tick
();
int
KeyDown
(
int
key
,
bool
shift
,
bool
ctrl
,
bool
alt
,
bool
*
consumed
);
void
ButtonDown
(
Scintilla
::
Point
pt
,
unsigned
int
curTime
,
bool
shift
,
bool
ctrl
,
bool
alt
);
void
ButtonMovePublic
(
Scintilla
::
Point
pt
);
void
ButtonUp
(
Scintilla
::
Point
pt
,
unsigned
int
curTime
,
bool
ctrl
);
void
AddCharUTF
(
const
char
*
s
,
unsigned
int
len
,
bool
treatAsDBCS
=
false
);
void
NotifyStyleToNeeded
(
int
endStyleNeeded
);
...
...
main.cpp
View file @
c4d0ea8c
...
...
@@ -138,7 +138,20 @@ int main()
for
(
int
i
=
0
;
i
<
Renderer
::
mouseEventBufferCount
;
i
++
)
{
if
(
bShowGui
)
mShaderEditor
.
ButtonDown
(
Scintilla
::
Point
(
Renderer
::
mouseEventBuffer
[
i
].
x
,
Renderer
::
mouseEventBuffer
[
i
].
y
),
time
*
1000
,
false
,
false
,
false
);
{
switch
(
Renderer
::
mouseEventBuffer
[
i
].
eventType
)
{
case
Renderer
::
MOUSEEVENTTYPE_MOVE
:
mShaderEditor
.
ButtonMovePublic
(
Scintilla
::
Point
(
Renderer
::
mouseEventBuffer
[
i
].
x
,
Renderer
::
mouseEventBuffer
[
i
].
y
)
);
break
;
case
Renderer
::
MOUSEEVENTTYPE_DOWN
:
mShaderEditor
.
ButtonDown
(
Scintilla
::
Point
(
Renderer
::
mouseEventBuffer
[
i
].
x
,
Renderer
::
mouseEventBuffer
[
i
].
y
),
time
*
1000
,
false
,
false
,
false
);
break
;
case
Renderer
::
MOUSEEVENTTYPE_UP
:
mShaderEditor
.
ButtonUp
(
Scintilla
::
Point
(
Renderer
::
mouseEventBuffer
[
i
].
x
,
Renderer
::
mouseEventBuffer
[
i
].
y
),
time
*
1000
,
false
);
break
;
}
}
}
Renderer
::
mouseEventBufferCount
=
0
;
...
...
platform_sdl/Renderer.cpp
View file @
c4d0ea8c
...
...
@@ -267,16 +267,39 @@ namespace Renderer
}
}
else
if
(
E
.
type
==
SDL_MOUSEMOTION
)
{
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_MOVE
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
E
.
motion
.
x
;
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
E
.
motion
.
y
;
if
(
E
.
motion
.
state
&
SDL_BUTTON
(
1
))
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
mouseEventBufferCount
++
;
}
else
if
(
E
.
type
==
SDL_MOUSEBUTTONDOWN
)
{
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_DOWN
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
E
.
button
.
x
;
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
E
.
button
.
y
;
switch
(
E
.
button
.
button
)
{
case
SDL_BUTTON_MIDDLE
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_MIDDLE
;
break
;
case
SDL_BUTTON_RIGHT
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_RIGHT
;
break
;
case
SDL_BUTTON_LEFT
:
default:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
break
;
}
mouseEventBufferCount
++
;
}
else
if
(
E
.
type
==
SDL_MOUSEBUTTONUP
)
{
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_UP
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
E
.
button
.
x
;
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
E
.
button
.
y
;
switch
(
E
.
button
.
button
)
{
case
SDL_BUTTON_MIDDLE
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_MIDDLE
;
break
;
case
SDL_BUTTON_RIGHT
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_RIGHT
;
break
;
case
SDL_BUTTON_LEFT
:
default:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
break
;
case
SDL_BUTTON_MIDDLE
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_MIDDLE
;
break
;
case
SDL_BUTTON_RIGHT
:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_RIGHT
;
break
;
case
SDL_BUTTON_LEFT
:
default:
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
break
;
}
mouseEventBufferCount
++
;
}
...
...
platform_w32_dx9/Renderer.cpp
View file @
c4d0ea8c
...
...
@@ -198,15 +198,28 @@ namespace Renderer
case
WM_LBUTTONDOWN
:
{
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_DOWN
;
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
GET_X_LPARAM
(
lParam
);
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
GET_Y_LPARAM
(
lParam
);
mouseEventBufferCount
++
;
}
break
;
case
WM_MOUSEMOVE
:
{
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_MOVE
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
GET_X_LPARAM
(
lParam
);
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
GET_Y_LPARAM
(
lParam
);
mouseEventBufferCount
++
;
}
break
;
case
WM_LBUTTONUP
:
{
//nLeftMouse = 0;
mouseEventBuffer
[
mouseEventBufferCount
].
eventType
=
MOUSEEVENTTYPE_UP
;
mouseEventBuffer
[
mouseEventBufferCount
].
button
=
MOUSEBUTTON_LEFT
;
mouseEventBuffer
[
mouseEventBufferCount
].
x
=
GET_X_LPARAM
(
lParam
);
mouseEventBuffer
[
mouseEventBufferCount
].
y
=
GET_Y_LPARAM
(
lParam
);
mouseEventBufferCount
++
;
}
break
;
case
WM_ACTIVATE
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment