Ejemplo n.º 1
0
void DiagramEndPoint::messageDropped(
	BPoint point,
	BMessage *message)
{
	D_MESSAGE(("DiagramEndPoint::messageDropped()\n"));
	switch (message->what)
	{
		case M_WIRE_DRAGGED:
		{
			D_MESSAGE(("DiagramEndPoint::messageDropped(M_WIRE_DRAGGED)\n"));
			DiagramEndPoint *endPoint;
			if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK)
			 && (endPoint != this))
			{
				bool success = connectionRequested(endPoint);
				BMessage dropMsg(M_WIRE_DROPPED);
				dropMsg.AddPointer("from", reinterpret_cast<void *>(endPoint));
				dropMsg.AddPointer("to", reinterpret_cast<void *>(this));
				dropMsg.AddBool("success", success);
				DiagramView* v = view();
				BMessenger(v).SendMessage(&dropMsg);
				if (isConnecting())
				{
					m_connecting = false;
					disconnected();
				}
			}
			return;
		}
		default:
		{
			DiagramItem::messageDropped(point, message);
		}
	}
}
Ejemplo n.º 2
0
void StatusView::MessageReceived(
	BMessage *message) {
	D_MESSAGE(("StatusView::MessageReceived()\n"));

	switch (message->what) {
		case 'Tick':
			fadeTick();
			break;
			
		case RouteAppNodeManager::M_LOG: {
			D_MESSAGE((" -> RouteAppNodeManager::M_LOG\n"));

			BString title;
			if (message->FindString("title", &title) != B_OK) {
				return;
			}
			BString details, line;
			for (int32 i = 0; message->FindString("line", i, &line) == B_OK; i++) {
				if (details.CountChars() > 0) {
					details << "\n";
				}
				details << line;
			}
			status_t error = B_OK;
			message->FindInt32("error", &error);
			setMessage(title, details, error);
			break;
		}
		default: {
			BStringView::MessageReceived(message);
		}
	}
}
Ejemplo n.º 3
0
void
CAssemblyWindow::MessageReceived(
	BMessage* message)
{
	switch (message->what)
	{
		case CEventEditor::TOOL_GRID:
		{
			D_MESSAGE((" -> TOOL_GRID\n"));
			int32 value;
			if (message->FindInt32("value", &value) != B_OK)
			{
				return;
			}
			Track()->EnableGridSnap(value);
			break;
		}
		case CEventEditor::TOOL_SELECT:
		case CEventEditor::TOOL_CREATE:
		case CEventEditor::TOOL_ERASE:
		case CEventEditor::TOOL_TEXT:
		{
			D_MESSAGE((" -> TOOL_SELECT/CREATE/ERASE/TEXT\n"));
			m_toolStates[0] = message->what;
			break;
		}
		case 'cMet':
		{
			// ++++++ what is this ?
			stripFrame->SetClockType(ClockType_Metered);
			break;
		}
		case 'cRea':
		{
			// ++++++ what is this ?
			stripFrame->SetClockType(ClockType_Real);
			break;
		}
		default:
		{
			CTrackWindow::MessageReceived(message);
			break;
		}
	}
}
Ejemplo n.º 4
0
void ParameterWindow::MessageReceived(
    BMessage *message) {
    D_MESSAGE(("ParameterWindow::MessageReceived()\n"));

    switch (message->what) {
    case M_START_CONTROL_PANEL: {
        D_MESSAGE((" -> M_START_CONTROL_PANEL\n"));
        status_t error = _startControlPanel();
        if (error) {
            BString s = "Could not start control panel";
            s << " (" << strerror(error) << ")";
            BAlert *alert = new BAlert("", s.String(), "OK", 0, 0,
                                       B_WIDTH_AS_USUAL, B_WARNING_ALERT);
            alert->Go(0);
        }
        bool replace = false;
        if ((message->FindBool("replace", &replace) == B_OK)
                && (replace == true)) {
            PostMessage(B_QUIT_REQUESTED);
        }
        break;
    }
    case M_THEME_SELECTED: {
        D_MESSAGE((" -> M_THEME_SELECTED\n"));
        int32 themeID;
        if (message->FindInt32("themeID", &themeID) != B_OK) {
            return;
        }
        // not yet implemented
        break;
    }
    case B_MEDIA_WEB_CHANGED: {
        D_MESSAGE((" -> B_MEDIA_WEB_CHANGED\n"));
        _updateParameterView();
        _constrainToScreen();
        break;
    }
    default: {
        BWindow::MessageReceived(message);
    }
    }
}
Ejemplo n.º 5
0
void DormantNodeView::MessageReceived(
	BMessage *message) {
	D_MESSAGE(("DormantNodeView::MessageReceived()\n"));

	switch (message->what) {
		case B_MEDIA_FLAVORS_CHANGED: {
			D_MESSAGE((" -> B_MEDIA_FLAVORS_CHANGED\n"));

			// init & re-populate the list
			int32 addOnID = 0;
			if (message->FindInt32("be:addon_id", &addOnID) != B_OK) {
				D_MESSAGE((" -> messages doesn't contain 'be:addon_id'!\n"));
				return;
			}
			_updateList(addOnID);
			break;
		}
		case InfoWindowManager::M_INFO_WINDOW_REQUESTED: {
			D_MESSAGE((" -> InfoWindowManager::M_INFO_WINDOW_REQUESTED)\n"));

			DormantNodeListItem *item;
			item = dynamic_cast<DormantNodeListItem *>(ItemAt(CurrentSelection()));
			if (item) {
				InfoWindowManager *manager = InfoWindowManager::Instance();
				if (manager && manager->Lock()) {
					manager->openWindowFor(item->info());
					manager->Unlock();
				}
			}
			break;
		}
		default: {
			_inherited::MessageReceived(message);
		}
	}
}
Ejemplo n.º 6
0
void DiagramEndPoint::messageDragged(
	BPoint point,
	uint32 transit,
	const BMessage *message)
{
	D_MOUSE(("DiagramEndPoint::messageDragged()\n"));
	switch (message->what)
	{
		case M_WIRE_DRAGGED:
		{
			D_MESSAGE(("DiagramEndPoint::messageDragged(M_WIRE_DRAGGED)\n"));
			switch (transit)
			{
				case B_INSIDE_VIEW:
				{
					//PRINT((" -> transit: B_INSIDE_VIEW\n"));
					// this is a WORK-AROUND caused by the unreliability
					// of BViews DragMessage() routine !!
					if (isConnecting())
					{
						break;
					}
					else if (isConnected())
					{
						view()->trackWire(point);
					}
					/* this should be enough in theory:
					if (!isConnecting())
					{
						view()->trackWire(point);
					}
					//break;*/
				}
				case B_ENTERED_VIEW:
				{
					//PRINT((" -> transit: B_ENTERED_VIEW\n"));
					DiagramEndPoint *endPoint;
					if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK)
					 && (endPoint != this))
					{
						if (connectionRequested(endPoint))
						{
							view()->trackWire(connectionPoint());
							if (!isConnecting())
							{
								m_connecting = true;
								connected();
							}
						}
						else
						{
							view()->trackWire(point);
							if (isConnecting())
							{
								m_connecting = false;
								disconnected();
							}
						}
					}
					break;
				}
				case B_EXITED_VIEW:
				{
					//PRINT((" -> transit: B_EXITED_VIEW\n"));
					if (isConnecting())
					{
						m_connecting = false;
						disconnected();
					}
					break;
				}
			}
			break;
		}
		default:
		{
			DiagramItem::messageDragged(point, transit, message);
		}
	}
}
Ejemplo n.º 7
0
void MediaRoutingView::MessageReceived(
	BMessage* message)
{
	D_METHOD(("MediaRoutingView::MessageReceived()\n"));

	switch (message->what)
	{
		case B_MEDIA_NODE_CREATED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_CREATED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for(int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						// [e.moon 8dec99] allow for existing panel
						MediaNodePanel* panel;
						if(_findPanelFor(id, &panel) < B_OK)
							_addPanelFor(id, BPoint(5.0, 5.0));
					}
				}
			}
			break;
		}
		case B_MEDIA_NODE_DELETED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_DELETED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						_removePanelFor(id);
					}
				}
			}			
			break;
		}
		case B_MEDIA_CONNECTION_MADE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_MADE)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, n, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						Connection connection;
						if (manager->findConnection(output.node.node, output.source, &connection) == B_OK)
						{
							_addWireFor(connection);
						}
					}
				}
			}
			break;
		}
		case B_MEDIA_CONNECTION_BROKEN:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_BROKEN)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("__connection_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					int32 id;
					if (message->FindInt32("__connection_id", n, &id) == B_OK)
					{
						_removeWireFor(id);
					}	
				}
			}
			break;
		}
		case B_MEDIA_FORMAT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_FORMAT_CHANGED)\n"));
			
			media_node_id nodeID;
			if(message->FindInt32("__source_node_id", &nodeID) < B_OK)
				break;

			uint32 connectionID;
			if(message->FindInt32("__connection_id", (int32*)&connectionID) < B_OK)
				break;

			media_source* source;
			ssize_t dataSize;
			if(message->FindData("be:source", B_RAW_TYPE, (const void**)&source, &dataSize) < B_OK)
				break;
				
			MediaWire* wire;
			if(_findWireFor(connectionID, &wire) == B_OK) {
				// copy new connection data
				manager->findConnection(nodeID, *source, &wire->connection);
			}
			break;
		}
		case M_CLEANUP_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_M_CLEANUP_REQUESTED)\n"));
			cleanUp();
			break;
		}
		case M_SELECT_ALL:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_SELECT_ALL)\n"));
			selectAll(DiagramItem::M_BOX);
			break;
		}
		case M_DELETE_SELECTION:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_DELETE_SELECTION)\n"));
			_deleteSelection();
			break;
		}
		case M_NODE_CHANGE_CYCLING:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_CYCLING_CHANGED)\n"));
			bool cycle;
			if (message->FindBool("cycle", &cycle) == B_OK)
			{
				_changeCyclingForSelection(cycle);
			}
			break;
		}
		case M_NODE_CHANGE_RUN_MODE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_RUNMODE_CHANGED)\n"));
			int32 mode;
			if (message->FindInt32("run_mode", &mode) == B_OK)
			{
				_changeRunModeForSelection(static_cast<uint32>(mode));
			}
			break;
		}
		case M_LAYOUT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_LAYOUT_CHANGED)\n"));
			layout_t layout;
			if (message->FindInt32("layout", (int32*)&layout) == B_OK)
			{
				if (layout != m_layout)
				{
					layoutChanged(layout);
					updateDataRect();
					Invalidate();
				}
			}
			break;
		}
		case M_NODE_START_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_START_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StartTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StartTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_STOP_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_STOP_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StopTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StopTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_TWEAK_PARAMETERS: {
			D_MESSAGE((" -> M_NODE_TWEAK_PARAMETERS\n"));
			_openParameterWindowsForSelection();
			break;
		}
		case M_NODE_START_CONTROL_PANEL: {
			D_MESSAGE((" -> M_NODE_START_CONTROL_PANEL\n"));
			_startControlPanelsForSelection();
			break;
		}
		case M_GROUP_SET_LOCKED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_GROUP_SET_LOCKED)\n"));
			int32 groupID;
			if(message->FindInt32("groupID", &groupID) < B_OK)
				break;
			bool locked;
			if(message->FindBool("locked", &locked) < B_OK)
				break;
			NodeGroup* group;
			if(manager->findGroup(groupID, &group) < B_OK)
				break;
			uint32 f = locked ?
				group->groupFlags() | NodeGroup::GROUP_LOCKED :
				group->groupFlags() & ~NodeGroup::GROUP_LOCKED;
			group->setGroupFlags(f);
			break;
		}
		case M_BROADCAST_SELECTION: {
			D_MESSAGE((" -> M_BROADCAST_SELECTION\n"));
			_broadcastSelection();
			break;
		}
		case InfoWindowManager::M_INFO_WINDOW_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(InfoView::M_INFO_WINDOW_REQUESTED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("input", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_input input;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("input", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						input = *reinterpret_cast<const media_input *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(input);
							manager->Unlock();
						}
					}
				}
			}
			else if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(output);
							manager->Unlock();
						}
					}
				}
			}
			else
			{
				_openInfoWindowsForSelection();
			}
			break;
		}
		case NodeManager::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeManager::M_RELEASED)\n"));
			remove_observer(this, manager);
			const_cast<RouteAppNodeManager*&>(manager) = 0;	
			// +++++ disable view!
			break;
		}			
		case NodeRef::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeRef::M_RELEASED)\n"));
			// only relevant on shutdown; do nothing
			break;
		}
		default:
		{
			DiagramView::MessageReceived(message);
		}
	}
}
Ejemplo n.º 8
0
void MediaRoutingView::messageDropped(
	BPoint point,
	BMessage *message)
{
	D_METHOD(("MediaRoutingView::messageDropped()\n"));

	switch (message->what)
	{
		case DormantNodeView::M_INSTANTIATE_NODE:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(DormantNodeView::M_INSTANTIATE_NODE)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("which", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					dormant_node_info info;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("which", B_RAW_TYPE, &data, &dataSize) == B_OK)
					{
						memcpy(reinterpret_cast<void *>(&info), data, dataSize);
						NodeRef* droppedNode;
						status_t error;
						error = manager->instantiate(info, &droppedNode);
						if (!error)
						{
							m_lastDroppedNode = droppedNode->id();
							BPoint dropPoint, dropOffset;
							dropPoint = message->DropPoint(&dropOffset);
							m_lastDropPoint = align(ConvertFromScreen(dropPoint - dropOffset));
						}
						else
						{
							BString s;
							s << "Could not instantiate '" << info.name << "'";
							showErrorMessage(s, error);
						}
					}	
				}
			}
			break;
		}
		case B_SIMPLE_DATA:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(B_SIMPLE_DATA)\n"));
			entry_ref fileRef;
			if (message->FindRef("refs", &fileRef) == B_OK)
			{
				_checkDroppedFile(&fileRef, ConvertFromScreen(message->DropPoint()));
			}
			break;
		}
		case B_PASTE:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(B_PASTE)\n"));
			ssize_t size;
			const rgb_color *color; // [e.moon 21nov99] fixed const error
			if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, reinterpret_cast<const void **>(&color), &size) == B_OK)
			{
				_changeBackground(*color);
			}
			break;
		}
		default:
		{
			DiagramView::messageDropped(point, message);
		}
	}
}
Ejemplo n.º 9
0
void
CTrackListView::MessageReceived(
	BMessage *message)
{
	D_MESSAGE(("CTrackListView::MessageReceived()\n"));

	switch(message->what)
	{
		case CObservable::UPDATED:
		{
			int32 trackHint, docHint;
			int32 trackID;
		
			if (message->FindInt32("TrackID", &trackID) != B_OK)
				trackID = -1;
			if (message->FindInt32("TrackAttrs", &trackHint) != B_OK)
				trackHint = 0;
			if (message->FindInt32("DocAttrs", &docHint ) != B_OK)
				docHint = 0;
		
			if (trackHint != 0 || docHint != 0)
			{
				if (trackID >= 0)
				{
					for (int i = 0; i < CountItems(); i++)
					{
						CTrackListItem *item = dynamic_cast<CTrackListItem *>
											   (ItemAt(i));
						if (item && (item->GetTrackID() == trackID))
						{
							if (trackHint & (CTrack::Update_Name | CTrack::Update_Flags))
							{
								item->Update(this, be_plain_font);
								InvalidateItem(i);
							}
						}
					}
				}
				
				if ((docHint & CMeVDoc::Update_AddTrack)
				 || (docHint & CMeVDoc::Update_DelTrack)
				 || (docHint & CMeVDoc::Update_TrackOrder))
				{
					BuildTrackList();
				}
			}
			break;
		}
		case CTrackListItem::EDIT_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::EDIT_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				if (item)
					m_doc->ShowWindowFor(item->GetTrack());
			}
			break;
		}
		case CTrackListItem::MUTE_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::MUTE_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				CTrack *track = item->GetTrack();
				track->SetMuted(!track->Muted());
				track->NotifyUpdate(CTrack::Update_Name, NULL);
				m_doc->SetModified();
			}
			break;
		}
		case CTrackListItem::SOLO_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::SOLO_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				// nyi
			}
			break;
		}
		case CTrackListItem::DELETE_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::DELETE_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				CTrack *track = item->GetTrack();
				CTrackDeleteUndoAction *undoAction;
				undoAction = new CTrackDeleteUndoAction(track);
				m_doc->AddUndoAction(undoAction);
			}
			break;
		}
		case CTrackListItem::RENAME_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::RENAME_TRACK\n"));

			int32 index = CurrentSelection();
			if (index < 0)
				return;
			CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
			if (item)
				item->StartEdit(this, index, ItemFrame(index));
			break;
		}
		case CTrackListItem::TRACK_NAME_EDITED:
		{
			D_MESSAGE((" -> CTrackListItem::TRACK_NAME_EDITED\n"));

			int32 index;
			BString name;
			if (message->FindInt32("index", &index) != B_OK)
				return;
			CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
			if (!item)
				return;
			item->StopEdit();
			if (message->FindString("text", &name) == B_OK)
			{
				// name changed
				CTrack *track = item->GetTrack();
				CTrackRenameUndoAction *undoAction;
				undoAction = new CTrackRenameUndoAction(track, name);
				m_doc->AddUndoAction(undoAction);
			}
			MakeFocus(true);
			break;
		}
		case MeVDragMsg_ID:
		{
			D_MESSAGE((" -> MeVDragMsg_ID\n"));

			int32 type;
			if ((message->FindInt32("Type", &type) != B_OK)
			 || (type != DragTrack_ID))
				return;

			// change of track order requested
			int32 index;
			message->FindInt32("Index", &index);
			// find the target index
			BPoint point = ConvertFromScreen(message->DropPoint());
			point.y -= ItemFrame(0).Height();
			int32 dragIndex;
			if (point.y < 0.0) 
				dragIndex = -1;
			else 
			{
				dragIndex = IndexOf(point);
				if (dragIndex < 0)	
					dragIndex = CountItems() - 1;
			}
			// reorder tracks
			if (dragIndex < index)
			{
				m_doc->ChangeTrackOrder(index, dragIndex + 1);
				m_doc->SetModified();
			}
			else if (dragIndex > index)
			{
				m_doc->ChangeTrackOrder(index, dragIndex);
				m_doc->SetModified();
			}

			break;
		}
		default:
		{
			BListView::MessageReceived(message);
			break;
		}
	}
}