void TPanelWindowView::RemoveShortcut( TPanelIcon *hicon )
{
	DebugCall( 5, "TPanelWindowVoew::RemoveShortcut( %p [parent: %p] )", hicon, hicon->fParent );

	if ( hicon )
	{
		TInnerPanel *parent = hicon->fParent->CountItems() > 1 ? 0 : hicon->fParent;
		TAppPanelIcon *icon = dynamic_cast<TAppPanelIcon*>(hicon);

		if ( fLastActiveAppIcon == hicon )
		{
			fLastActiveAppIcon->SetActive(false);
			fLastActiveAppIcon = 0;
		}

		hicon->fParent->RemoveItem( hicon, false );

		if ( icon && icon->Teams()->CountItems() > 0 )
			AddRunning( fRunningAppPanel, icon );
		else
			delete hicon;

		if ( parent )
			RemovePanel(parent);
	}
}
void LandscapeEditorControlsPlaceholder::UpdatePanels()
{
	RemovePanel();

	int32 tools = activeScene->GetEnabledTools();
	if (tools & SceneEditor2::LANDSCAPE_TOOL_CUSTOM_COLOR)
	{
		SetPanel(customColorsPanel);
	}
	else if (tools & SceneEditor2::LANDSCAPE_TOOL_HEIGHTMAP_EDITOR)
	{
		SetPanel(heightmapEditorPanel);
	}
	else if (tools & SceneEditor2::LANDSCAPE_TOOL_RULER)
	{
		SetPanel(rulerToolPanel);
	}
	else if (tools & SceneEditor2::LANDSCAPE_TOOL_TILEMAP_EDITOR)
	{
		SetPanel(tilemaskEditorPanel);
	}
	else if (tools & SceneEditor2::LANDSCAPE_TOOL_VISIBILITY)
	{
		SetPanel(visibilityToolPanel);
	}
}
Example #3
0
BOOL Hotlist::RemoveItem(OpTreeModel* model, INT32 model_pos)
{
	OpTreeModelItem* model_item = model->GetItemByPosition(model_pos);

	INT32 pos = FindItem(model_item->GetID());

	if (pos != -1)
	{
		RemovePanel(pos);

		return TRUE;
	}

	return FALSE;
}
void LandscapeEditorControlsPlaceholder::SetPanel(LandscapeEditorBasePanel* panel)
{
	if (!panel || panel == currentPanel)
	{
		return;
	}
	
	RemovePanel();
	
	currentPanel = panel;
	layout()->addWidget(panel);
	panel->show();

	panel->InitPanel(activeScene);
}
Example #5
0
BOOL Hotlist::ShowPanelByType(Type type, BOOL show, BOOL focus)
{
	INT32 index = 0;

	BOOL shown = GetPanelByType(type, &index) != NULL;

	if (shown == show)
		return FALSE;

	if (show)
	{
		if (!shown)
		{
			AddPanelByType(type, type - PANEL_TYPE_FIRST);
			m_selector->WriteContent();
		}

		if (focus)
		{
			if (GetPanelByType(type, &index) != NULL)
			{
				m_selector->SetSelected(index, TRUE);
			}
		}

		return !shown;
	}
	else if (shown)
	{
		RemovePanel(index);
		m_selector->WriteContent();
		return TRUE;
	}

	return FALSE;
}
void TPanelWindowView::MessageReceived( BMessage *message )
{
	if ( fDebugLevel >= 20 )
		message->PrintToStream();

	if ( message->what == B_GET_PROPERTY
		 || message->what == B_SET_PROPERTY
		 || message->what == B_COUNT_PROPERTIES
		 || message->what == B_CREATE_PROPERTY
		 || message->what == B_DELETE_PROPERTY
		 || message->what == B_EXECUTE_PROPERTY )
	{
		int32 index, what;
		BMessage specifier;
		const char *property;
		if ( message->GetCurrentSpecifier( &index, &specifier, &what, &property ) == B_OK )
		{
			BMessage reply( B_REPLY );
			if ( message->what == B_GET_PROPERTY
				 || message->what == B_COUNT_PROPERTIES
				 || message->what == B_EXECUTE_PROPERTY )
			{
				if ( GetOptions( property, &reply ) )
					reply.AddInt32( "error", 0 );
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_SET_PROPERTY )
			{
				if ( SetOptions( property, message ) )
					reply.AddInt32( "error", 0 );
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_CREATE_PROPERTY )
			{
				if ( !strcasecmp( property, "tab" ) )
				{
					int32 index;
					if ( message->FindInt32( "index", &index ) != B_OK )
						index = -1;
					TShortcutPanel *panel = new TShortcutPanel( this );

					fPanels.Lock();
					if ( index >= 0 )
					{
						TInnerPanel *rightpanel = fPanels.ItemAt(index);
						AddPanel( panel, rightpanel );
					}
					else
					{
						AddPanel( panel );
					}
					fPanels.Unlock();

					ChangedSize(0);

					reply.AddInt32( "error", 0 );
				}
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_DELETE_PROPERTY )
			{
				int32 index;
				if ( specifier.FindInt32( "index", &index ) != B_OK )
					reply.AddInt32( "error", -1 );
				else
				{
					fPanels.Lock();
					TInnerPanel *panel = fPanels.ItemAt(index);
					if ( !panel )
						reply.AddInt32( "error", -1 );
					else
					{
						if ( panel != fRunningAppPanel )
						{
							RemovePanel( panel );
							reply.AddInt32( "error", 0 );
						}
						else
							reply.AddInt32( "error", -1 );
					}
					fPanels.Unlock();
				}
			}
			message->SendReply( &reply );
		}
		return;
	}

	if ( message->WasDropped() )
	{
		BPoint point = message->DropPoint();
		ConvertFromScreen( &point );
		TInnerPanel *panel = PanelAt( point );
		if ( message->what == 'IDRG' )
		{
			TPanelIcon *item;
			if ( message->FindPointer( "source", (void**)&item ) == B_OK )
			{
				TRaisingIconPanel *previous_parent = item->fParent;
				TRaisingIconPanel *rpanel;
				if ( modifiers() & B_CONTROL_KEY )
				{
					rpanel = new TShortcutPanel(this);
					bool left = false;
					if ( point.x < (panel->Frame().left+(panel->Frame().Width()/2) ) )
					{
						left = true;
					}
						
					rpanel = new TShortcutPanel(this);
					AddPanel( rpanel, left ? panel : 0 );
				}
				else
					rpanel = dynamic_cast<TRaisingIconPanel*>(panel);
				if ( rpanel && rpanel != fRunningAppPanel )
				{
					TPanelIcon *icon = rpanel->IconAt( point, true );
					if ( previous_parent == fRunningAppPanel && dynamic_cast<TShortcutPanel*>(rpanel) )
					{
						int32 index = rpanel->IndexOf(icon);
						AddShortcut( dynamic_cast<TShortcutPanel*>(rpanel), dynamic_cast<TAppPanelIcon*>(item)->Ref(), index );
					}
					else if ( !dynamic_cast<TTrashIcon*>(icon) || (modifiers() & B_SHIFT_KEY) )
					{
						previous_parent->RemoveItem( item, false );
						int32 index = rpanel->IndexOf(icon);
						rpanel->AddItem( item, index );
					}
					else
					{
						if ( item->Removable() )
							RemoveShortcut(item);
					}
					if ( previous_parent->CountItems() == 0 && previous_parent != fRunningAppPanel )
						RemovePanel( previous_parent );
				}
			}
		}
		else
		{
			if ( panel && panel->HitsFrame( point ) )
			{
				panel->HandleDroppedMessage( message, point );
			}
			else
			{
				HandleDroppedMessage( message, point );
			}
		}

		return;
	}

	switch ( message->what )
	{
	case kPanelWindowViewTimer:
		{
			if ( DoIconSmallerWithTime() == 0 )
			{
				fTimer->SetInterval( 999999999 );
			}
			break;
		}
	case T_MENU_CLOSED:
		{
			DebugCall( 8, "Got T_MENU_CLOSED" );

			TAwarePopupMenu *source;
			if ( message->FindPointer( "source", (void**)&source ) == B_OK )
			{
				if ( source == fOpenMenu )
				{
					DebugCall( 9, "fOpenMenu is now 0" );

					fOpenMenu = 0;
					BPoint point;
					uint32 buttons;
					GetMouse( &point, &buttons );
					if ( !Bounds().Contains( point ) )
						Window()->PostMessage(B_EXITED_VIEW);
				}
			}
			break;
		}
	case B_SOME_APP_LAUNCHED:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) != B_OK )
				break;
			const char *sig;
			if ( message->FindString( "be:signature", &sig ) != B_OK )
				break;
			entry_ref ref;
			if ( message->FindRef( "be:ref", &ref ) != B_OK )
				break;
			int32 flags;
			if ( message->FindInt32( "be:flags", &flags ) != B_OK )
				break;

			if ( sig && strlen(sig) && ( ( flags & B_BACKGROUND_APP ) == 0 ) )
				AddTeam( tid, sig, ref );

			break;
		}
	case B_SOME_APP_QUIT:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) != B_OK )
				break;

			RemoveTeam( tid );

			break;
		}
	case B_SOME_APP_ACTIVATED:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) == B_OK )
			{
				TAppPanelIcon *icon = ItemWith( tid );

				if ( icon != fLastActiveAppIcon )
				{
					DebugCall( 10, "B_SOME_APP_ACTIVATED %p[..]->%p[%i]", fLastActiveAppIcon, icon, tid );

					if ( fLastActiveAppIcon )
						fLastActiveAppIcon->SetActive( false );
					if ( icon )
						icon->SetActive( true );
					fLastActiveAppIcon = icon;
				}
			}

			BString temp;
			message->FindString( "be:signature", &temp );

			if ( temp != "application/x-vnd.Be-TSKB" )
				fLastActivatedAppSig = temp;

			break;
		}
	case kDoBubbleHelp:
		{
			BPoint point;
			uint32 buttons;
			GetMouse(&point, &buttons);
			if ( fPreviousMousePosition != point )
			{
				if ( fBubbleCounter > 0 )
				{
					if ( fBubbleCounter >= 6 )
					{
						fBubbleHelp->HideBubble();
					}
					fBubbleCounter = 0;
				}
				fPreviousMousePosition = point;
			}
			else
			{
				BRegion region;
				GetClippingRegion(&region);
				if ( region.Contains( point ) )
				{
					fBubbleCounter ++;
					if ( fBubbleCounter == 6 )
					{
						ConvertToScreen(&point);
						TBubbleTarget *target = fBubbleHelp->TargetAt( point );
						if (dynamic_cast<TTrackerIcon*>(target)) {
							TTrackerIcon *trackerIcon = dynamic_cast<TTrackerIcon*>(target);
							point.x = Window()->Frame().left + trackerIcon->ContentLocation().x + trackerIcon->Frame().Width() + 4;
							point.y = Window()->Frame().top;
							float height = TBubbleHelp::BubbleHeight(target);
							point.y += height;
							point.y += (Window()->Frame().Height() - height)/2 -4;
						}
						fBubbleHelp->ShowBubble( point, target );
					}
//					else if ( fBubbleCounter == 12 )
//					{
//						fBubbleHelp->HideBubble();
//					}
				}
			}
			break;
		}
	case 'flsh':
		{
			BMessenger target;
			if ( message->FindMessenger("source", &target ) == B_OK && target.IsValid() )
			{
				TAppPanelIcon *teamicon = ItemWith( target.Team() );
				if ( teamicon )
				{
//					todo: flashing
					teamicon->Flash();
				}
			}
			break;
		}
	case 'mctx':
		{
//			todo: context menus
			break;
		}
	default:
		BView::MessageReceived(message);
	}
}
Example #7
0
void Hotlist::OnReadPanels(PrefsSection *section)
{
	OP_PROFILE_METHOD("Created panels");

	//remember which panels exist right now, so we know what to remove
	OpVector<HotlistPanel> removed_panels;

	for (INT32 i=0; i < GetPanelCount(); ++i)
	{
		HotlistPanel* old_panel = GetPanel(i);
		if (old_panel->GetType() != PANEL_TYPE_WEB)	//web panels are maintained by the bookmarks events
			removed_panels.Add(old_panel);
	}

	//read panel setup and apply to current setup
	if (section)
	{
		for (const PrefsEntry *entry = section->Entries(); entry; entry = (const PrefsEntry *) entry->Suc())
		{
			OpLineParser line(entry->Key());

			OpString item_type;
			INT32 pos = -1;

			if (OpStatus::IsError(line.GetNextToken(item_type)))
				continue;

			line.GetNextValue(pos);

			//get the new panel type;
			Type new_panel_type = GetPanelTypeByName(item_type.CStr());

			//move or create it if needed
			HotlistPanel* positioned_panel = PositionPanel(new_panel_type, pos);

			//this panel (if already existed) should not be removed
			OpStatus::Ignore(removed_panels.RemoveByItem(positioned_panel));
		}
	}

	//all panels in this list have not been reread, so they must have been removed
	while (removed_panels.GetCount() > 0)
	{
		INT32 pos;
		GetPanelByType(removed_panels.Get(0)->GetType(), &pos);
		OP_ASSERT(pos >= 0);	//panels in the removed_panels list should exist
		//delete panel and remove from the removal list
		RemovePanel(pos);
		removed_panels.Remove(0);
	}

	//update panels from bookmarks (webpanels)
	OnTreeChanged(g_hotlist_manager->GetBookmarksModel());

	INT32 active = ReadActiveTab();

	Collapse collapse = GetCollapse();
	if (collapse == COLLAPSE_SMALL)
		active = -1;

	m_selector->SetSelected(active, TRUE, TRUE);
}
Example #8
0
BOOL Hotlist::OnInputAction(OpInputAction* action)
{
	if (!m_selector)
		return FALSE;

	if (OpBar::OnInputAction(action))
		return TRUE;

	HotlistPanel* panel = m_selector->GetFocused() != -1 ? GetPanel(m_selector->GetFocused()) : NULL;
	WebPanel* web_panel = panel && panel->GetType() == PANEL_TYPE_WEB ? (WebPanel*) panel : NULL;

	switch (action->GetAction())
	{
		case OpInputAction::ACTION_GET_ACTION_STATE:
		{
			OpInputAction* child_action = action->GetChildAction();

			switch (child_action->GetAction())
			{
				case OpInputAction::ACTION_FOCUS_PANEL:
				{
					child_action->SetEnabled(TRUE);
					child_action->SetSelected(!child_action->HasActionDataString() && m_selector->GetSelected() == child_action->GetActionData());
					return TRUE;
				}

				case OpInputAction::ACTION_EDIT_PANEL:
				{
					child_action->SetEnabled(web_panel != NULL);
					return TRUE;
				}
				case OpInputAction::ACTION_SHOW_POPUP_MENU:
				{
					if (child_action->HasActionDataString() && uni_stricmp(child_action->GetActionDataString(), UNI_L("Internal Panels")) == 0)
					{
						OpString text;
						GetPanelText(m_selector->GetSelected(), text, PANEL_TEXT_NAME);

						child_action->SetActionText(text.CStr());
						return TRUE;
					}
					return FALSE;
				}
				case OpInputAction::ACTION_ADD_WEB_PANEL:
				{
					// DSK-351304: adding a web panel creates new bookmark - disable until bookmarks are loaded
					child_action->SetEnabled(g_desktop_bookmark_manager->GetBookmarkModel()->Loaded());
					return TRUE;
				}
			}
			break;
		}

		case OpInputAction::ACTION_GET_TYPED_OBJECT:
		{
			if (action->GetActionData() == WIDGET_TYPE_HOTLIST)
			{
				action->SetActionObject(this);
				return TRUE;
			}
			return FALSE;
		}

		case OpInputAction::ACTION_HIDE_PANEL:
		{
			if (action->GetActionData() == -1 && IsCollapsableToSmall())
			{
				return m_selector->SetSelected(-1, TRUE);
			}

			BOOL has_focus = IsFocused(TRUE);
			BOOL result = ShowPanelByName(action->GetActionDataString(), FALSE);

			if( has_focus )
			{
				DesktopWindow *window = g_application->GetActiveDesktopWindow();
				if( window )
				{
					//Does not work. Would like to use it but does not work yet [espen 2004-04-01]
					//window->RestoreFocus(FOCUS_REASON_OTHER);
					g_input_manager->InvokeAction(OpInputAction::ACTION_FOCUS_PAGE);
				}
			}

			return result;
		}

		case OpInputAction::ACTION_SHOW_PANEL:
		case OpInputAction::ACTION_FOCUS_PANEL:
		{
			INT32 index = action->GetActionData();

			HotlistPanel* panel = NULL;
			BOOL handled = FALSE;

			if (action->HasActionDataString()) // show a specific panel (another panel might already be open)
			{
				handled = ShowPanelByName(action->GetActionDataString(), TRUE);

				if (!handled && action->GetAction() == OpInputAction::ACTION_SHOW_PANEL)
					return FALSE;

				panel = GetPanelByType(GetPanelTypeByName(action->GetActionDataString()), &index);
			}
			else if (action->GetAction() == OpInputAction::ACTION_FOCUS_PANEL ||	// focus a specific panel
					 GetAlignment() == ALIGNMENT_OFF || GetSelectedPanel() == -1)	// show the currently active panel (no panel is currently open)
			{
				if (index == -1)
					index = ReadActiveTab();

				panel = GetPanel(index);
			}
			else // don't show anything (advance to next input action, which is normally: hide panel)
			{
				action->SetWasReallyHandled(FALSE);
				return TRUE;
			}

			if (!panel)
				return FALSE;

			// make sure we are visible

			if (SetAlignment(OpBar::ALIGNMENT_OLD_VISIBLE))
				handled = TRUE;

			SyncLayout();

			if (m_selector->SetSelected(index, TRUE, TRUE))
				handled = TRUE;

			if (GetParentDesktopWindow()->Activate())
				handled = TRUE;

			panel->RestoreFocus(FOCUS_REASON_ACTION);

			return handled;
		}

		case OpInputAction::ACTION_REMOVE_PANEL:
		{
			if (web_panel)
			{
				g_hotlist_manager->ShowInPanel( web_panel->GetID(), FALSE );
			}
			else if (panel)
			{
				RemovePanel(m_selector->GetFocused());
				m_selector->WriteContent();
			}
			return TRUE;
		}

		case OpInputAction::ACTION_EDIT_PANEL:
		{
			if (web_panel)
			{
				g_hotlist_manager->EditItem( web_panel->GetID(), GetParentDesktopWindow() );
			}
			return TRUE;
		}

		case OpInputAction::ACTION_SHOW_CONTEXT_MENU:
		{
			ShowContextMenu(m_selector->GetBounds().Center(),TRUE,TRUE);
			return TRUE;
		}

		case OpInputAction::ACTION_ADD_WEB_PANEL:
		{
			AddWebPanelController* controller = OP_NEW(AddWebPanelController, ());
			OpStatus::Ignore(ShowDialog(controller, g_global_ui_context, g_application->GetActiveDocumentDesktopWindow()));
			return TRUE;
		}

		case OpInputAction::ACTION_MANAGE:
		{
			if (action->HasActionDataString() || !panel)
				return FALSE;

			if (web_panel)
			{
				OpenURLSetting settings;
				web_panel->GetURL(settings.m_address);
				settings.m_ignore_modifier_keys = (action->IsKeyboardInvoked());

				g_application->OpenURL(settings);
			}
			else
			{
				g_application->GetPanelDesktopWindow(panel->GetType() , TRUE);
			}
			return TRUE;
		}
	}

	return FALSE;
}
void LandscapeEditorControlsPlaceholder::SceneDeactivated(SceneEditor2* scene)
{
	RemovePanel();

	activeScene = NULL;
}