Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
e8e65d95
Commit
e8e65d95
authored
Feb 20, 2010
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx dialog provider: moved UI widgets out of the interface implementation
parent
4ad09c1b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
461 additions
and
401 deletions
+461
-401
modules/gui/macosx_dialog_provider/Modules.am
modules/gui/macosx_dialog_provider/Modules.am
+4
-1
modules/gui/macosx_dialog_provider/VLCUIWidgets.h
modules/gui/macosx_dialog_provider/VLCUIWidgets.h
+77
-0
modules/gui/macosx_dialog_provider/VLCUIWidgets.m
modules/gui/macosx_dialog_provider/VLCUIWidgets.m
+378
-0
modules/gui/macosx_dialog_provider/dialogProvider.m
modules/gui/macosx_dialog_provider/dialogProvider.m
+2
-400
No files found.
modules/gui/macosx_dialog_provider/Modules.am
View file @
e8e65d95
...
...
@@ -6,9 +6,12 @@ LIBTOOL=@LIBTOOL@ --tag=CC
SOURCES_macosx_dialog_provider = \
VLCLoginPanel.m \
VLCProgressPanel.m \
VLCUIWidgets.m \
dialogProvider.m \
$(NULL)
noinst_HEADERS = \
VLCLoginPanel.h \
VLCProgressPanel.h
VLCProgressPanel.h \
VLCUIWidgets.h \
dialogProvider.h
modules/gui/macosx_dialog_provider/VLCUIWidgets.h
0 → 100644
View file @
e8e65d95
/*****************************************************************************
* VLCUIWidgets.h: Widgets for VLC's Minimal Dialog Provider for Mac OS X
*****************************************************************************
* Copyright (C) 2009-2010 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan dot>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <vlc_extensions.h>
@interface
VLCDialogButton
:
NSButton
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@interface
VLCDialogPopUpButton
:
NSPopUpButton
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@interface
VLCDialogTextField
:
NSTextField
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@interface
VLCDialogWindow
:
NSWindow
{
extension_dialog_t
*
dialog
;
}
@property
(
readwrite
)
extension_dialog_t
*
dialog
;
@end
@interface
VLCDialogList
:
NSTableView
{
extension_widget_t
*
widget
;
NSMutableArray
*
contentArray
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@property
(
readwrite
,
retain
)
NSMutableArray
*
contentArray
;
@end
@interface
VLCDialogGridView
:
NSView
{
NSUInteger
_rowCount
,
_colCount
;
NSMutableArray
*
_gridedViews
;
}
-
(
void
)
addSubview
:(
NSView
*
)
view
atRow
:(
NSUInteger
)
row
column
:(
NSUInteger
)
column
rowSpan
:(
NSUInteger
)
rowSpan
colSpan
:(
NSUInteger
)
colSpan
;
-
(
NSSize
)
flexSize
:(
NSSize
)
size
;
-
(
void
)
removeSubview
:(
NSView
*
)
view
;
@end
\ No newline at end of file
modules/gui/macosx_dialog_provider/VLCUIWidgets.m
0 → 100644
View file @
e8e65d95
/*****************************************************************************
* VLCUIWidgets.m: Widgets for VLC's Minimal Dialog Provider for Mac OS X
*****************************************************************************
* Copyright (C) 2009-2010 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan dot>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "VLCUIWidgets.h"
@implementation
VLCDialogButton
@synthesize
widget
;
@end
@implementation
VLCDialogPopUpButton
@synthesize
widget
;
@end
@implementation
VLCDialogTextField
@synthesize
widget
;
@end
@implementation
VLCDialogWindow
@synthesize
dialog
;
@end
@implementation
VLCDialogList
@synthesize
widget
;
@synthesize
contentArray
;
-
(
NSInteger
)
numberOfRowsInTableView
:(
NSTableView
*
)
aTableView
{
return
[
contentArray
count
];
}
-
(
id
)
tableView
:(
NSTableView
*
)
aTableView
objectValueForTableColumn
:(
NSTableColumn
*
)
aTableColumn
row
:(
NSInteger
)
rowIndex
{
return
[[
contentArray
objectAtIndex
:
rowIndex
]
objectForKey
:
@"text"
];
}
@end
@implementation
VLCDialogGridView
-
(
void
)
dealloc
{
[
_gridedViews
release
];
[
super
dealloc
];
}
-
(
void
)
recomputeCount
{
_colCount
=
0
;
_rowCount
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
if
(
col
+
1
>
_colCount
)
_colCount
=
col
+
1
;
if
(
row
+
1
>
_rowCount
)
_rowCount
=
row
+
1
;
}
}
-
(
void
)
recomputeWindowSize
{
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
recomputeWindowSize
)
object
:
nil
];
NSWindow
*
window
=
[
self
window
];
NSRect
frame
=
[
window
frame
];
NSRect
contentRect
=
[
window
contentRectForFrameRect
:
frame
];
contentRect
.
size
=
[
self
flexSize
:
frame
.
size
];
NSRect
newFrame
=
[
window
frameRectForContentRect
:
contentRect
];
newFrame
.
origin
.
y
-=
newFrame
.
size
.
height
-
frame
.
size
.
height
;
newFrame
.
origin
.
x
-=
(
newFrame
.
size
.
width
-
frame
.
size
.
width
)
/
2
;
[
window
setFrame
:
newFrame
display
:
YES
animate
:
YES
];
}
-
(
NSSize
)
objectSizeToFit
:(
NSView
*
)
view
{
if
([
view
isKindOfClass
:[
NSControl
class
]])
{
NSControl
*
control
=
(
NSControl
*
)
view
;
return
[[
control
cell
]
cellSize
];
}
return
[
view
frame
].
size
;
}
-
(
CGFloat
)
marginX
{
return
16
;
}
-
(
CGFloat
)
marginY
{
return
8
;
}
-
(
CGFloat
)
constrainedHeightOfRow
:(
NSUInteger
)
targetRow
{
CGFloat
height
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
if
(
row
!=
targetRow
)
continue
;
NSUInteger
rowSpan
=
[[
obj
objectForKey
:
@"rowSpan"
]
intValue
];
if
(
rowSpan
!=
1
)
continue
;
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
if
([
view
autoresizingMask
]
&
NSViewHeightSizable
)
continue
;
NSSize
sizeToFit
=
[
self
objectSizeToFit
:
view
];
if
(
height
<
sizeToFit
.
height
)
height
=
sizeToFit
.
height
;
}
return
height
;
}
-
(
CGFloat
)
remainingRowsHeight
{
NSUInteger
height
=
[
self
marginY
];
if
(
!
_rowCount
)
return
0
;
NSUInteger
autosizedRows
=
0
;
for
(
NSUInteger
i
=
0
;
i
<
_rowCount
;
i
++
)
{
CGFloat
constrainedHeight
=
[
self
constrainedHeightOfRow
:
i
];
if
(
!
constrainedHeight
)
autosizedRows
++
;
height
+=
constrainedHeight
+
[
self
marginY
];
}
CGFloat
remaining
=
0
;
if
(
height
<
self
.
bounds
.
size
.
height
&&
autosizedRows
)
remaining
=
(
self
.
bounds
.
size
.
height
-
height
)
/
autosizedRows
;
if
(
remaining
<
0
)
remaining
=
0
;
return
remaining
;
}
-
(
CGFloat
)
heightOfRow
:(
NSUInteger
)
targetRow
{
NSAssert
(
targetRow
<
_rowCount
,
@"accessing a non existing row"
);
CGFloat
height
=
[
self
constrainedHeightOfRow
:
targetRow
];
if
(
!
height
)
height
=
[
self
remainingRowsHeight
];
return
height
;
}
-
(
CGFloat
)
topOfRow
:(
NSUInteger
)
targetRow
{
CGFloat
top
=
[
self
marginY
];
for
(
NSUInteger
i
=
1
;
i
<
_rowCount
-
targetRow
;
i
++
)
{
top
+=
[
self
heightOfRow
:
_rowCount
-
i
]
+
[
self
marginY
];
}
return
top
;
}
-
(
CGFloat
)
constrainedWidthOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
width
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
if
(
col
!=
targetColumn
)
continue
;
NSUInteger
colSpan
=
[[
obj
objectForKey
:
@"colSpan"
]
intValue
];
if
(
colSpan
!=
1
)
continue
;
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
if
([
view
autoresizingMask
]
&
NSViewWidthSizable
)
return
0
;
NSSize
sizeToFit
=
[
self
objectSizeToFit
:
view
];
if
(
width
<
sizeToFit
.
width
)
width
=
sizeToFit
.
width
;
}
return
width
;
}
-
(
CGFloat
)
remainingColumnWidth
{
NSUInteger
width
=
[
self
marginX
];
if
(
!
_colCount
)
return
0
;
NSUInteger
autosizedCol
=
0
;
for
(
NSUInteger
i
=
0
;
i
<
_colCount
;
i
++
)
{
CGFloat
constrainedWidth
=
[
self
constrainedWidthOfColumn
:
i
];
if
(
!
constrainedWidth
)
autosizedCol
++
;
width
+=
constrainedWidth
+
[
self
marginX
];
}
CGFloat
remaining
=
0
;
if
(
width
<
self
.
bounds
.
size
.
width
&&
autosizedCol
)
remaining
=
(
self
.
bounds
.
size
.
width
-
width
)
/
autosizedCol
;
if
(
remaining
<
0
)
remaining
=
0
;
return
remaining
;
}
-
(
CGFloat
)
widthOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
width
=
[
self
constrainedWidthOfColumn
:
targetColumn
];
if
(
!
width
)
width
=
[
self
remainingColumnWidth
];
return
width
;
}
-
(
CGFloat
)
leftOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
left
=
[
self
marginX
];
for
(
NSUInteger
i
=
0
;
i
<
targetColumn
;
i
++
)
{
left
+=
[
self
widthOfColumn
:
i
]
+
[
self
marginX
];
}
return
left
;
}
-
(
void
)
relayout
{
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
NSUInteger
rowSpan
=
[[
obj
objectForKey
:
@"rowSpan"
]
intValue
];
NSUInteger
colSpan
=
[[
obj
objectForKey
:
@"colSpan"
]
intValue
];
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
NSRect
rect
;
// Get the height
if
([
view
autoresizingMask
]
&
NSViewHeightSizable
||
rowSpan
>
1
)
{
CGFloat
height
=
0
;
for
(
NSUInteger
r
=
0
;
r
<
rowSpan
;
r
++
)
{
if
(
row
+
r
>=
_rowCount
)
break
;
height
+=
[
self
heightOfRow
:
row
+
r
]
+
[
self
marginY
];
}
rect
.
size
.
height
=
height
-
[
self
marginY
];
}
else
rect
.
size
.
height
=
[
self
objectSizeToFit
:
view
].
height
;
// Get the width
if
([
view
autoresizingMask
]
&
NSViewWidthSizable
)
{
CGFloat
width
=
0
;
for
(
NSUInteger
c
=
0
;
c
<
colSpan
;
c
++
)
width
+=
[
self
widthOfColumn
:
col
+
c
]
+
[
self
marginX
];
rect
.
size
.
width
=
width
-
[
self
marginX
];
}
else
rect
.
size
.
width
=
[
self
objectSizeToFit
:
view
].
width
;
// Top corner
rect
.
origin
.
y
=
[
self
topOfRow
:
row
]
+
([
self
heightOfRow
:
row
]
-
rect
.
size
.
height
)
/
2
;
rect
.
origin
.
x
=
[
self
leftOfColumn
:
col
];
[
view
setFrame
:
rect
];
[
view
setNeedsDisplay
:
YES
];
}
}
-
(
NSMutableDictionary
*
)
objectForView
:(
NSView
*
)
view
{
for
(
NSMutableDictionary
*
dict
in
_gridedViews
)
{
if
([
dict
objectForKey
:
@"view"
]
==
view
)
return
dict
;
}
return
nil
;
}
-
(
void
)
addSubview
:(
NSView
*
)
view
atRow
:(
NSUInteger
)
row
column
:(
NSUInteger
)
column
rowSpan
:(
NSUInteger
)
rowSpan
colSpan
:(
NSUInteger
)
colSpan
{
if
(
row
+
1
>
_rowCount
)
_rowCount
=
row
+
1
;
if
(
column
+
1
>
_colCount
)
_colCount
=
column
+
1
;
if
(
!
_gridedViews
)
_gridedViews
=
[[
NSMutableArray
alloc
]
init
];
NSMutableDictionary
*
dict
=
[
self
objectForView
:
view
];
if
(
!
dict
)
{
dict
=
[
NSMutableDictionary
dictionary
];
[
dict
setObject
:
view
forKey
:
@"view"
];
[
_gridedViews
addObject
:
dict
];
}
[
dict
setObject
:[
NSNumber
numberWithInt
:
rowSpan
]
forKey
:
@"rowSpan"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
colSpan
]
forKey
:
@"colSpan"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
row
]
forKey
:
@"row"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
column
]
forKey
:
@"col"
];
[
self
addSubview
:
view
];
[
self
relayout
];
// Recompute the size of the window after making sure we won't see anymore update
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
recomputeWindowSize
)
object
:
nil
];
[
self
performSelector
:
@selector
(
recomputeWindowSize
)
withObject
:
nil
afterDelay
:
0
.
1
];
}
-
(
void
)
removeSubview
:(
NSView
*
)
view
{
NSDictionary
*
dict
=
[
self
objectForView
:
view
];
if
(
dict
)
[
_gridedViews
removeObject
:
dict
];
[
view
removeFromSuperview
];
[
self
recomputeCount
];
[
self
recomputeWindowSize
];
[
self
relayout
];
[
self
setNeedsDisplay
:
YES
];
}
-
(
void
)
setFrame
:(
NSRect
)
frameRect
{
[
super
setFrame
:
frameRect
];
[
self
relayout
];
}
-
(
NSSize
)
flexSize
:(
NSSize
)
size
{
if
(
!
_rowCount
||
!
_colCount
)
return
size
;
CGFloat
minHeight
=
[
self
marginY
];
BOOL
canFlexHeight
=
NO
;
for
(
NSUInteger
i
=
0
;
i
<
_rowCount
;
i
++
)
{
CGFloat
constrained
=
[
self
constrainedHeightOfRow
:
i
];
if
(
!
constrained
)
{
canFlexHeight
=
YES
;
constrained
=
128
;
}
minHeight
+=
constrained
+
[
self
marginY
];
}
CGFloat
minWidth
=
[
self
marginX
];
BOOL
canFlexWidth
=
NO
;
for
(
NSUInteger
i
=
0
;
i
<
_colCount
;
i
++
)
{
CGFloat
constrained
=
[
self
constrainedWidthOfColumn
:
i
];
if
(
!
constrained
)
{
canFlexWidth
=
YES
;
constrained
=
128
;
}
minWidth
+=
constrained
+
[
self
marginX
];
}
if
(
size
.
width
<
minWidth
)
size
.
width
=
minWidth
;
if
(
size
.
height
<
minHeight
)
size
.
height
=
minHeight
;
if
(
!
canFlexHeight
)
size
.
height
=
minHeight
;
if
(
!
canFlexWidth
)
size
.
width
=
minWidth
;
return
size
;
}
@end
modules/gui/macosx_dialog_provider/dialogProvider.m
View file @
e8e65d95
...
...
@@ -38,6 +38,7 @@
#import <vlc_extensions.h>
#import "dialogProvider.h"
#import "VLCUIWidgets.h"
/*****************************************************************************
* Prototypes
...
...
@@ -57,405 +58,6 @@ static void updateProgressPanel (void *, const char *, float);
static
bool
checkProgressPanel
(
void
*
);
static
void
destroyProgressPanel
(
void
*
);
@interface
VLCDialogButton
:
NSButton
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@implementation
VLCDialogButton
@synthesize
widget
;
@end
@interface
VLCDialogPopUpButton
:
NSPopUpButton
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@implementation
VLCDialogPopUpButton
@synthesize
widget
;
@end
@interface
VLCDialogTextField
:
NSTextField
{
extension_widget_t
*
widget
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@end
@implementation
VLCDialogTextField
@synthesize
widget
;
@end
@interface
VLCDialogWindow
:
NSWindow
{
extension_dialog_t
*
dialog
;
}
@property
(
readwrite
)
extension_dialog_t
*
dialog
;
@end
@implementation
VLCDialogWindow
@synthesize
dialog
;
@end
@interface
VLCDialogList
:
NSTableView
{
extension_widget_t
*
widget
;
NSMutableArray
*
contentArray
;
}
@property
(
readwrite
)
extension_widget_t
*
widget
;
@property
(
readwrite
,
retain
)
NSMutableArray
*
contentArray
;
@end
@implementation
VLCDialogList
@synthesize
widget
;
@synthesize
contentArray
;
-
(
NSInteger
)
numberOfRowsInTableView
:(
NSTableView
*
)
aTableView
{
return
[
contentArray
count
];
}
-
(
id
)
tableView
:(
NSTableView
*
)
aTableView
objectValueForTableColumn
:(
NSTableColumn
*
)
aTableColumn
row
:(
NSInteger
)
rowIndex
{
return
[[
contentArray
objectAtIndex
:
rowIndex
]
objectForKey
:
@"text"
];
}
@end
@interface
VLCDialogGridView
:
NSView
{
NSUInteger
_rowCount
,
_colCount
;
NSMutableArray
*
_gridedViews
;
}
-
(
NSSize
)
flexSize
:(
NSSize
)
size
;
-
(
void
)
removeSubview
:(
NSView
*
)
view
;
@end
// Move this to separate file
@implementation
VLCDialogGridView
-
(
void
)
dealloc
{
[
_gridedViews
release
];
[
super
dealloc
];
}
-
(
void
)
recomputeCount
{
_colCount
=
0
;
_rowCount
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
if
(
col
+
1
>
_colCount
)
_colCount
=
col
+
1
;
if
(
row
+
1
>
_rowCount
)
_rowCount
=
row
+
1
;
}
}
-
(
void
)
recomputeWindowSize
{
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
recomputeWindowSize
)
object
:
nil
];
NSWindow
*
window
=
[
self
window
];
NSRect
frame
=
[
window
frame
];
NSRect
contentRect
=
[
window
contentRectForFrameRect
:
frame
];
contentRect
.
size
=
[
self
flexSize
:
frame
.
size
];
NSRect
newFrame
=
[
window
frameRectForContentRect
:
contentRect
];
newFrame
.
origin
.
y
-=
newFrame
.
size
.
height
-
frame
.
size
.
height
;
newFrame
.
origin
.
x
-=
(
newFrame
.
size
.
width
-
frame
.
size
.
width
)
/
2
;
[
window
setFrame
:
newFrame
display
:
YES
animate
:
YES
];
}
-
(
NSSize
)
objectSizeToFit
:(
NSView
*
)
view
{
if
([
view
isKindOfClass
:[
NSControl
class
]])
{
NSControl
*
control
=
(
NSControl
*
)
view
;
return
[[
control
cell
]
cellSize
];
}
return
[
view
frame
].
size
;
}
-
(
CGFloat
)
marginX
{
return
16
;
}
-
(
CGFloat
)
marginY
{
return
8
;
}
-
(
CGFloat
)
constrainedHeightOfRow
:(
NSUInteger
)
targetRow
{
CGFloat
height
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
if
(
row
!=
targetRow
)
continue
;
NSUInteger
rowSpan
=
[[
obj
objectForKey
:
@"rowSpan"
]
intValue
];
if
(
rowSpan
!=
1
)
continue
;
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
if
([
view
autoresizingMask
]
&
NSViewHeightSizable
)
continue
;
NSSize
sizeToFit
=
[
self
objectSizeToFit
:
view
];
if
(
height
<
sizeToFit
.
height
)
height
=
sizeToFit
.
height
;
}
return
height
;
}
-
(
CGFloat
)
remainingRowsHeight
{
NSUInteger
height
=
[
self
marginY
];
if
(
!
_rowCount
)
return
0
;
NSUInteger
autosizedRows
=
0
;
for
(
NSUInteger
i
=
0
;
i
<
_rowCount
;
i
++
)
{
CGFloat
constrainedHeight
=
[
self
constrainedHeightOfRow
:
i
];
if
(
!
constrainedHeight
)
autosizedRows
++
;
height
+=
constrainedHeight
+
[
self
marginY
];
}
CGFloat
remaining
=
0
;
if
(
height
<
self
.
bounds
.
size
.
height
&&
autosizedRows
)
remaining
=
(
self
.
bounds
.
size
.
height
-
height
)
/
autosizedRows
;
if
(
remaining
<
0
)
remaining
=
0
;
return
remaining
;
}
-
(
CGFloat
)
heightOfRow
:(
NSUInteger
)
targetRow
{
NSAssert
(
targetRow
<
_rowCount
,
@"accessing a non existing row"
);
CGFloat
height
=
[
self
constrainedHeightOfRow
:
targetRow
];
if
(
!
height
)
height
=
[
self
remainingRowsHeight
];
return
height
;
}
-
(
CGFloat
)
topOfRow
:(
NSUInteger
)
targetRow
{
CGFloat
top
=
[
self
marginY
];
for
(
NSUInteger
i
=
1
;
i
<
_rowCount
-
targetRow
;
i
++
)
{
top
+=
[
self
heightOfRow
:
_rowCount
-
i
]
+
[
self
marginY
];
}
return
top
;
}
-
(
CGFloat
)
constrainedWidthOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
width
=
0
;
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
if
(
col
!=
targetColumn
)
continue
;
NSUInteger
colSpan
=
[[
obj
objectForKey
:
@"colSpan"
]
intValue
];
if
(
colSpan
!=
1
)
continue
;
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
if
([
view
autoresizingMask
]
&
NSViewWidthSizable
)
return
0
;
NSSize
sizeToFit
=
[
self
objectSizeToFit
:
view
];
if
(
width
<
sizeToFit
.
width
)
width
=
sizeToFit
.
width
;
}
return
width
;
}
-
(
CGFloat
)
remainingColumnWidth
{
NSUInteger
width
=
[
self
marginX
];
if
(
!
_colCount
)
return
0
;
NSUInteger
autosizedCol
=
0
;
for
(
NSUInteger
i
=
0
;
i
<
_colCount
;
i
++
)
{
CGFloat
constrainedWidth
=
[
self
constrainedWidthOfColumn
:
i
];
if
(
!
constrainedWidth
)
autosizedCol
++
;
width
+=
constrainedWidth
+
[
self
marginX
];
}
CGFloat
remaining
=
0
;
if
(
width
<
self
.
bounds
.
size
.
width
&&
autosizedCol
)
remaining
=
(
self
.
bounds
.
size
.
width
-
width
)
/
autosizedCol
;
if
(
remaining
<
0
)
remaining
=
0
;
return
remaining
;
}
-
(
CGFloat
)
widthOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
width
=
[
self
constrainedWidthOfColumn
:
targetColumn
];
if
(
!
width
)
width
=
[
self
remainingColumnWidth
];
return
width
;
}
-
(
CGFloat
)
leftOfColumn
:(
NSUInteger
)
targetColumn
{
CGFloat
left
=
[
self
marginX
];
for
(
NSUInteger
i
=
0
;
i
<
targetColumn
;
i
++
)
{
left
+=
[
self
widthOfColumn
:
i
]
+
[
self
marginX
];
}
return
left
;
}
-
(
void
)
relayout
{
for
(
NSDictionary
*
obj
in
_gridedViews
)
{
NSUInteger
row
=
[[
obj
objectForKey
:
@"row"
]
intValue
];
NSUInteger
col
=
[[
obj
objectForKey
:
@"col"
]
intValue
];
NSUInteger
rowSpan
=
[[
obj
objectForKey
:
@"rowSpan"
]
intValue
];
NSUInteger
colSpan
=
[[
obj
objectForKey
:
@"colSpan"
]
intValue
];
NSView
*
view
=
[
obj
objectForKey
:
@"view"
];
NSRect
rect
;
// Get the height
if
([
view
autoresizingMask
]
&
NSViewHeightSizable
||
rowSpan
>
1
)
{
CGFloat
height
=
0
;
for
(
NSUInteger
r
=
0
;
r
<
rowSpan
;
r
++
)
{
if
(
row
+
r
>=
_rowCount
)
break
;
height
+=
[
self
heightOfRow
:
row
+
r
]
+
[
self
marginY
];
}
rect
.
size
.
height
=
height
-
[
self
marginY
];
}
else
rect
.
size
.
height
=
[
self
objectSizeToFit
:
view
].
height
;
// Get the width
if
([
view
autoresizingMask
]
&
NSViewWidthSizable
)
{
CGFloat
width
=
0
;
for
(
NSUInteger
c
=
0
;
c
<
colSpan
;
c
++
)
width
+=
[
self
widthOfColumn
:
col
+
c
]
+
[
self
marginX
];
rect
.
size
.
width
=
width
-
[
self
marginX
];
}
else
rect
.
size
.
width
=
[
self
objectSizeToFit
:
view
].
width
;
// Top corner
rect
.
origin
.
y
=
[
self
topOfRow
:
row
]
+
([
self
heightOfRow
:
row
]
-
rect
.
size
.
height
)
/
2
;
rect
.
origin
.
x
=
[
self
leftOfColumn
:
col
];
[
view
setFrame
:
rect
];
[
view
setNeedsDisplay
:
YES
];
}
}
-
(
NSMutableDictionary
*
)
objectForView
:(
NSView
*
)
view
{
for
(
NSMutableDictionary
*
dict
in
_gridedViews
)
{
if
([
dict
objectForKey
:
@"view"
]
==
view
)
return
dict
;
}
return
nil
;
}
-
(
void
)
addSubview
:(
NSView
*
)
view
atRow
:(
NSUInteger
)
row
column
:(
NSUInteger
)
column
rowSpan
:(
NSUInteger
)
rowSpan
colSpan
:(
NSUInteger
)
colSpan
{
if
(
row
+
1
>
_rowCount
)
_rowCount
=
row
+
1
;
if
(
column
+
1
>
_colCount
)
_colCount
=
column
+
1
;
if
(
!
_gridedViews
)
_gridedViews
=
[[
NSMutableArray
alloc
]
init
];
NSMutableDictionary
*
dict
=
[
self
objectForView
:
view
];
if
(
!
dict
)
{
dict
=
[
NSMutableDictionary
dictionary
];
[
dict
setObject
:
view
forKey
:
@"view"
];
[
_gridedViews
addObject
:
dict
];
}
[
dict
setObject
:[
NSNumber
numberWithInt
:
rowSpan
]
forKey
:
@"rowSpan"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
colSpan
]
forKey
:
@"colSpan"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
row
]
forKey
:
@"row"
];
[
dict
setObject
:[
NSNumber
numberWithInt
:
column
]
forKey
:
@"col"
];
[
self
addSubview
:
view
];
[
self
relayout
];
// Recompute the size of the window after making sure we won't see anymore update
[
NSObject
cancelPreviousPerformRequestsWithTarget
:
self
selector
:
@selector
(
recomputeWindowSize
)
object
:
nil
];
[
self
performSelector
:
@selector
(
recomputeWindowSize
)
withObject
:
nil
afterDelay
:
0
.
1
];
}
-
(
void
)
removeSubview
:(
NSView
*
)
view
{
NSDictionary
*
dict
=
[
self
objectForView
:
view
];
if
(
dict
)
[
_gridedViews
removeObject
:
dict
];
[
view
removeFromSuperview
];
[
self
recomputeCount
];
[
self
recomputeWindowSize
];
[
self
relayout
];
[
self
setNeedsDisplay
:
YES
];
}
-
(
void
)
setFrame
:(
NSRect
)
frameRect
{
[
super
setFrame
:
frameRect
];
[
self
relayout
];
}
-
(
NSSize
)
flexSize
:(
NSSize
)
size
{
if
(
!
_rowCount
||
!
_colCount
)
return
size
;
CGFloat
minHeight
=
[
self
marginY
];
BOOL
canFlexHeight
=
NO
;
for
(
NSUInteger
i
=
0
;
i
<
_rowCount
;
i
++
)
{
CGFloat
constrained
=
[
self
constrainedHeightOfRow
:
i
];
if
(
!
constrained
)
{
canFlexHeight
=
YES
;
constrained
=
128
;
}
minHeight
+=
constrained
+
[
self
marginY
];
}
CGFloat
minWidth
=
[
self
marginX
];
BOOL
canFlexWidth
=
NO
;
for
(
NSUInteger
i
=
0
;
i
<
_colCount
;
i
++
)
{
CGFloat
constrained
=
[
self
constrainedWidthOfColumn
:
i
];
if
(
!
constrained
)
{
canFlexWidth
=
YES
;
constrained
=
128
;
}
minWidth
+=
constrained
+
[
self
marginX
];
}
if
(
size
.
width
<
minWidth
)
size
.
width
=
minWidth
;
if
(
size
.
height
<
minHeight
)
size
.
height
=
minHeight
;
if
(
!
canFlexHeight
)
size
.
height
=
minHeight
;
if
(
!
canFlexWidth
)
size
.
width
=
minWidth
;
return
size
;
}
@end
static
inline
NSDictionary
*
DictFromDialogFatal
(
dialog_fatal_t
*
dialog
)
{
return
[
VLCDialogDisplayer
dictionaryForDialog
:
dialog
->
title
:
dialog
->
message
:
NULL
:
NULL
:
NULL
];
...
...
@@ -875,7 +477,7 @@ bool checkProgressPanel (void *priv)
config_PutPsz
(
p_intf
,
"lastfm-username"
,
[
lastFMUsername
UTF8String
]);
config_PutPsz
(
p_intf
,
"lastfm-password"
,
[
lastFMPassword
UTF8String
]);
config_SaveConfigFile
(
p_intf
,
"main"
);
config_SaveConfigFile
(
p_intf
,
"main"
);
config_SaveConfigFile
(
p_intf
,
"audioscrobbler"
);
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment