...
  View open merge request
Commits (1)
......@@ -836,9 +836,11 @@
if (p_input) {
/* we can obviously only do that if an input is available */
int64_t length = var_GetInteger(p_input, "length");
[_timeSelectionPanel setMaxValue:(int)(length / CLOCK_FREQ)];
[_timeSelectionPanel setMaxTime:(int)(length / CLOCK_FREQ)];
int64_t pos = var_GetInteger(p_input, "time");
[_timeSelectionPanel setJumpTimeValue: (int)(pos / CLOCK_FREQ)];
[_timeSelectionPanel setPosition:(int)(pos / CLOCK_FREQ)];
[_timeSelectionPanel runModalForWindow:[NSApp mainWindow]
completionHandler:^(NSInteger returnCode, int64_t returnTime) {
......
......@@ -24,17 +24,25 @@
@interface VLCTimeSelectionPanelController : NSWindowController
@property (readwrite, weak) IBOutlet NSButton *cancelButton;
@property (readwrite, weak) IBOutlet NSTextField *textField;
@property (readwrite, weak) IBOutlet NSTextField *goToLabel;
@property (readwrite, weak) IBOutlet NSButton *okButton;
@property (readwrite, weak) IBOutlet NSTextField *secsLabel;
@property (readwrite, weak) IBOutlet NSStepper *stepper;
@property (readwrite, weak) IBOutlet NSTextField *minsLabel;
@property (readwrite, weak) IBOutlet NSTextField *hoursLabel;
@property (nonatomic) int jumpTimeValue;
@property (nonatomic) int maxValue;
@property (nonatomic) int jumpSecsValue;
@property (nonatomic) int jumpMinsValue;
@property (nonatomic) int jumpHoursValue;
@property (nonatomic) int secsMax;
@property (nonatomic) int minsMax;
@property (nonatomic) int hoursMax;
- (IBAction)buttonPressed:(id)sender;
- (int)getTimeInSecs;
- (void)setMaxTime:(int)secsMax;
- (void)setPosition:(int)secsPos;
/**
* Completion handler for textfield panel
* \param returnCode Result from panel. Can be NSModalResponseOK or NSModalResponseCancel.
......@@ -50,4 +58,4 @@ typedef void(^TimeSelectionCompletionHandler)(NSInteger returnCode, int64_t retu
- (void)runModalForWindow:(NSWindow *)window completionHandler:(TimeSelectionCompletionHandler)handler;
@end
\ No newline at end of file
@end
......@@ -49,35 +49,61 @@
{
[_cancelButton setTitle: _NS("Cancel")];
[_okButton setTitle: _NS("OK")];
[_secsLabel setStringValue: _NS("sec.")];
[_secsLabel setStringValue: _NS("ss")];
[_minsLabel setStringValue: _NS("mm")];
[_hoursLabel setStringValue: _NS("hh")];
[_goToLabel setStringValue: _NS("Jump to Time")];
[_textField setFormatter:[[PositionFormatter alloc] init]];
}
- (void)controlTextDidChange:(NSNotification *)notification
{
[self setPosition:[self getTimeInSecs]];
}
- (void)setMaxTime:(int)secsMax
{
[self setHoursMax:(int)secsMax / 3600];
if (secsMax >= 3600) {
[self setMinsMax:59];
[self setSecsMax:59];
}
else if (secsMax >= 60) {
[self setMinsMax:(int)secsMax / 60];
[self setSecsMax:59];
}
else {
[self setSecsMax:secsMax];
[self setMinsMax:0];
}
}
- (void)setPosition:(int)secsPos
{
int minsPos = secsPos / 60;
secsPos = secsPos % 60;
int hoursPos = minsPos / 60;
minsPos = minsPos % 60;
[self setJumpSecsValue: secsPos];
[self setJumpMinsValue: minsPos];
[self setJumpHoursValue: hoursPos];
}
- (int)getTimeInSecs
{
// calculate resulting time in secs:
int timeInSec = self.jumpSecsValue;
timeInSec += self.jumpMinsValue * 60;
timeInSec += self.jumpHoursValue * 3600;
return timeInSec;
}
- (IBAction)buttonPressed:(id)sender
{
[self.window orderOut:sender];
[NSApp endSheet: self.window];
// calculate resulting time in secs:
int64_t timeInSec = 0;
NSString *string = [_textField stringValue];
if ([[string componentsSeparatedByString: @":"] count] > 1 &&
[[string componentsSeparatedByString: @":"] count] <= 3) {
NSArray *ourTempArray = \
[string componentsSeparatedByString: @":"];
if ([[string componentsSeparatedByString: @":"] count] == 3) {
timeInSec += ([[ourTempArray firstObject] intValue] *3600); //h
timeInSec += ([[ourTempArray objectAtIndex:1] intValue] *60); //m
timeInSec += [[ourTempArray objectAtIndex:2] intValue]; //s
} else {
timeInSec += ([[ourTempArray firstObject] intValue] *60); //m
timeInSec += [[ourTempArray objectAtIndex:1] intValue]; //s
}
}
else
timeInSec = [string intValue];
int64_t timeInSec = [self getTimeInSecs];
if (_completionHandler)
_completionHandler(sender == _okButton ? NSModalResponseOK : NSModalResponseCancel, timeInSec);
......@@ -86,7 +112,6 @@
- (void)runModalForWindow:(NSWindow *)window completionHandler:(TimeSelectionCompletionHandler)handler
{
[self window];
[_stepper setMaxValue:self.maxValue];
_completionHandler = [handler copy];
[NSApp beginSheet:self.window
......