Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-01 19:02:46 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-02 13:50:50 +0300
commit01a5e087aa25cc76de543740a720f45d1c28d69a (patch)
tree66e57d6572208fe080fccda0b7908ccdda0d7843 /intern/ghost/intern/GHOST_WindowCocoa.mm
parent593eab66b5caa02dcd632eab909cccc137bc2fcd (diff)
Cleanup: move CocoaOpenGLView into own header
Diffstat (limited to 'intern/ghost/intern/GHOST_WindowCocoa.mm')
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm266
1 files changed, 7 insertions, 259 deletions
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 26aa2e8e067..33d9921cdec 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -262,261 +262,8 @@
@end
-#pragma mark NSOpenGLView subclass
-//We need to subclass it in order to give Cocoa the feeling key events are trapped
-@interface CocoaOpenGLView : NSOpenGLView <NSTextInput>
-{
- GHOST_SystemCocoa *systemCocoa;
- GHOST_WindowCocoa *associatedWindow;
-
- bool composing;
- NSString *composing_text;
-
- bool immediate_draw;
-}
-- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
- windowCocoa:(GHOST_WindowCocoa *)winCocoa;
-@end
-
-@implementation CocoaOpenGLView
-
-- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
- windowCocoa:(GHOST_WindowCocoa *)winCocoa
-{
- systemCocoa = sysCocoa;
- associatedWindow = winCocoa;
-
- composing = false;
- composing_text = nil;
-
- immediate_draw = false;
-}
-
-- (BOOL)acceptsFirstResponder
-{
- return YES;
-}
-
-// The trick to prevent Cocoa from complaining (beeping)
-- (void)keyDown:(NSEvent *)event
-{
- systemCocoa->handleKeyEvent(event);
-
- /* Start or continue composing? */
- if ([[event characters] length] == 0 || [[event charactersIgnoringModifiers] length] == 0 ||
- composing) {
- composing = YES;
-
- // interpret event to call insertText
- NSMutableArray *events;
- events = [[NSMutableArray alloc] initWithCapacity:1];
- [events addObject:event];
- [self interpretKeyEvents:events]; // calls insertText
- [events removeObject:event];
- [events release];
- return;
- }
-}
-
-- (void)keyUp:(NSEvent *)event
-{
- systemCocoa->handleKeyEvent(event);
-}
-
-- (void)flagsChanged:(NSEvent *)event
-{
- systemCocoa->handleKeyEvent(event);
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)mouseUp:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)rightMouseDown:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)rightMouseUp:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)mouseMoved:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)mouseDragged:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)rightMouseDragged:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)otherMouseDown:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)otherMouseUp:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)otherMouseDragged:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)magnifyWithEvent:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)rotateWithEvent:(NSEvent *)event
-{
- systemCocoa->handleMouseEvent(event);
-}
-
-- (void)tabletPoint:(NSEvent *)event
-{
- systemCocoa->handleTabletEvent(event, [event type]);
-}
-
-- (void)tabletProximity:(NSEvent *)event
-{
- systemCocoa->handleTabletEvent(event, [event type]);
-}
-
-- (BOOL)isOpaque
-{
- return YES;
-}
-
-- (void)drawRect:(NSRect)rect
-{
- if ([self inLiveResize]) {
- /* Don't redraw while in live resize */
- }
- else {
- [super drawRect:rect];
- systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
-
- /* For some cases like entering fullscreen we need to redraw immediately
- * so our window does not show blank during the animation */
- if (associatedWindow->getImmediateDraw())
- systemCocoa->dispatchEvents();
- }
-}
-
-// Text input
-
-- (void)composing_free
-{
- composing = NO;
-
- if (composing_text) {
- [composing_text release];
- composing_text = nil;
- }
-}
-
-- (void)insertText:(id)chars
-{
- [self composing_free];
-}
-
-- (void)setMarkedText:(id)chars selectedRange:(NSRange)range
-{
- [self composing_free];
- if ([chars length] == 0)
- return;
-
- // start composing
- composing = YES;
- composing_text = [chars copy];
-
- // if empty, cancel
- if ([composing_text length] == 0)
- [self composing_free];
-}
-
-- (void)unmarkText
-{
- [self composing_free];
-}
-
-- (BOOL)hasMarkedText
-{
- return (composing) ? YES : NO;
-}
-
-- (void)doCommandBySelector:(SEL)selector
-{
-}
-
-- (BOOL)isComposing
-{
- return composing;
-}
-
-- (NSInteger)conversationIdentifier
-{
- return (NSInteger)self;
-}
-
-- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range
-{
- return [NSAttributedString new]; // XXX does this leak?
-}
-
-- (NSRange)markedRange
-{
- unsigned int length = (composing_text) ? [composing_text length] : 0;
-
- if (composing)
- return NSMakeRange(0, length);
-
- return NSMakeRange(NSNotFound, 0);
-}
-
-- (NSRange)selectedRange
-{
- unsigned int length = (composing_text) ? [composing_text length] : 0;
- return NSMakeRange(0, length);
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)range
-{
- return NSZeroRect;
-}
-
-- (NSUInteger)characterIndexForPoint:(NSPoint)point
-{
- return NSNotFound;
-}
-
-- (NSArray *)validAttributesForMarkedText
-{
- return [NSArray array]; // XXX does this leak?
-}
-
-@end
+/* NSView for handling input and drawing. */
+#include "GHOST_WindowViewCocoa.h"
#pragma mark initialization / finalization
@@ -533,12 +280,13 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
const bool stereoVisual,
bool is_debug)
: GHOST_Window(width, height, state, stereoVisual, false),
+ m_openGLView(nil),
+ m_systemCocoa(systemCocoa),
m_customCursor(0),
+ m_immediateDraw(false),
m_debug_context(is_debug)
{
- m_systemCocoa = systemCocoa;
m_fullScreen = false;
- m_immediateDraw = false;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -602,8 +350,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
[m_window setAcceptsMouseMovedEvents:YES];
- NSView *view = [m_window contentView];
- [view setAcceptsTouchEvents:YES];
+ NSView *contentview = [m_window contentView];
+ [contentview setAcceptsTouchEvents:YES];
[m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
NSStringPboardType,