Commit 4a7b1635 authored by Eric Petit's avatar Eric Petit

* modules/gui/beos/MessagesWindow.* : cleaning

 * modules/gui/beos/PreferencesWindow.* : split the main modules into
   its categories
parent 8885548e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MessagesWindow.cpp: beos interface * MessagesWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MessagesWindow.cpp,v 1.9 2003/05/17 15:20:46 titer Exp $ * $Id: MessagesWindow.cpp,v 1.10 2003/05/17 18:30:41 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -34,7 +34,85 @@ ...@@ -34,7 +34,85 @@
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#include "MessagesWindow.h" #include "MessagesWindow.h"
static int UpdateMessages( intf_thread_t * p_intf ); /*****************************************************************************
* MessagesView::Pulse
*****************************************************************************/
void MessagesView::Pulse()
{
int i_start, oldLength;
char * psz_module_type = NULL;
rgb_color red = { 200, 0, 0 };
rgb_color gray = { 150, 150, 150 };
rgb_color green = { 0, 150, 0 };
rgb_color orange = { 230, 180, 00 };
rgb_color color;
vlc_mutex_lock( p_sub->p_lock );
int i_stop = *p_sub->pi_stop;
vlc_mutex_unlock( p_sub->p_lock );
if( p_sub->i_start != i_stop )
{
for( i_start = p_sub->i_start;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
/* Add message */
switch( p_sub->p_msg[i_start].i_type )
{
case VLC_MSG_INFO: color = green; break;
case VLC_MSG_WARN: color = orange; break;
case VLC_MSG_ERR: color = red; break;
case VLC_MSG_DBG: color = gray; break;
}
switch( p_sub->p_msg[i_start].i_object_type )
{
case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
}
if( LockLooper() )
{
oldLength = TextLength();
BString string;
string << p_sub->p_msg[i_start].psz_module
<< " " << psz_module_type << " : "
<< p_sub->p_msg[i_start].psz_msg << "\n";
Insert( TextLength(), string.String(), strlen( string.String() ) );
SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
Draw( Bounds() );
UnlockLooper();
}
}
vlc_mutex_lock( p_sub->p_lock );
p_sub->i_start = i_start;
vlc_mutex_unlock( p_sub->p_lock );
}
/* Scroll at the end unless the is user is selecting something */
int32 start, end;
GetSelection( &start, &end );
if( start == end && fScrollBar->LockLooper() )
{
float min, max;
fScrollBar->GetRange( &min, &max );
fScrollBar->SetValue( max );
fScrollBar->UnlockLooper();
}
BTextView::Pulse();
}
/***************************************************************************** /*****************************************************************************
* MessagesWindow::MessagesWindow * MessagesWindow::MessagesWindow
...@@ -54,25 +132,19 @@ MessagesWindow::MessagesWindow( intf_thread_t * p_intf, ...@@ -54,25 +132,19 @@ MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
rect.right -= B_V_SCROLL_BAR_WIDTH; rect.right -= B_V_SCROLL_BAR_WIDTH;
textRect = rect; textRect = rect;
textRect.InsetBy( 5, 5 ); textRect.InsetBy( 5, 5 );
fMessagesView = new BTextView( rect, "messages", textRect, fMessagesView = new MessagesView( p_intf,
B_FOLLOW_ALL, B_WILL_DRAW ); rect, "messages", textRect,
B_FOLLOW_ALL, B_WILL_DRAW );
fMessagesView->MakeEditable( false ); fMessagesView->MakeEditable( false );
fMessagesView->SetStylable( true ); fMessagesView->SetStylable( true );
fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW, fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
B_FOLLOW_ALL, false, true ); B_FOLLOW_ALL, false, true );
fScrollBar = fScrollView->ScrollBar( B_VERTICAL ); fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
AddChild( fScrollView ); AddChild( fScrollView );
/* start window thread in hidden state */ /* start window thread in hidden state */
Hide(); Hide();
Show(); Show();
/* update it */
if( vlc_thread_create( p_intf, "update messages", UpdateMessages,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
{
msg_Err( p_intf, "cannot create update messages thread" );
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -80,7 +152,6 @@ MessagesWindow::MessagesWindow( intf_thread_t * p_intf, ...@@ -80,7 +152,6 @@ MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
*****************************************************************************/ *****************************************************************************/
MessagesWindow::~MessagesWindow() MessagesWindow::~MessagesWindow()
{ {
vlc_thread_join( p_intf );
} }
/***************************************************************************** /*****************************************************************************
...@@ -112,98 +183,3 @@ void MessagesWindow::ReallyQuit() ...@@ -112,98 +183,3 @@ void MessagesWindow::ReallyQuit()
Hide(); Hide();
Quit(); Quit();
} }
/*****************************************************************************
* UpdateMessages
*****************************************************************************/
static int UpdateMessages( intf_thread_t * p_intf )
{
/* workaround: wait a bit or it'll crash */
msleep( 500000 );
intf_sys_t * p_sys = (intf_sys_t*)p_intf->p_sys;
msg_subscription_t * p_sub = p_sys->p_sub;
MessagesWindow * messagesWindow = p_sys->p_window->fMessagesWindow;
BTextView * messagesView = messagesWindow->fMessagesView;
BScrollBar * scrollBar = messagesWindow->fScrollBar;
while( !p_intf->b_die )
{
int i_start, oldLength;
char * psz_module_type = NULL;
rgb_color red = { 200, 0, 0 };
rgb_color gray = { 150, 150, 150 };
rgb_color green = { 0, 150, 0 };
rgb_color orange = { 230, 180, 00 };
rgb_color color;
vlc_mutex_lock( p_sub->p_lock );
int i_stop = *p_sub->pi_stop;
vlc_mutex_unlock( p_sub->p_lock );
if( p_sub->i_start != i_stop )
{
for( i_start = p_sub->i_start;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
/* Add message */
switch( p_sub->p_msg[i_start].i_type )
{
case VLC_MSG_INFO: color = green; break;
case VLC_MSG_WARN: color = orange; break;
case VLC_MSG_ERR: color = red; break;
case VLC_MSG_DBG: color = gray; break;
}
switch( p_sub->p_msg[i_start].i_object_type )
{
case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
}
if ( messagesView->LockLooper() )
{
oldLength = messagesView->TextLength();
BString string;
string << p_sub->p_msg[i_start].psz_module << " " << psz_module_type << " : " <<
p_sub->p_msg[i_start].psz_msg << "\n";
messagesView->Insert( messagesView->TextLength(),
string.String(),
strlen( string.String() ) );
messagesView->SetFontAndColor( oldLength,
messagesView->TextLength(),
NULL, 0, &color );
messagesView->Draw( messagesView->Bounds() );
messagesView->UnlockLooper();
}
/* Scroll at the end */
if( scrollBar->LockLooper() )
{
float min, max;
scrollBar->GetRange( &min, &max );
scrollBar->SetValue( max );
scrollBar->UnlockLooper();
}
}
vlc_mutex_lock( p_sub->p_lock );
p_sub->i_start = i_start;
vlc_mutex_unlock( p_sub->p_lock );
}
/* Wait a bit */
msleep( INTF_IDLE_SLEEP );
}
return 0;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MessagesWindow.h * MessagesWindow.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MessagesWindow.h,v 1.3 2003/02/10 15:23:46 titer Exp $ * $Id: MessagesWindow.h,v 1.4 2003/05/17 18:30:41 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,6 +26,25 @@ ...@@ -26,6 +26,25 @@
#include <Window.h> #include <Window.h>
class MessagesView : public BTextView
{
public:
MessagesView( intf_thread_t * _p_intf,
BRect rect, char * name, BRect textRect,
uint32 resizingMode, uint32 flags )
: BTextView( rect, name, textRect,
resizingMode, flags )
{
p_intf = _p_intf;
p_sub = ((intf_sys_t*)p_intf->p_sys)->p_sub;
}
virtual void Pulse();
intf_thread_t * p_intf;
msg_subscription_t * p_sub;
BScrollBar * fScrollBar;
};
class MessagesWindow : public BWindow class MessagesWindow : public BWindow
{ {
public: public:
...@@ -34,15 +53,14 @@ class MessagesWindow : public BWindow ...@@ -34,15 +53,14 @@ class MessagesWindow : public BWindow
virtual ~MessagesWindow(); virtual ~MessagesWindow();
virtual void FrameResized( float, float ); virtual void FrameResized( float, float );
virtual bool QuitRequested(); virtual bool QuitRequested();
void ReallyQuit(); void ReallyQuit();
intf_thread_t * p_intf; intf_thread_t * p_intf;
BView * fBackgroundView; BView * fBackgroundView;
BTextView * fMessagesView; MessagesView * fMessagesView;
BScrollView * fScrollView; BScrollView * fScrollView;
BScrollBar * fScrollBar;
}; };
#endif // BEOS_PREFERENCES_WINDOW_H #endif // BEOS_PREFERENCES_WINDOW_H
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PreferencesWindow.cpp: beos interface * PreferencesWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.cpp,v 1.21 2003/05/13 14:11:33 titer Exp $ * $Id: PreferencesWindow.cpp,v 1.22 2003/05/17 18:30:41 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -39,18 +39,12 @@ int compare_func( const BListItem * _first, const BListItem * _second ) ...@@ -39,18 +39,12 @@ int compare_func( const BListItem * _first, const BListItem * _second )
{ {
StringItemWithView * first = (StringItemWithView*) _first; StringItemWithView * first = (StringItemWithView*) _first;
StringItemWithView * second = (StringItemWithView*) _second; StringItemWithView * second = (StringItemWithView*) _second;
/* the beos module first */
if( !strcmp( first->Text(), "beos" ) )
return -1;
if( !strcmp( second->Text(), "beos" ) )
return 1;
/* the main module in second */ /* The Modules tree at last */
if( !strcmp( first->Text(), "main" ) ) if( !strcmp( first->Text(), _( "Modules" ) ) )
return -1;
if( !strcmp( second->Text(), "main" ) )
return 1; return 1;
if( !strcmp( second->Text(), _( "Modules" ) ) )
return -1;
/* alphabetic order */ /* alphabetic order */
return( strcmp( first->Text(), second->Text() ) ); return( strcmp( first->Text(), second->Text() ) );
...@@ -75,7 +69,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface, ...@@ -75,7 +69,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
fPrefsView = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW ); fPrefsView = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
fPrefsView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); fPrefsView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
AddChild( fPrefsView ); AddChild( fPrefsView );
/* Create the preferences tree */ /* Create the preferences tree */
rect = Bounds(); rect = Bounds();
rect.InsetBy( 10, 10 ); rect.InsetBy( 10, 10 );
...@@ -87,7 +81,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface, ...@@ -87,7 +81,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,
0, false, true ); 0, false, true );
fPrefsView->AddChild( scrollview ); fPrefsView->AddChild( scrollview );
/* We need to be informed if the user selects an item */ /* We need to be informed if the user selects an item */
fOutline->SetSelectionMessage( new BMessage( PREFS_ITEM_SELECTED ) ); fOutline->SetSelectionMessage( new BMessage( PREFS_ITEM_SELECTED ) );
...@@ -96,14 +90,14 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface, ...@@ -96,14 +90,14 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
rect.left = rect.right + 15 + B_V_SCROLL_BAR_WIDTH; rect.left = rect.right + 15 + B_V_SCROLL_BAR_WIDTH;
rect.right = Bounds().right - 15; rect.right = Bounds().right - 15;
fDummyView = new BView( rect, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); fDummyView = new BView( rect, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW );
fDummyView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
fPrefsView->AddChild( fDummyView ); fPrefsView->AddChild( fDummyView );
/* Add a category for modules configuration */ /* Add a category for modules configuration */
StringItemWithView * modulesItem; StringItemWithView * modulesItem;
modulesItem = new StringItemWithView( _("Modules") ); modulesItem = new StringItemWithView( _("Modules") );
modulesItem->fConfigView = NULL;
fOutline->AddItem( modulesItem ); fOutline->AddItem( modulesItem );
/* Fill the tree */ /* Fill the tree */
vlc_list_t * p_list; vlc_list_t * p_list;
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
...@@ -113,139 +107,110 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface, ...@@ -113,139 +107,110 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
return; return;
} }
module_t * p_module;
/* First, handle the main module */
module_t * p_module = NULL;
module_config_t * p_item;
for( int i = 0; i < p_list->i_count; i++ ) for( int i = 0; i < p_list->i_count; i++ )
{ {
p_module = (module_t*) p_list->p_values[i].p_object; p_module = (module_t*) p_list->p_values[i].p_object;
if( !strcmp( p_module->psz_object_name, "main" ) &&
( p_item = p_module->p_config ) )
break;
else
p_module = NULL;
}
if( p_module )
{
/* We found the main module */
while( p_item->i_type == CONFIG_HINT_CATEGORY )
{
StringItemWithView * stringItem;
stringItem = new StringItemWithView( p_item->psz_text );
p_item++;
stringItem->fConfigView = BuildConfigView( &p_item, true );
fOutline->AddItem( stringItem );
}
}
for( int i = 0; i < p_list->i_count; i++ )
{
p_module = (module_t*) p_list->p_values[i].p_object;
if( !strcmp( p_module->psz_object_name, "main" ) )
continue;
/* If the module has no config option, ignore it */ /* If the module has no config option, ignore it */
module_config_t * p_item;
p_item = p_module->p_config; p_item = p_module->p_config;
if( !p_item ) if( !p_item )
continue; continue;
do do {
{
if( p_item->i_type & CONFIG_ITEM ) if( p_item->i_type & CONFIG_ITEM )
break; break;
} while( p_item->i_type != CONFIG_HINT_END && p_item++ ); } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
if( p_item->i_type == CONFIG_HINT_END ) if( p_item->i_type == CONFIG_HINT_END )
continue; continue;
/* Build the config view for this module */
rect = fDummyView->Bounds();
rect.right -= B_V_SCROLL_BAR_WIDTH;
BView * configView;
configView = new BView( 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;
ConfigTextControl * textControl;
ConfigCheckBox * checkBox;
ConfigMenuField * menuField;
BPopUpMenu * popUp;
p_item = p_module->p_config; /* Create the capability tree if it doesn't already exist */
bool firstItem = true; char * psz_capability;
do psz_capability = p_module->psz_capability;
if( !psz_capability || !*psz_capability )
{ {
switch( p_item->i_type ) /* Empty capability ? Let's look at the submodules */
module_t * p_submodule;
for( int j = 0; j < p_module->i_children; j++ )
{ {
case CONFIG_ITEM_STRING: p_submodule = (module_t*)p_module->pp_children[ j ];
case CONFIG_ITEM_FILE: if( p_submodule->psz_capability && *p_submodule->psz_capability )
case CONFIG_ITEM_MODULE: {
case CONFIG_ITEM_DIRECTORY: psz_capability = p_submodule->psz_capability;
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
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:
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
textControl = new ConfigTextControl( rect, p_item->psz_text,
CONFIG_ITEM_INTEGER, p_item->psz_name );
configView->AddChild( textControl );
break;
case CONFIG_ITEM_FLOAT:
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
textControl = new ConfigTextControl( rect, p_item->psz_text,
CONFIG_ITEM_FLOAT, p_item->psz_name );
configView->AddChild( textControl );
break;
case CONFIG_ITEM_BOOL:
if( !firstItem )
rect.OffsetBy( 0,25 );
else
firstItem = false;
checkBox = new ConfigCheckBox( rect, p_item->psz_text,
p_item->psz_name );
configView->AddChild( checkBox );
break; break;
}
} }
}
} while( p_item->i_type != CONFIG_HINT_END && p_item++ ); StringItemWithView * capabilityItem;
capabilityItem = NULL;
/* Adjust the configView size */ for( int j = 0; j < fOutline->CountItemsUnder( modulesItem, true ); j++ )
rect.bottom += 10; {
configView->ResizeTo( configView->Bounds().Width(), rect.bottom ); if( !strcmp( ((StringItemWithView*)
fOutline->ItemUnderAt( modulesItem, true, j ))->Text(),
psz_capability ) )
{
capabilityItem = (StringItemWithView*)
fOutline->ItemUnderAt( modulesItem, true, j );
break;
}
}
if( !capabilityItem )
{
capabilityItem = new StringItemWithView( psz_capability );
fOutline->AddUnder( capabilityItem, modulesItem );
}
/* Add the item to the tree */ /* Now add the item ! */
StringItemWithView * stringItem; StringItemWithView * stringItem;
stringItem = new StringItemWithView( p_module->psz_object_name ); stringItem = new StringItemWithView( p_module->psz_object_name );
stringItem->fConfigView = configView; stringItem->fConfigView = BuildConfigView( &p_item, false );
if( !strcmp( p_module->psz_object_name, "beos" ) fOutline->AddUnder( stringItem, capabilityItem );
|| !strcmp( p_module->psz_object_name, "main" ) )
fOutline->AddItem( stringItem );
else
fOutline->AddUnder( stringItem, modulesItem );
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
/* Set the correct values */ /* Set the correct values */
ApplyChanges( false ); ApplyChanges( false );
/* Sort items, collapse the Modules one */ /* Sort items, collapse the tree */
fOutline->FullListSortItems( compare_func ); fOutline->FullListSortItems( compare_func );
fOutline->Collapse( modulesItem ); fOutline->Collapse( modulesItem );
for( int i = 0; i < fOutline->CountItemsUnder( modulesItem, true ); i++ )
fOutline->Collapse( fOutline->ItemUnderAt( modulesItem, true, i ) );
/* Select the first item */ /* Select the first item */
fOutline->Select( 0 ); fOutline->Select( 0 );
/* Add the buttons */ /* Add the buttons */
BButton * button; BButton * button;
rect = Bounds(); rect = Bounds();
...@@ -264,7 +229,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface, ...@@ -264,7 +229,7 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
button = new BButton( rect, "", _("Defaults"), new BMessage( PREFS_DEFAULTS ), button = new BButton( rect, "", _("Defaults"), new BMessage( PREFS_DEFAULTS ),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM ); B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
fPrefsView->AddChild( button ); fPrefsView->AddChild( button );
Hide(); Hide();
Show(); Show();
} }
...@@ -296,16 +261,16 @@ void PreferencesWindow::MessageReceived( BMessage * message ) ...@@ -296,16 +261,16 @@ void PreferencesWindow::MessageReceived( BMessage * message )
case PREFS_ITEM_SELECTED: case PREFS_ITEM_SELECTED:
Update(); Update();
break; break;
case PREFS_DEFAULTS: case PREFS_DEFAULTS:
config_ResetAll( p_intf ); config_ResetAll( p_intf );
ApplyChanges( false ); ApplyChanges( false );
break; break;
case PREFS_APPLY: case PREFS_APPLY:
ApplyChanges( true ); ApplyChanges( true );
break; break;
case PREFS_SAVE: case PREFS_SAVE:
SaveChanges(); SaveChanges();
break; break;
...@@ -321,7 +286,7 @@ void PreferencesWindow::MessageReceived( BMessage * message ) ...@@ -321,7 +286,7 @@ void PreferencesWindow::MessageReceived( BMessage * message )
void PreferencesWindow::FrameResized( float width, float height ) void PreferencesWindow::FrameResized( float width, float height )
{ {
BWindow::FrameResized( width, height ); BWindow::FrameResized( width, height );
/* Get the current config BView */ /* Get the current config BView */
BView * view; BView * view;
view = fConfigScroll->ChildAt( 0 ); view = fConfigScroll->ChildAt( 0 );
...@@ -339,9 +304,9 @@ void PreferencesWindow::Update() ...@@ -339,9 +304,9 @@ void PreferencesWindow::Update()
return; return;
StringItemWithView * selectedItem = StringItemWithView * selectedItem =
(StringItemWithView*) fOutline->ItemAt( fOutline->CurrentSelection() ); (StringItemWithView*) fOutline->ItemAt( fOutline->CurrentSelection() );
if( !selectedItem->fConfigView ) if( !selectedItem->fConfigView )
/* This must be the "Modules" item */ /* This is a category */
return; return;
if( fConfigScroll ) if( fConfigScroll )
...@@ -357,7 +322,7 @@ void PreferencesWindow::Update() ...@@ -357,7 +322,7 @@ void PreferencesWindow::Update()
fDummyView->RemoveChild( fConfigScroll ); fDummyView->RemoveChild( fConfigScroll );
delete fConfigScroll; delete fConfigScroll;
} }
/* Create a BScrollView with the new config BView in it */ /* Create a BScrollView with the new config BView in it */
BRect oldBounds = selectedItem->fConfigView->Bounds(); BRect oldBounds = selectedItem->fConfigView->Bounds();
selectedItem->fConfigView->ResizeTo( fDummyView->Bounds().Width() - selectedItem->fConfigView->ResizeTo( fDummyView->Bounds().Width() -
...@@ -380,15 +345,15 @@ void PreferencesWindow::UpdateScrollBar() ...@@ -380,15 +345,15 @@ void PreferencesWindow::UpdateScrollBar()
{ {
/* We have to fix the scrollbar manually because it doesn't handle /* We have to fix the scrollbar manually because it doesn't handle
correctly simple BViews */ correctly simple BViews */
/* Get the current config view */ /* Get the current config view */
BView * view; BView * view;
view = fConfigScroll->ChildAt( 0 ); view = fConfigScroll->ChildAt( 0 );
/* Get the available BRect for display */ /* Get the available BRect for display */
BRect display = fConfigScroll->Bounds(); BRect display = fConfigScroll->Bounds();
display.right -= B_V_SCROLL_BAR_WIDTH; display.right -= B_V_SCROLL_BAR_WIDTH;
/* Fix the scrollbar */ /* Fix the scrollbar */
BScrollBar * scrollBar; BScrollBar * scrollBar;
long max; long max;
...@@ -417,9 +382,9 @@ void PreferencesWindow::ApplyChanges( bool doIt ) ...@@ -417,9 +382,9 @@ void PreferencesWindow::ApplyChanges( bool doIt )
{ {
item = (StringItemWithView*) fOutline->ItemAt( i ); item = (StringItemWithView*) fOutline->ItemAt( i );
view = item->fConfigView; view = item->fConfigView;
if( !view ) if( !view )
/* This must be the "Modules" item */ /* This is a category */
continue; continue;
for( int j = 0; j < view->CountChildren(); j++ ) for( int j = 0; j < view->CountChildren(); j++ )
...@@ -521,3 +486,115 @@ void PreferencesWindow::ReallyQuit() ...@@ -521,3 +486,115 @@ void PreferencesWindow::ReallyQuit()
Hide(); Hide();
Quit(); Quit();
} }
/*****************************************************************************
* PreferencesWindow::BuildConfigView
*****************************************************************************/
BView * PreferencesWindow::BuildConfigView( module_config_t ** pp_item,
bool stop_after_category )
{
/* Build the config view for this module */
BRect rect = fDummyView->Bounds();
rect.right -= B_V_SCROLL_BAR_WIDTH;
BView * configView;
configView = new BView( rect, "config view",
B_FOLLOW_NONE, B_WILL_DRAW );
configView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
rect = configView->Bounds();
rect.InsetBy( 10, 10 );
rect.bottom = rect.top + TEXT_HEIGHT;
ConfigTextControl * textControl;
ConfigCheckBox * checkBox;
ConfigMenuField * menuField;
BPopUpMenu * popUp;
bool firstItem = true;
bool categoryHit = false;
do
{
switch( (*pp_item)->i_type )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_DIRECTORY:
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
if( (*pp_item)->ppsz_list && (*pp_item)->ppsz_list[0] )
{
popUp = new BPopUpMenu( "" );
menuField = new ConfigMenuField( rect, (*pp_item)->psz_text,
popUp, (*pp_item)->psz_name );
BMenuItem * menuItem;
for( int i = 0; (*pp_item)->ppsz_list[i]; i++ )
{
menuItem = new BMenuItem( (*pp_item)->ppsz_list[i], new BMessage() );
popUp->AddItem( menuItem );
}
configView->AddChild( menuField );
}
else
{
textControl = new ConfigTextControl( rect, (*pp_item)->psz_text,
CONFIG_ITEM_STRING, (*pp_item)->psz_name );
configView->AddChild( textControl );
}
break;
case CONFIG_ITEM_INTEGER:
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
textControl = new ConfigTextControl( rect, (*pp_item)->psz_text,
CONFIG_ITEM_INTEGER, (*pp_item)->psz_name );
configView->AddChild( textControl );
break;
case CONFIG_ITEM_FLOAT:
if( !firstItem )
rect.OffsetBy( 0, 25 );
else
firstItem = false;
textControl = new ConfigTextControl( rect, (*pp_item)->psz_text,
CONFIG_ITEM_FLOAT, (*pp_item)->psz_name );
configView->AddChild( textControl );
break;
case CONFIG_ITEM_BOOL:
if( !strcmp( (*pp_item)->psz_name, "advanced" ) )
/* Don't show this one, the interface doesn't handle it anyway */
break;
if( !firstItem )
rect.OffsetBy( 0,25 );
else
firstItem = false;
checkBox = new ConfigCheckBox( rect, (*pp_item)->psz_text,
(*pp_item)->psz_name );
configView->AddChild( checkBox );
break;
case CONFIG_HINT_CATEGORY:
if( stop_after_category )
categoryHit = true;
}
} while( !categoryHit &&
(*pp_item)->i_type != CONFIG_HINT_END &&
(*pp_item)++ );
/* Adjust the configView size */
rect.bottom += 10;
configView->ResizeTo( configView->Bounds().Width(), rect.bottom );
return configView;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PreferencesWindow.h * PreferencesWindow.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.h,v 1.14 2003/05/13 14:11:33 titer Exp $ * $Id: PreferencesWindow.h,v 1.15 2003/05/17 18:30:41 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <InterfaceKit.h> #include <InterfaceKit.h>
#define PREFS_WINDOW_WIDTH 600 #define PREFS_WINDOW_WIDTH 700
#define PREFS_WINDOW_HEIGHT 400 #define PREFS_WINDOW_HEIGHT 400
#define PREFS_ITEM_SELECTED 'pris' #define PREFS_ITEM_SELECTED 'pris'
#define PREFS_DEFAULTS 'prde' #define PREFS_DEFAULTS 'prde'
...@@ -38,7 +38,10 @@ class StringItemWithView : public BStringItem ...@@ -38,7 +38,10 @@ class StringItemWithView : public BStringItem
{ {
public: public:
StringItemWithView( const char * text ) StringItemWithView( const char * text )
: BStringItem( text ) {} : BStringItem( text )
{
fConfigView = NULL;
}
/* Here we store the config BView associated to this module */ /* Here we store the config BView associated to this module */
BView * fConfigView; BView * fConfigView;
...@@ -108,6 +111,9 @@ class PreferencesWindow : public BWindow ...@@ -108,6 +111,9 @@ class PreferencesWindow : public BWindow
void ReallyQuit(); void ReallyQuit();
private: private:
BView * BuildConfigView( module_config_t ** pp_item,
bool stop_after_category );
BView * fPrefsView; BView * fPrefsView;
BOutlineListView * fOutline; BOutlineListView * fOutline;
BView * fDummyView; BView * fDummyView;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment