Commit 83180dff authored by Alexandre Lision's avatar Alexandre Lision

chat: custom message selection

Allow user to drag-select multiple messages

Change-Id: I1fcf115822dab791d3df35b29696be3af3800204
Tuleap: #202
parent 0f66bd33
......@@ -144,6 +144,8 @@ SET(ringclient_OTHERS
src/AppDelegate.mm
src/AppDelegate.h
src/Constants.h
src/INDSequentialTextSelectionManager.mm
src/INDSequentialTextSelectionManager.h
src/delegates/ImageManipulationDelegate.mm
src/delegates/ImageManipulationDelegate.h)
......
......@@ -37,6 +37,7 @@
#import "views/IMTableCellView.h"
#import "views/NSColor+RingTheme.h"
#import "QNSTreeController.h"
#import "INDSequentialTextSelectionManager.h"
#import "delegates/ImageManipulationDelegate.h"
#import <QuartzCore/QuartzCore.h>
......@@ -58,6 +59,8 @@
__unsafe_unretained IBOutlet NSPopUpButton* contactMethodsPopupButton;
}
@property (nonatomic, strong, readonly) INDSequentialTextSelectionManager* selectionManager;
@end
@implementation ConversationVC
......@@ -72,6 +75,7 @@
[sendPanel setWantsLayer:YES];
[sendPanel setLayer:[CALayer layer]];
_selectionManager = [[INDSequentialTextSelectionManager alloc] init];
[self setupChat];
......@@ -95,6 +99,8 @@
return ;
}
[self.selectionManager unregisterAllTextViews];
[contactMethodsPopupButton removeAllItems];
for (auto cm : contactMethods) {
[contactMethodsPopupButton addItemWithTitle:cm->uri().toNSString()];
......@@ -231,6 +237,10 @@
- (void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row
{
if (IMTableCellView* cellView = [outlineView viewAtColumn:0 row:row makeIfNecessary:NO]) {
[self.selectionManager registerTextView:cellView.msgView withUniqueIdentifier:@(row).stringValue];
}
if (auto txtRecording = contactMethods.at([contactMethodsPopupButton indexOfSelectedItem])->textRecording()) {
[emptyConversationPlaceHolder setHidden:txtRecording->instantMessagingModel()->rowCount() > 0];
txtRecording->setAllRead();
......
//
// INDSequentialTextSelectionManager.h
// INDSequentialTextSelectionManager
//
// Created by Indragie Karunaratne on 2014-03-02.
// Copyright (c) 2014 Indragie Karunaratne. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
typedef NSAttributedString * (^INDAttributedTextTransformationBlock)(NSAttributedString *);
/**
* Coordinates sequential text selection among an arbitrary set of `NSTextView`s
*/
@interface INDSequentialTextSelectionManager : NSResponder
/**
* Registers a text view to participate in sequential selection.
*
* @param textView The `NSTextView` instance to register.
* @param identifier The unique identifier to associate with the text view instance.
*/
- (void)registerTextView:(NSTextView *)textView withUniqueIdentifier:(NSString *)identifier;
/**
* Registers a text view to participate in sequential selection.
*
* @param textView The `NSTextView` instance to register.
* @param identifier The unique identifier to associate with the text view instance.
* @param block A transformation block to apply to the contents of the text view
* before copying the text.
*/
- (void)registerTextView:(NSTextView *)textView withUniqueIdentifier:(NSString *)identifier transformationBlock:(INDAttributedTextTransformationBlock)block;
/**
* Unregisters a text view for sequential text selection.
*
* @param textView The text view to unregister.
*/
- (void)unregisterTextView:(NSTextView *)textView;
/**
* Unregisters all text views.
*/
- (void)unregisterAllTextViews;
@end
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment