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
3dae4454
Commit
3dae4454
authored
May 13, 2003
by
Eric Petit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modules/gui/beos/PreferencesWindow.*:
- use BMenuFields for string_from_list config items - cleaning
parent
7ba77f51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
175 additions
and
128 deletions
+175
-128
modules/gui/beos/PreferencesWindow.cpp
modules/gui/beos/PreferencesWindow.cpp
+129
-115
modules/gui/beos/PreferencesWindow.h
modules/gui/beos/PreferencesWindow.h
+46
-13
No files found.
modules/gui/beos/PreferencesWindow.cpp
View file @
3dae4454
...
...
@@ -2,7 +2,7 @@
* PreferencesWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.cpp,v 1.2
0 2003/05/13 11:18:25
titer Exp $
* $Id: PreferencesWindow.cpp,v 1.2
1 2003/05/13 14:11:33
titer Exp $
*
* Authors: Eric Petit <titer@videolan.org>
*
...
...
@@ -23,14 +23,17 @@
#include <stdlib.h>
/* atoi(), strtod() */
#include <InterfaceKit.h>
#include <SupportKit.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "PreferencesWindow.h"
/* TODO:
- handle CONFIG_HINT_SUBCATEGORY
- use BSliders for integer_with_range and float_with_range
- add the needed LockLooper()s
- fix horizontal window resizing */
/* We use this function to order the items of the BOutlineView */
int
compare_func
(
const
BListItem
*
_first
,
const
BListItem
*
_second
)
{
...
...
@@ -53,25 +56,6 @@ int compare_func( const BListItem * _first, const BListItem * _second )
return
(
strcmp
(
first
->
Text
(),
second
->
Text
()
)
);
}
/*****************************************************************************
* StringItemWithView::StringItemWithView
*****************************************************************************/
StringItemWithView
::
StringItemWithView
(
const
char
*
text
)
:
BStringItem
(
text
)
{
/* We use the default constructor */
}
/*****************************************************************************
* ConfigView::ConfigView
*****************************************************************************/
ConfigView
::
ConfigView
(
BRect
frame
,
const
char
*
name
,
uint32
resizingMode
,
uint32
flags
)
:
BView
(
frame
,
name
,
resizingMode
,
flags
)
{
/* We use the default constructor */
}
/*****************************************************************************
* PreferencesWindow::PreferencesWindow
*****************************************************************************/
...
...
@@ -88,9 +72,8 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
BRect
rect
;
/* The "background" view */
rgb_color
background
=
ui_color
(
B_PANEL_BACKGROUND_COLOR
);
fPrefsView
=
new
BView
(
Bounds
(),
NULL
,
B_FOLLOW_ALL
,
B_WILL_DRAW
);
fPrefsView
->
SetViewColor
(
background
);
fPrefsView
->
SetViewColor
(
ui_color
(
B_PANEL_BACKGROUND_COLOR
)
);
AddChild
(
fPrefsView
);
/* Create the preferences tree */
...
...
@@ -122,13 +105,6 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
fOutline
->
AddItem
(
modulesItem
);
/* Fill the tree */
/* TODO:
- manage CONFIG_HINT_SUBCATEGORY
- use a pop-up for CONFIG_HINT_MODULE
- use BSliders for integer_with_range and float_with_range
- add the needed LockLooper()s
- fix horizontal window resizing
- make this intuitive ! */
vlc_list_t
*
p_list
;
p_list
=
vlc_list_find
(
p_intf
,
VLC_OBJECT_MODULE
,
FIND_ANYWHERE
);
if
(
!
p_list
)
...
...
@@ -158,22 +134,19 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
/* Build the config view for this module */
rect
=
fDummyView
->
Bounds
();
rect
.
right
-=
B_V_SCROLL_BAR_WIDTH
;
Config
View
*
configView
;
configView
=
new
Config
View
(
rect
,
"config view"
,
B_FOLLOW_LEFT_RIGHT
|
B_FOLLOW_TOP
,
B_WILL_DRAW
);
configView
->
SetViewColor
(
background
);
B
View
*
configView
;
configView
=
new
B
View
(
rect
,
"config view"
,
B_FOLLOW_LEFT_RIGHT
|
B_FOLLOW_TOP
,
B_WILL_DRAW
);
configView
->
SetViewColor
(
ui_color
(
B_PANEL_BACKGROUND_COLOR
)
);
rect
=
configView
->
Bounds
();
rect
.
InsetBy
(
10
,
10
);
rect
.
bottom
=
rect
.
top
+
TEXT_HEIGHT
;
BTextControl
*
textControl
;
BCheckBox
*
checkBox
;
/* FIXME: we use the BControl name to store the VLC variable name.
To know what variable type it is, I add one character at the beginning
of the name (see ApplyChanges()); it's not pretty, but it works. To
be cleaned later. */
char
name
[
128
];
ConfigTextControl
*
textControl
;
ConfigCheckBox
*
checkBox
;
ConfigMenuField
*
menuField
;
BPopUpMenu
*
popUp
;
p_item
=
p_module
->
p_config
;
bool
firstItem
=
true
;
do
...
...
@@ -189,12 +162,25 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
else
firstItem
=
false
;
memset
(
name
,
0
,
128
);
sprintf
(
name
,
"s%s"
,
p_item
->
psz_name
);
textControl
=
new
BTextControl
(
rect
,
name
,
p_item
->
psz_text
,
""
,
new
BMessage
(),
B_FOLLOW_NONE
);
configView
->
AddChild
(
textControl
);
if
(
p_item
->
ppsz_list
&&
p_item
->
ppsz_list
[
0
]
)
{
popUp
=
new
BPopUpMenu
(
""
);
menuField
=
new
ConfigMenuField
(
rect
,
p_item
->
psz_text
,
popUp
,
p_item
->
psz_name
);
BMenuItem
*
menuItem
;
for
(
int
i
=
0
;
p_item
->
ppsz_list
[
i
];
i
++
)
{
menuItem
=
new
BMenuItem
(
p_item
->
ppsz_list
[
i
],
new
BMessage
()
);
popUp
->
AddItem
(
menuItem
);
}
configView
->
AddChild
(
menuField
);
}
else
{
textControl
=
new
ConfigTextControl
(
rect
,
p_item
->
psz_text
,
CONFIG_ITEM_STRING
,
p_item
->
psz_name
);
configView
->
AddChild
(
textControl
);
}
break
;
case
CONFIG_ITEM_INTEGER
:
...
...
@@ -203,11 +189,8 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
else
firstItem
=
false
;
memset
(
name
,
0
,
128
);
sprintf
(
name
,
"i%s"
,
p_item
->
psz_name
);
textControl
=
new
BTextControl
(
rect
,
name
,
p_item
->
psz_text
,
""
,
new
BMessage
(),
B_FOLLOW_NONE
);
textControl
=
new
ConfigTextControl
(
rect
,
p_item
->
psz_text
,
CONFIG_ITEM_INTEGER
,
p_item
->
psz_name
);
configView
->
AddChild
(
textControl
);
break
;
...
...
@@ -217,11 +200,8 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
else
firstItem
=
false
;
memset
(
name
,
0
,
128
);
sprintf
(
name
,
"f%s"
,
p_item
->
psz_name
);
textControl
=
new
BTextControl
(
rect
,
name
,
p_item
->
psz_text
,
""
,
new
BMessage
(),
B_FOLLOW_NONE
);
textControl
=
new
ConfigTextControl
(
rect
,
p_item
->
psz_text
,
CONFIG_ITEM_FLOAT
,
p_item
->
psz_name
);
configView
->
AddChild
(
textControl
);
break
;
...
...
@@ -231,10 +211,8 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
else
firstItem
=
false
;
memset
(
name
,
0
,
128
);
sprintf
(
name
,
"b%s"
,
p_item
->
psz_name
);
checkBox
=
new
BCheckBox
(
rect
,
name
,
p_item
->
psz_text
,
new
BMessage
(),
B_FOLLOW_NONE
);
checkBox
=
new
ConfigCheckBox
(
rect
,
p_item
->
psz_text
,
p_item
->
psz_name
);
configView
->
AddChild
(
checkBox
);
break
;
}
...
...
@@ -243,8 +221,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
/* Adjust the configView size */
rect
.
bottom
+=
10
;
configView
->
fRealBounds
=
BRect
(
0
,
0
,
configView
->
Bounds
().
Width
(),
rect
.
bottom
);
configView
->
ResizeTo
(
configView
->
Bounds
().
Width
(),
configView
->
Bounds
().
Height
()
);
configView
->
ResizeTo
(
configView
->
Bounds
().
Width
(),
rect
.
bottom
);
/* Add the item to the tree */
StringItemWithView
*
stringItem
;
...
...
@@ -345,12 +322,9 @@ void PreferencesWindow::FrameResized( float width, float height )
{
BWindow
::
FrameResized
(
width
,
height
);
/* Get the current ConfigView */
ConfigView
*
view
;
view
=
(
ConfigView
*
)
fConfigScroll
->
ChildAt
(
0
);
view
->
ResizeTo
(
fDummyView
->
Bounds
().
Width
()
-
B_V_SCROLL_BAR_WIDTH
,
fDummyView
->
Bounds
().
Height
()
);
/* Get the current config BView */
BView
*
view
;
view
=
fConfigScroll
->
ChildAt
(
0
);
UpdateScrollBar
();
}
...
...
@@ -372,11 +346,11 @@ void PreferencesWindow::Update()
if
(
fConfigScroll
)
{
/* If we don't do this, the
Config
View will remember a wrong position */
/* If we don't do this, the
config B
View will remember a wrong position */
BScrollBar
*
scrollBar
=
fConfigScroll
->
ScrollBar
(
B_VERTICAL
);
scrollBar
->
SetValue
(
0
);
/* Detach the current
Config
View, remove the BScrollView */
/* Detach the current
config B
View, remove the BScrollView */
BView
*
view
;
while
(
(
view
=
fConfigScroll
->
ChildAt
(
0
)
)
)
fConfigScroll
->
RemoveChild
(
view
);
...
...
@@ -384,14 +358,17 @@ void PreferencesWindow::Update()
delete
fConfigScroll
;
}
/* Create a BScrollView with the new config BView in it */
BRect
oldBounds
=
selectedItem
->
fConfigView
->
Bounds
();
selectedItem
->
fConfigView
->
ResizeTo
(
fDummyView
->
Bounds
().
Width
()
-
B_V_SCROLL_BAR_WIDTH
,
fDummyView
->
Bounds
().
Height
()
);
/* Create a BScrollView with the new ConfigView in it */
fConfigScroll
=
new
BScrollView
(
""
,
selectedItem
->
fConfigView
,
B_FOLLOW_ALL_SIDES
,
0
,
false
,
true
,
B_NO_BORDER
);
fConfigScroll
->
SetViewColor
(
ui_color
(
B_PANEL_BACKGROUND_COLOR
)
);
fDummyView
->
AddChild
(
fConfigScroll
);
selectedItem
->
fConfigView
->
ResizeTo
(
oldBounds
.
Width
(),
oldBounds
.
Height
()
);
UpdateScrollBar
();
}
...
...
@@ -405,8 +382,8 @@ void PreferencesWindow::UpdateScrollBar()
correctly simple BViews */
/* Get the current config view */
Config
View
*
view
;
view
=
(
ConfigView
*
)
fConfigScroll
->
ChildAt
(
0
);
B
View
*
view
;
view
=
fConfigScroll
->
ChildAt
(
0
);
/* Get the available BRect for display */
BRect
display
=
fConfigScroll
->
Bounds
();
...
...
@@ -415,10 +392,10 @@ void PreferencesWindow::UpdateScrollBar()
/* Fix the scrollbar */
BScrollBar
*
scrollBar
;
long
max
;
BRect
visible
=
display
&
view
->
fRealBounds
;
BRect
total
=
display
|
view
->
fRealBounds
;
BRect
visible
=
display
&
view
->
Bounds
()
;
BRect
total
=
display
|
view
->
Bounds
()
;
scrollBar
=
fConfigScroll
->
ScrollBar
(
B_VERTICAL
);
max
=
(
long
)(
view
->
fRealBounds
.
Height
()
-
visible
.
Height
()
);
max
=
(
long
)(
view
->
Bounds
()
.
Height
()
-
visible
.
Height
()
);
if
(
max
<
0
)
max
=
0
;
scrollBar
->
SetRange
(
0
,
max
);
scrollBar
->
SetProportion
(
visible
.
Height
()
/
total
.
Height
()
);
...
...
@@ -432,7 +409,7 @@ void PreferencesWindow::UpdateScrollBar()
void
PreferencesWindow
::
ApplyChanges
(
bool
doIt
)
{
StringItemWithView
*
item
;
Config
View
*
view
;
B
View
*
view
;
BView
*
child
;
const
char
*
name
;
BString
string
;
...
...
@@ -444,46 +421,83 @@ void PreferencesWindow::ApplyChanges( bool doIt )
if
(
!
view
)
/* This must be the "Modules" item */
continue
;
for
(
int
j
=
0
;
j
<
view
->
CountChildren
();
j
++
)
{
child
=
view
->
ChildAt
(
j
);
name
=
child
->
Name
();
switch
(
*
name
)
if
(
!
strcmp
(
name
,
"ConfigTextControl"
)
)
{
case
's'
:
/* BTextControl, string variable */
if
(
doIt
)
config_PutPsz
(
p_intf
,
name
+
1
,
((
BTextControl
*
)
child
)
->
Text
()
);
else
((
BTextControl
*
)
child
)
->
SetText
(
config_GetPsz
(
p_intf
,
name
+
1
)
);
break
;
case
'i'
:
/* BTextControl, int variable */
if
(
doIt
)
config_PutInt
(
p_intf
,
name
+
1
,
atoi
(
((
BTextControl
*
)
child
)
->
Text
()
)
);
else
{
string
=
""
;
string
<<
config_GetInt
(
p_intf
,
name
+
1
);
((
BTextControl
*
)
child
)
->
SetText
(
string
.
String
()
);
}
break
;
case
'f'
:
/* BTextControl, float variable */
if
(
doIt
)
config_PutFloat
(
p_intf
,
name
+
1
,
strtod
(
((
BTextControl
*
)
child
)
->
Text
(),
NULL
)
);
else
ConfigTextControl
*
textControl
;
textControl
=
(
ConfigTextControl
*
)
child
;
switch
(
textControl
->
fConfigType
)
{
case
CONFIG_ITEM_STRING
:
if
(
doIt
)
config_PutPsz
(
p_intf
,
textControl
->
fConfigName
,
textControl
->
Text
()
);
else
textControl
->
SetText
(
config_GetPsz
(
p_intf
,
textControl
->
fConfigName
)
);
break
;
case
CONFIG_ITEM_INTEGER
:
if
(
doIt
)
config_PutInt
(
p_intf
,
textControl
->
fConfigName
,
atoi
(
textControl
->
Text
()
)
);
else
{
string
=
""
;
string
<<
config_GetInt
(
p_intf
,
textControl
->
fConfigName
);
textControl
->
SetText
(
string
.
String
()
);
}
break
;
case
CONFIG_ITEM_FLOAT
:
if
(
doIt
)
config_PutFloat
(
p_intf
,
textControl
->
fConfigName
,
strtod
(
textControl
->
Text
(),
NULL
)
);
else
{
string
=
""
;
string
<<
config_GetFloat
(
p_intf
,
textControl
->
fConfigName
);
textControl
->
SetText
(
string
.
String
()
);
}
break
;
}
}
else
if
(
!
strcmp
(
name
,
"ConfigCheckBox"
)
)
{
ConfigCheckBox
*
checkBox
;
checkBox
=
(
ConfigCheckBox
*
)
child
;
if
(
doIt
)
config_PutInt
(
p_intf
,
checkBox
->
fConfigName
,
checkBox
->
Value
()
);
else
checkBox
->
SetValue
(
config_GetInt
(
p_intf
,
checkBox
->
fConfigName
)
);
}
else
if
(
!
strcmp
(
name
,
"ConfigMenuField"
)
)
{
ConfigMenuField
*
menuField
;
menuField
=
(
ConfigMenuField
*
)
child
;
BMenu
*
menu
;
BMenuItem
*
menuItem
;
menu
=
menuField
->
Menu
();
if
(
doIt
)
{
menuItem
=
menu
->
FindMarked
();
if
(
menuItem
)
config_PutPsz
(
p_intf
,
menuField
->
fConfigName
,
menuItem
->
Label
()
);
}
else
{
char
*
value
;
value
=
config_GetPsz
(
p_intf
,
menuField
->
fConfigName
);
if
(
!
value
)
value
=
""
;
for
(
int
k
=
0
;
k
<
menu
->
CountItems
();
k
++
)
{
string
=
""
;
string
<<
config_GetFloat
(
p_intf
,
name
+
1
);
((
BTextControl
*
)
child
)
->
SetText
(
string
.
String
()
);
menuItem
=
menu
->
ItemAt
(
k
);
if
(
!
strcmp
(
value
,
menuItem
->
Label
()
)
)
{
menuItem
->
SetMarked
(
true
);
break
;
}
}
break
;
case
'b'
:
/* BCheckBox, bool variable */
if
(
doIt
)
config_PutInt
(
p_intf
,
name
+
1
,
((
BCheckBox
*
)
child
)
->
Value
()
);
else
((
BCheckBox
*
)
child
)
->
SetValue
(
config_GetInt
(
p_intf
,
name
+
1
)
);
break
;
}
}
}
}
...
...
modules/gui/beos/PreferencesWindow.h
View file @
3dae4454
...
...
@@ -2,7 +2,7 @@
* PreferencesWindow.h
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.h,v 1.1
3 2003/05/13 11:18:25
titer Exp $
* $Id: PreferencesWindow.h,v 1.1
4 2003/05/13 14:11:33
titer Exp $
*
* Authors: Eric Petit <titer@videolan.org>
*
...
...
@@ -24,7 +24,7 @@
#ifndef BEOS_PREFERENCES_WINDOW_H
#define BEOS_PREFERENCES_WINDOW_H
#include <
Window
.h>
#include <
InterfaceKit
.h>
#define PREFS_WINDOW_WIDTH 600
#define PREFS_WINDOW_HEIGHT 400
...
...
@@ -34,25 +34,58 @@
#define PREFS_SAVE 'prsa'
#define TEXT_HEIGHT 16
class
ConfigView
:
public
BView
class
StringItemWithView
:
public
BStringItem
{
public:
ConfigView
(
BRect
frame
,
const
char
*
name
,
uint32
resizingMode
,
uint32
flags
);
StringItemWithView
(
const
char
*
text
)
:
BStringItem
(
text
)
{}
/* When we create the view, we have to give it an arbitrary size because
it will be the size of the BScrollView. That's why we keep the real size
in fRealBounds so we can have a correct BScrollBar later */
BRect
fRealBounds
;
/* Here we store the config BView associated to this module */
BView
*
fConfigView
;
};
class
StringItemWithView
:
public
BStringItem
class
ConfigTextControl
:
public
BTextControl
{
public:
StringItemWithView
(
const
char
*
text
);
ConfigTextControl
(
BRect
rect
,
char
*
label
,
int
type
,
char
*
configName
)
:
BTextControl
(
rect
,
"ConfigTextControl"
,
label
,
""
,
new
BMessage
()
)
{
fConfigType
=
type
;
fConfigName
=
strdup
(
configName
);
}
int
fConfigType
;
char
*
fConfigName
;
};
class
ConfigCheckBox
:
public
BCheckBox
{
public:
ConfigCheckBox
(
BRect
rect
,
char
*
label
,
char
*
configName
)
:
BCheckBox
(
rect
,
"ConfigCheckBox"
,
label
,
new
BMessage
()
)
{
fConfigName
=
strdup
(
configName
);
}
char
*
fConfigName
;
};
class
ConfigMenuField
:
public
BMenuField
{
public:
ConfigMenuField
(
BRect
rect
,
char
*
label
,
BPopUpMenu
*
popUp
,
char
*
configName
)
:
BMenuField
(
rect
,
"ConfigMenuField"
,
label
,
popUp
,
new
BMessage
()
)
{
fConfigName
=
strdup
(
configName
);
}
/* Here we store the ConfigView associated to this module */
ConfigView
*
fConfigView
;
char
*
fConfigName
;
};
class
PreferencesWindow
:
public
BWindow
...
...
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