xref: /haiku/src/preferences/media/MediaWindow.h (revision 6d2f2ec177bf615a117a7428d71be4330545b320)
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 <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 "MediaIcons.h"
22 #include "MediaListItem.h"
23 #include "MediaViews.h"
24 
25 #define MEDIA_SERVICE_NOTIFICATION_ID "MediaServiceNotificationID"
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 	static	bool				_UpdateProgress(int stage, const char* message,
76 									void* cookie);
77 			void				_Notify(float progress, const char* message);
78 
79 			void				_ClearParamView();
80 			void				_MakeParamView();
81 			void				_MakeEmptyParamView();
82 
83 	struct SmartNode {
84 								SmartNode(const BMessenger& notifyHandler);
85 								~SmartNode();
86 
87 			void				SetTo(const dormant_node_info* node);
88 			void				SetTo(const media_node& node);
89 			bool				IsSet();
90 								operator media_node();
91 
92 	private:
93 			void				_FreeNode();
94 			media_node*			fNode;
95 			BMessenger			fMessenger;
96 	};
97 
98 			BListView*			fListView;
99 			BSeparatorView*		fTitleView;
100 			BCardLayout*		fContentLayout;
101 			AudioSettingsView*	fAudioView;
102 			VideoSettingsView*	fVideoView;
103 			MidiSettingsView*	fMidiView;
104 
105 			SmartNode			fCurrentNode;
106 			BParameterWeb*		fParamWeb;
107 
108 
109 			NodeList			fAudioInputs;
110 			NodeList			fAudioOutputs;
111 			NodeList			fVideoInputs;
112 			NodeList			fVideoOutputs;
113 
114 			status_t			fInitCheck;
115 };
116 
117 
118 #endif	// MEDIA_WINDOW_H
119