AeIconFieldUI.c++ 2.17 KB
#include <assert.h>
#include <Vk/VkApp.h>

#include "AeTypes.h"
#include "AeAsset.h"
#include "AeAssetBase.h"
#include "AeFieldUI.h"
#include "AeAssetUI.h"
#include "AeAssetBinUI.h"
#include "AeBinEditor.h"
#include "AeBinView.h"
#include "AePlayer.h"


AeIconFieldUI::AeIconFieldUI (const char * name,
			      Boolean isSelectable,
			      Boolean isCommon,
			      TJustify justify) : 
    AeFieldUI (name, False, isSelectable, False, isCommon, justify, 0)
{
    fWidth = kMinWidth;		// enough room to fit a standard icon size
    fNeedsWidthUpdate = False;	// should never change since icons are uneditable
}


AeIconFieldUI::~AeIconFieldUI (void)
{
}


void
AeIconFieldUI::GetValueString (AeAsset * asset, String string)
{
    *string = '\0';
}


void
AeIconFieldUI::HandleDoubleClick (AeBinEditor * editor,
				  AeAssetUI * assetUI,
				  XEvent * event,
				  TEditModifier modifier)
{
    assert (editor);
    assert (assetUI);

    AePlayer * player = editor->GetPlayer ();

    // if the asset is not the currently displayed bin in form,
    // then tell the form to make it the current displayed bin.
    if (assetUI->GetLevel () != 0)
	editor->SelectTypedBinUI (assetUI->GetType ());

    // if we can put the asset on and offline, then toggle
    // its online state
    if ((assetUI->GetAsset())->CanOnline ())
    {
	(assetUI->GetAsset())->ToggleOnline ();

	(editor->GetAssetBase())->NotifySuspend ();
	(editor->GetAssetBase())->NotifyOnline (assetUI->GetAsset());
	(editor->GetAssetBase())->NotifyResume ();
    }
    
#ifdef NOT_SUPPORTED
    else
	editor->OpenEditor (assetUI->GetAsset ());
#endif
}


Boolean
AeIconFieldUI::HandleButtonPress (AeBinEditor * editor,
				  AeAssetUI * assetUI,
				  XEvent * event,
				  TEditModifier modifier)
{
    assert (editor);
    assert (assetUI);

    AePlayer * player = editor->GetPlayer ();

    if (player)
    {
	// start the audition on a button down
	if (modifier == kModDown)
	    player->AuditionStart (assetUI->GetAsset ());
	
	// stop the audition if the user moves or releases the mouse
	else if (modifier == kModUp || modifier == kModMotion)
	    player->AuditionStop ();
    }	

    editor->SelectAssetUI (assetUI, modifier);

    return True;
}