Old 1st September 2002, 04:25   #1
tangofan
Junior Member
 
Join Date: Aug 2002
Location: San Francisco Bay Area
Posts: 25
Question Q's regarding attrib input and output of settings

Hi,

I'm new to Winamp programming and just
trying to get a little more familiar
with the library.

For my 1st project I'd like to write
an Automatic Gain Controller DSP.
I need a window where I can input some
settings via a slider, checkboxes
and input fields and where I also can
output some info about the current status
of the DSP when it is active.

My first approach now was to follow the
exampleAttrib from the toolkit.
My questions:
1. If I follow that example, how do
I best register "output-only" fields?
As TextBar? Or what?
2. How do I notify the window that an
output attribute has changed?

3. Are there approaches that are perhaps
better suited to my problem, such
as following the exampleprefsgroup
example by using an entry in the
Preferences window or any other
approach?

Thanks in advance for any input,

Bernhard
tangofan is offline  
Old 6th September 2002, 10:30   #2
Kell
Member
 
Join Date: Aug 2002
Posts: 63
2) You don't have to notify the window. When you use the methods to change the value of the attrib (such as setValueAsInt ), it automatically updates the objects associated with it.

3) A preferences window makes it more integrated into how people expect to configure their components, but maybe yor own window would do better if you want full control over it. Namedly, in the example below, you'd know exactly when the window is open, and wether you had to update the components or not.

1) I can't think of an easy way that doesn't involve a bit of programming. If you know the RootWnd pointer to the window, you could do:

code:

// let's say your text field is named "mycomponent.output.text1"
// and that "wnd" is a RootWnd *, a pointer to your window )

char * output = "EXAMPLE";
GuiObject * text1 = wnd->getGuiObject()->findObject( "mycomponent.output.text1" );
if ( text1 )
text1->guiobject_setXmlParam ( "text",
StringPrintf( "Output: %s", output ) );



If you create a new window, you know what "wdn" is, so it's no big deal. If you use a Preferences window, you can do it with:

code:

GUID prefsGUID = nsGUID:fromChar( "{B397A4CE-455A-4D62-8BF6-D0F91ACB70E6}" );
RootWnd * prefsWnd = api->skinwnd_enumByGuid( prefsGUID, 0 );
if ( prefsWnd )
{
// the code above, with wnd = prefsWnd;
}



The disadvantage of using a preferences window is that you have to write extra code to detect when the window is displayed, because this will only work if the Prefs window is open, in your component's section. Otherwise it won't be able to find the text.

There might be an easier way to do this though :)



If you want to use both your window and the Preferences window, you might be able to pull the trick of sticking your window into the client space of the preferences window, but that, I'm not sure of how to do (yet).
Kell is offline  
Old 6th September 2002, 16:51   #3
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Alright... here's the quick and dirty lodown:

1. Never Ever Ever listen to Kell unless you want to do things in a hackish way that will eventually crash in wierd and awful ways. Every example I've seen from him is the hacked way of doing it. They're bad. Sorry Kell, but its true.
- NEVER EVER get the values of attribs by hunting the rootwnd pointer of the Preferences window! Bad! Bad! If you are using _bool, _int etc., they automatically get updated with the latest values that are in prefs. If you need notification of when they change, then your WAComponentClient class should override the cfgitem_onAttribSetValue( Attribute* attr ) function.

2. You need to decide where you want your interface to be. If you would like to have a seperate window that is activated through either the thinger, or through the Windows context menu, first look at examplecodegui. That gives the good basics on creating windows, etc. Then move on to exampleattribs.

If you'd rather have your settings be completely within the preferences window, then take a look at the howto at: http://forums.winamp.com/showthread....threadid=92699

Don't worry, even if you don't have a window of your own, you can still get notification of changed settings through cfgitem_onAttribSetValue( Attribute* attr ).

If you'd like to have the same window appear in both the thinger AND in preferences, you can do that to (although I don't know why). Create your thinger launched window, then follow the Mostly C++ way in the howto I reference above. Then you register that window as a thinger item, a Windows Context menu item, and have it linked through preferences XML.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline  
Old 6th September 2002, 21:13   #4
Kell
Member
 
