xref: /haiku/src/preferences/media/MediaWindow.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2003-2014, 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 <Alert.h>
14 #include <ListView.h>
15 #include <MediaAddOn.h>
16 #include <ParameterWeb.h>
17 #include <StringView.h>
18 #include <Window.h>
19 
20 #include <ObjectList.h>
21 
22 #include "MediaIcons.h"
23 #include "MediaListItem.h"
24 #include "MediaViews.h"
25 
26 #define SETTINGS_FILE "MediaPrefs Settings"
27 
28 
29 class BCardLayout;
30 class BSeparatorView;
31 class MidiSettingsView;
32 
33 class MediaWindow : public BWindow {
34 public:
35 								MediaWindow(BRect frame);
36 								~MediaWindow();
37 
38 			status_t			InitCheck();
39 
40 	// methods to be called by MediaListItems...
41 			void				SelectNode(const dormant_node_info* node);
42 			void				SelectAudioSettings(const char* title);
43 			void				SelectVideoSettings(const char* title);
44 			void				SelectAudioMixer(const char* title);
45 			void				SelectMidiSettings(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 
76 			void				_ClearParamView();
77 			void				_MakeParamView();
78 			void				_MakeEmptyParamView();
79 
80 	struct SmartNode {
81 								SmartNode(const BMessenger& notifyHandler);
82 								~SmartNode();
83 
84 			void				SetTo(const dormant_node_info* node);
85 			void				SetTo(const media_node& node);
86 			bool				IsSet();
87 								operator media_node();
88 
89 	private:
90 			void				_FreeNode();
91 			media_node*			fNode;
92 			BMessenger			fMessenger;
93 	};
94 
95 			BListView*			fListView;
96 			BSeparatorView*		fTitleView;
97 			BCardLayout*		fContentLayout;
98 			AudioSettingsView*	fAudioView;
99 			VideoSettingsView*	fVideoView;
100 			MidiSettingsView*	fMidiView;
101 
102 			SmartNode			fCurrentNode;
103 			BParameterWeb*		fParamWeb;
104 
105 
106 			NodeList			fAudioInputs;
107 			NodeList			fAudioOutputs;
108 			NodeList			fVideoInputs;
109 			NodeList			fVideoOutputs;
110 
111 			status_t			fInitCheck;
112 			thread_id			fRestartThread;
113 			BAlert*				fRestartAlert;
114 };
115 
116 
117 #endif	// MEDIA_WINDOW_H
118