Skip to content

Instantly share code, notes, and snippets.

View saikat's full-sized avatar

Saikat Chakrabarti saikat

View GitHub Profile
@implementation BorderlessWindow
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(unsigned int)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag {
self = [super initWithContentRect:contentRect
styleMask:CPBorderlessBridgeWindowMask];
return self;
- (void)performDragOperation:(CPDraggingInfo)aSender
{
var data = [[aSender draggingPasteboard] dataForType:WidgetDragType];
var widget = [CPKeyedUnarchiver unarchiveObjectWithData:data];
var dropLocationX = [aSender draggedViewLocation].x - [[aSender draggingSource] frame].size.width;
var dropLocationY = [aSender draggedViewLocation].y - [[aSender draggedView] frame].size.height;
[widget setFrameOrigin:CGPointMake (dropLocationX, dropLocationY)];
[self addSubview:widget];
}
@implementation WidgetView : CPView
{
Widget _widget;
}
- (void)setSelected:(BOOL)isSelected
{
[self setBackgroundColor:isSelected ? [CPColor grayColor] : nil];
}
@implementation WidgetView : CPView
{
Widget _widget;
}
- (void)setSelected:(BOOL)isSelected
{
[self setBackgroundColor:isSelected ? [CPColor grayColor] : nil];
}
@implementation WidgetView : CPView
{
Widget _widget;
}
- (void)setSelected:(BOOL)isSelected
{
[self setBackgroundColor:isSelected ? [CPColor grayColor] : nil];
}
widgetsCollection = [[CPCollectionView alloc] initWithFrame:bounds];
[widgetsCollection setMinItemSize:CGSizeMake(100, 100)];
[widgetsCollection setMaxItemSize:CGSizeMake(100, 100)];
[widgetsCollection setAutoresizingMask:CPViewWidthSizable];
[widgetsCollection setDelegate:self];
var itemPrototype = [[CPCollectionViewItem alloc] init];
[itemPrototype setView:[[WidgetView alloc] initWithFrame:CGRectMakeZero()]];
widgetsCollection = [[CPCollectionView alloc] initWithFrame:bounds];
[widgetsCollection setMinItemSize:CGSizeMake(100, 100)];
[widgetsCollection setMaxItemSize:CGSizeMake(100, 100)];
[widgetsCollection setAutoresizingMask:CPViewWidthSizable];
[widgetsCollection setDelegate:self];
var itemPrototype = [[CPCollectionViewItem alloc] init];
[itemPrototype setView:[[WidgetView alloc] initWithFrame:CGRectMakeZero()]];
for (i = 0; i < [[self subviews] count]; i++) {
[[self subviews][i] removeFromSuperview];
}
[screensCollectionView reloadContent];
var screenName = [[[screensCollectionView items][0] view] screenName];
[screenName setEditable:YES];
[screenName setBackgroundColor:[CPColor whiteColor]];
[[screenName window] makeFirstResponder:screenName];
[screenName selectText:self];
var newScreen = [[ScreenService sharedScreenService] addScreenWithName:"New Screen"];
[screensCollectionView reloadContent];
var index = [[[ScreenService sharedScreenService] screens] count] - 1;
var screenName = [[[screensCollectionView items][index] view] screenName];
[screenName setEditable:YES];
[screenName setBackgroundColor:[CPColor whiteColor]];
[[screenName window] makeFirstResponder:screenName];
[screenName selectText:self];