xref: /haiku/src/preferences/media/MediaWindow.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2003-2012, Haiku, Inc.
3  * Distributed under the terms of the MIT license.
4  *
5  * Authors:
6  *		Sikosis, Jérôme Duval
7  *		yourpalal, Alex Wilson
8  */
9 #ifndef MEDIA_WINDOW_H
10 #define MEDIA_WINDOW_H
11 
12 
13 #include <ListView.h>
14 #include <MediaAddOn.h>
15 #include <ParameterWeb.h>
16 #include <StringView.h>
17 #include <Window.h>
18 
19 #include <ObjectList.h>
20 
21 #include "MediaAlert.h"
22 #include "MediaIcons.h"
23 #include "MediaListItem.h"
24 #include "MediaViews.h"
25 
26 
27 #define SETTINGS_FILE "MediaPrefs Settings"
28 
29 
30 class BCardLayout;
31 class BSeparatorView;
32 
33 
34 class MediaWindow : public BWindow {
35 public:
36 								MediaWindow(BRect frame);
37    								~MediaWindow();
38 
39     		status_t			InitCheck();
40 
41 	// methods to be called by MediaListItems...
42 			void				SelectNode(const dormant_node_info* node);
43 			void				SelectAudioSettings(const char* title);
44 			void				SelectVideoSettings(const char* title);
45 			void				SelectAudioMixer(const char* title);
46 
47 	// methods to be called by SettingsViews...
48 			void				UpdateInputListItem(
49 									MediaListItem::media_type type,
50 									const dormant_node_info* node);
51 			void				UpdateOutputListItem(
52 									MediaListItem::media_type type,
53 									const dormant_node_info* node);
54 
55     virtual	bool 				QuitRequested();
56     virtual	void				MessageReceived(BMessage* message);
57 
58 private:
59 	typedef BObjectList<dormant_node_info> NodeList;
60 
61 			void				_InitWindow();
62 			status_t			_InitMedia(bool first);
63 
64 			void				_FindNodes();
65 			void				_FindNodes(media_type type, uint64 kind,
66 									NodeList& into);
67 			void				_AddNodeItems(NodeList &from,
68 									MediaListItem::media_type type);
69 			void				_EmptyNodeLists();
70 			void				_UpdateListViewMinWidth();
71 
72 			NodeListItem*		_FindNodeListItem(dormant_node_info* info);
73 
74 	static	status_t			_RestartMediaServices(void* data);
75 	static	bool				_UpdateProgress(int stage, const char * message,
76 									void * cookie);
77 
78 			void				_ClearParamView();
79 			void				_MakeParamView();
80 			void				_MakeEmptyParamView();
81 
82 	struct SmartNode {
83 								SmartNode(const BMessenger& notifyHandler);
84 								~SmartNode();
85 
86 			void				SetTo(const dormant_node_info* node);
87 			void				SetTo(const media_node& node);
88 			bool				IsSet();
89 								operator media_node();
90 
91 	private:
92 			void				_FreeNode();
93 			media_node*			fNode;
94 			BMessenger			fMessenger;
95 	};
96 
97 			BListView*			fListView;
98 			BSeparatorView*		fTitleView;
99 			BCardLayout*		fContentLayout;
100 			AudioSettingsView*	fAudioView;
101 			VideoSettingsView*	fVideoView;
102 
103 			SmartNode			fCurrentNode;
104 			BParameterWeb*		fParamWeb;
105 
106 
107 			NodeList			fAudioInputs;
108 			NodeList			fAudioOutputs;
109 			NodeList			fVideoInputs;
110 			NodeList			fVideoOutputs;
111 
112 			MediaAlert*			fAlert;
113 			status_t			fInitCheck;
114 };
115 
116 
117 #endif	// MEDIA_WINDOW_H
118