Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to show or hide month border in calendar view #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Itsycal/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ + (void)initialize
kShowMonthInIcon: @(NO),
kShowDayOfWeekInIcon: @(NO),
kShowEventDots: @(YES),
kShowMonthBorder: @(YES),
kUseColoredDots: @(YES),
kThemePreference: @0, // System=0, Light=1, Dark=2
kHideIcon: @(NO)
Expand Down
1 change: 1 addition & 0 deletions Itsycal/Itsycal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ extern NSString * const kAllowOutsideApplicationsFolder;
extern NSString * const kClockFormat;
extern NSString * const kHideIcon;
extern NSString * const kShowLocation;
extern NSString * const kShowMonthBorder;
extern NSString * const kShowEventDots;
extern NSString * const kUseColoredDots;
1 change: 1 addition & 0 deletions Itsycal/Itsycal.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
NSString * const kClockFormat = @"ClockFormat";
NSString * const kHideIcon = @"HideIcon";
NSString * const kShowLocation = @"ShowLocation";
NSString * const kShowMonthBorder = @"kShowMonthBorder";
NSString * const kShowEventDots = @"kShowEventDots";
NSString * const kUseColoredDots = @"UseColoredDots";
3 changes: 3 additions & 0 deletions Itsycal/MoCalendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ typedef enum : NSInteger {
// Should calendar show dots under days with events?
@property (nonatomic) BOOL showEventDots;

// Should calendar show border around each month?
@property (nonatomic) BOOL showMonthBorder;

// Should event dots use calendar colors?
@property (nonatomic) BOOL useColoredDots;

Expand Down
12 changes: 11 additions & 1 deletion Itsycal/MoCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ - (void)setShowEventDots:(BOOL)showEventDots
[self reloadData];
}

- (void)setShowMonthBorder:(BOOL)showMonthBorder
{
_showMonthBorder = showMonthBorder;
[self reloadData];
}

- (void)setUseColoredDots:(BOOL)useColoredDots
{
_useColoredDots = useColoredDots;
Expand Down Expand Up @@ -806,7 +812,11 @@ - (void)drawRect:(NSRect)dirtyRect

NSBezierPath *outlinePath = [self bezierPathWithStartCell:_monthStartCell endCell:_monthEndCell radius:radius inset:0 useRects:NO];

[Theme.currentMonthOutlineColor set];
if (_showMonthBorder) {
[Theme.currentMonthOutlineColor set];
} else {
[NSColor.clearColor set];
}
[outlinePath setLineWidth:1.5];
[outlinePath stroke];
}
Expand Down
9 changes: 7 additions & 2 deletions Itsycal/PrefsAppearanceVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ - (void)loadView
NSButton *useColoredDots = chkbx(NSLocalizedString(@"Use colored dots", @""));
NSButton *showWeeks = chkbx(NSLocalizedString(@"Show calendar weeks", @""));
NSButton *showLocation = chkbx(NSLocalizedString(@"Show event location", @""));
NSButton *showMonthBorder = chkbx(NSLocalizedString(@"Show month border", @""));
_hideIcon = chkbx(NSLocalizedString(@"Hide icon", @""));

// Datetime format text field
Expand Down Expand Up @@ -108,8 +109,8 @@ - (void)loadView
sizeSlider.maxValue = SizePreferenceLarge; // = 2
[v addSubview:sizeSlider];

MoVFLHelper *vfl = [[MoVFLHelper alloc] initWithSuperview:v metrics:@{@"m": @20, @"mm": @40} views:NSDictionaryOfVariableBindings(menubarLabel, calendarLabel, separator0, separator1, useOutlineIcon, showMonth, showDayOfWeek, showEventDots, useColoredDots, showWeeks, showLocation, _dateTimeFormat, helpButton, _hideIcon, highlight, themeLabel, themePopup, sizeMinLabel, sizeSlider, sizeMaxLabel)];
[vfl :@"V:|-m-[menubarLabel]-10-[useOutlineIcon]-[showMonth]-[showDayOfWeek]-[_dateTimeFormat]-[_hideIcon]-m-[calendarLabel]-10-[sizeSlider]-15-[themePopup]-m-[highlight]-m-[showEventDots]-[useColoredDots]-[showLocation]-[showWeeks]-m-|"];
MoVFLHelper *vfl = [[MoVFLHelper alloc] initWithSuperview:v metrics:@{@"m": @20, @"mm": @40} views:NSDictionaryOfVariableBindings(menubarLabel, calendarLabel, separator0, separator1, useOutlineIcon, showMonth, showDayOfWeek, showMonthBorder, showEventDots, useColoredDots, showWeeks, showLocation, _dateTimeFormat, helpButton, _hideIcon, highlight, themeLabel, themePopup, sizeMinLabel, sizeSlider, sizeMaxLabel)];
[vfl :@"V:|-m-[menubarLabel]-10-[useOutlineIcon]-[showMonth]-[showDayOfWeek]-[_dateTimeFormat]-[_hideIcon]-m-[calendarLabel]-10-[sizeSlider]-15-[themePopup]-m-[highlight]-m-[showMonthBorder]-[showEventDots]-[useColoredDots]-[showLocation]-[showWeeks]-m-|"];
[vfl :@"H:|-m-[menubarLabel]-[separator0]-m-|" :NSLayoutFormatAlignAllCenterY];
[vfl :@"H:|-m-[calendarLabel]-[separator1]-m-|" :NSLayoutFormatAlignAllCenterY];
[vfl :@"H:|-m-[useOutlineIcon]-(>=m)-|"];
Expand All @@ -120,6 +121,7 @@ - (void)loadView
[vfl :@"H:|-m-[highlight]-(>=m)-|"];
[vfl :@"H:|-(>=m)-[sizeMinLabel]-[sizeSlider(90)]-[sizeMaxLabel]-(>=m)-|" :NSLayoutFormatAlignAllCenterY];
[vfl :@"H:|-m-[themeLabel]-[themePopup]-(>=m)-|" :NSLayoutFormatAlignAllFirstBaseline];
[vfl :@"H:|-m-[showMonthBorder]-(>=m)-|"];
[vfl :@"H:|-m-[showEventDots]-(>=m)-|"];
[vfl :@"H:|-mm-[useColoredDots]-(>=m)-|"];
[vfl :@"H:|-m-[showWeeks]-(>=m)-|"];
Expand Down Expand Up @@ -153,6 +155,9 @@ - (void)loadView

// Bindings for showLocation preference
[showLocation bind:@"value" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kShowLocation] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];

// Bindings for showMonthBorder preference
[showMonthBorder bind:@"value" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kShowMonthBorder] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];

// Bindings for highlight picker
[highlight bind:@"weekStartDOW" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kWeekStartDOW] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];
Expand Down
1 change: 1 addition & 0 deletions Itsycal/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ - (void)viewDidLoad
[_moCal bind:@"highlightedDOWs" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kHighlightedDOWs] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];
[_moCal bind:@"weekStartDOW" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kWeekStartDOW] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];
[_agendaVC bind:@"showLocation" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kShowLocation] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];
[_moCal bind:@"showMonthBorder" toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[@"values." stringByAppendingString:kShowMonthBorder] options:@{NSContinuouslyUpdatesValueBindingOption: @(YES)}];

// A very ugly and questionable hack. Maybe it doesn't work. It
// shouldn't work. But I think it might. Somehow prevents(?!?)
Expand Down