Join Date: Aug 2002
Posts: 63
To be honest, you're not so wrong schweitn. But in this case, if you read the example above, it was refering to a way to change a static text output in a window, NOT changing attribs. Either way, if you know a better way to do it I'm all ears, honest.
And it's not true that it's the hackish way... well, mostly, hell this one only uses Wasabi calls.

(and my programs don't really usually crash, they even work - proof is in my signature)
Kell is offline  
Old 6th September 2002, 21:28   #5
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
The prefered way (although I've never done it myself) for changing a static item if Preferences is to use a text feed.

You need to implement the svc_textFeed service in your component, and of course link it up in your Preferences Xml. You can see an example of this in \Wacs\xml\winamp\prefs\prefs-media.xml ...
code:

<list id="medialist"
feed="Preferences:MEDIAEXTENTIONS"
x="1" y="1" w="93" h="-22"
relath="1"
multiselect="1"
autodeselect="0"
cfgattrib="{C30C97E6-77E6-4da4-9F4F-C7F848F8F641};keepers"
/>


Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline  
Old 6th September 2002, 21:40   #6
tangofan
Junior Member
 
Join Date: Aug 2002
Location: San Francisco Bay Area
Posts: 25
So that would be the solution, if
I were using a preferences window, correct?

Do you know of a way to do this with a
static or non-static attribute?
tangofan is offline  
Old 6th September 2002, 21:46   #7
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Like I said, I've never done it... but what you do is create a Wasabi:text in the xml with a "feed" that you set equal to some string you decide upon.

Then when you implement the svc_textFeed in your component, you will get passed that feed string, and asked to provide it with the text to fill into that Wasabi:text object.

That of course is if your doing it in Preferences where you specify everything through Xml.

If you're doing your own window thats launched from the thinger, then you just create a Wnd (ContWnd, StylePosWnd, there are several ones to choose from) that contains a TextBar. Then just change the text in the text bar with setName(). Simple.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline  
Old 6th September 2002, 21:47   #8
tmyhre
Junior Member
 
Join Date: Sep 2002
Location: Somewhere in Canada
Posts: 21
Hmm... speaking of exampleattribs...

I'm working through that example right now, and I'm a little confused about the usage of this bit of code:
code:

// ExampleAttrib: Attribute Change Notification Methods
//
void ExampleAttribWnd::onIntChange(int id, int value) {
myDropList->setCurSel(attr->intAttr);
}


If I have more than one droplist in my window, I assume that I'll need to add a switch() statement on the id to figure out which droplist changed. OK, fine, no problemo. Then why is value being ignored? Shouldn't this read myDropList->setCurSel(value)? When does this callback get invoked exactly, anyway?
tmyhre is offline  
Old 6th September 2002, 21:59   #9
schweitn
Winamp3 Component Guuuru
Beta Team
 
schweitn's Avatar
 
Join Date: Dec 2000
Location: Milwaukee, WI
Posts: 1,068
Send a message via AIM to schweitn Send a message via Yahoo to schweitn
Yeah - I don't use that AttrHandler crap... Its an extra level of indirection that is often times not wanted... here's how to do it without that handler class.
code:

// Header File
class MyComponent : public WAComponetClient
{
public:
// ... Your Class Stuff
virtual int cfgitem_onAttribSetValue( Attribute* attr );

private:
_int m_nMyIntAttrib;
};

// CPP File
MyComponent::MyComponent()
: WAComponentClient( "My Component",
m_nMyIntAttrib ( "My Int Attrib", 1 )
{
// ... Register Stuff and do some init
registerAttribute( &m_nMyIntAttrib );
}

int MyComponent::cfgitem_onAttribSetValue( Attribute* attr )
{
// Do something when the value changes
if ( attr == &m_nMyIntAttrib )
{
// .. Do some validation or something
}

return 1;
}


Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
- Albert Einstein

Winamp 3 Projects | Winamp 2x Plugin Manager | Explorer Playlist | FileSystem Object | Shoutcast List | Sashimi
schweitn is offline  
 
Go Back   Winamp & Shoutcast Forums > Winamp3 > Wasabi Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump