Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
18dce59e
Commit
18dce59e
authored
Aug 16, 2010
by
egottlieb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recoded Cocoa code that got erased by... failure to commit? Merge? Eh.
parent
c510c4d9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
20 deletions
+45
-20
project.pbxproj
Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
+2
-2
SDL_cocoashape.h
src/video/cocoa/SDL_cocoashape.h
+1
-1
SDL_cocoashape.m
src/video/cocoa/SDL_cocoashape.m
+42
-17
No files found.
Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
View file @
18dce59e
...
...
@@ -1184,14 +1184,14 @@
isa
=
PBXContainerItemProxy
;
containerPortal
=
003FA63A093FFD41000C53B3
/* SDL.xcodeproj */
;
proxyType
=
2
;
remoteGlobalIDString
=
00D8D9EF1195090700638393
/* testsdl.app */
;
remoteGlobalIDString
=
00D8D9EF1195090700638393
;
remoteInfo
=
testsdl
;
};
4537749D1209152D002F0F45
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
08FB7793FE84155DC02AAC07
/* Project object */
;
proxyType
=
1
;
remoteGlobalIDString
=
BEC567F70761D90600A33029
/* sdlcommon */
;
remoteGlobalIDString
=
BEC567F70761D90600A33029
;
remoteInfo
=
sdlcommon
;
};
BEC568300761D90600A33029
/* PBXContainerItemProxy */
=
{
...
...
src/video/cocoa/SDL_cocoashape.h
View file @
18dce59e
...
...
@@ -38,7 +38,7 @@ typedef struct {
}
SDL_ShapeData
;
extern
SDL_WindowShaper
*
Cocoa_CreateShaper
(
SDL_Window
*
window
);
extern
int
Cocoa_SetWindowShape
(
SDL_WindowShaper
*
shaper
,
SDL_Surface
*
shape
,
SDL_WindowShapeMode
*
shape
M
ode
);
extern
int
Cocoa_SetWindowShape
(
SDL_WindowShaper
*
shaper
,
SDL_Surface
*
shape
,
SDL_WindowShapeMode
*
shape
_m
ode
);
extern
int
Cocoa_ResizeWindowShape
(
SDL_Window
*
window
);
#endif
src/video/cocoa/SDL_cocoashape.m
View file @
18dce59e
...
...
@@ -23,47 +23,72 @@
#include
"SDL_cocoavideo.h"
#include
"SDL_shape.h"
#include
"SDL_cocoashape.h"
#include
"../src/video/SDL_sysvideo.h"
SDL
_
WindowShaper
*
Cocoa
_
CreateShaper
(
SDL
_
Window
*
window
)
{
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
[
data
->
nswindow
setAlpha
:
1.0
]
;
[
data
->
nswindow
setOpaque
:
YES
]
;
[
data
->
nswindow
setStyleMask
:
NSBorderlessWindowMask
]
;
SDL
_
Shaper
*
result
=
result
=
malloc
(
sizeof
(
SDL
_
WindowShaper
))
;
SDL
_
WindowData
*
windata
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
[
windata
->
nswindow
setOpaque
:
NO
]
;
[
windata
->
nswindow
setStyleMask
:
NSBorderlessWindowMask
]
;
SDL
_
WindowShaper
*
result
=
result
=
malloc
(
sizeof
(
SDL
_
WindowShaper
))
;
result
->
window
=
window
;
result
->
mode
.
mode
=
ShapeModeDefault
;
result
->
mode
.
parameters
.
binarizationCutoff
=
1
;
result
->
user
shownflag
=
0
;
result
->
user
x
=
result
->
usery
=
0
;
window
->
shaper
=
result
;
SDL
_
ShapeData
*
data
=
malloc
(
sizeof
(
SDL
_
ShapeData
))
;
result
->
driverdata
=
data
;
data
->
context
=
[
data
->
nswindow
graphicsContext
]
;
data
->
saved
=
SDL
_
False
;
data
->
rects
=
NULL
;
data
->
count
=
0
;
data
->
context
=
[
windata
->
nswindow
graphicsContext
]
;
data
->
saved
=
SDL
_
FALSE
;
data
->
shape
=
NULL
;
int
resized
_
properly
=
Cocoa
_
ResizeWindowShape
(
window
)
;
assert
(
resized
_
properly
==
0
)
;
return
result
;
}
typedef
struct
{
NSView
*
view
;
NSBezierPath
*
path
;
}
SDL
_
CocoaClosure
;
void
ConvertRects
(
SDL
_
ShapeTree
*
tree
,
void
*
closure
)
{
SDL
_
CocoaClosure
*
data
=
(
SDL
_
CocoaClosure
*
)
closure
;
if
(
tree
->
kind
==
OpaqueShape
)
{
NSRect
rect
=
NSMakeRect
(
tree
->
data
.
shape
.
x
,
tree
->
data
.
shape
.
y
,
tree
->
data
.
shape
.
w
,
tree
->
data
.
shape
.
h
)
;
[
data
->
path
appendBezierPathWithRect
:
[
data
->
view
convertRect
:
rect
toView
:
nil
]]
;
}
}
int
Cocoa
_
SetWindowShape
(
SDL
_
WindowShaper
*
shaper
,
SDL
_
Surface
*
shape
,
SDL
_
WindowShapeMode
*
shapeMode
)
{
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
shaper
->
window
->
driverdata
;
if
(
data
->
saved
==
SDL
_
True
)
{
Cocoa
_
SetWindowShape
(
SDL
_
WindowShaper
*
shaper
,
SDL
_
Surface
*
shape
,
SDL
_
WindowShapeMode
*
shape
_
mode
)
{
SDL
_
ShapeData
*
data
=
(
SDL
_
ShapeData
*
)
shaper
->
driverdata
;
SDL
_
WindowData
*
windata
=
(
SDL
_
WindowData
*
)
shaper
->
window
->
driverdata
;
SDL
_
CocoaClosure
closure
;
NSAutoreleasePool
*
pool
=
NULL
;
if
(
data
->
saved
==
SDL
_
TRUE
)
{
[
data
->
context
restoreGraphicsState
]
;
data
->
saved
=
SDL
_
F
alse
;
data
->
saved
=
SDL
_
F
ALSE
;
}
[
data
->
context
saveGraphicsState
]
;
data
->
saved
=
SDL
_
True
;
//
[
data
->
context
saveGraphicsState
]
;
//
data
->
saved
=
SDL
_
TRUE
;
[[
NSColor
clearColor
]
set
]
;
NSRectFill
([[
data
->
nswindow
contentView
]
frame
])
;
NSRectFill
([[
win
data
->
nswindow
contentView
]
frame
])
;
/*
TODO
:
It
looks
like
Cocoa
can
set
a
clipping
path
based
on
a
list
of
rectangles
.
That
'
s
what
we
get
from
the
Windoze
shape
-
calculation
code
:
a
list
of
rectangles
.
This
will
work
...
I
think
.
*/
data
->
shape
=
SDL
_
CalculateShapeTree
(*shape_mode,shape);
pool = [[NSAutoreleasePool alloc] init];
closure.view = [windata->nswindow contentView];
closure.path = [[NSBezierPath bezierPath] autorelease];
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
[NSGraphicsContext setCurrentContext:data->context];
[closure.path setClip];
[pool drain];
}
int
...
...
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