Example #1
0
void HUD::update(int width, int height) {
	std::set<Resolution> availableRes;

	for (size_t i = 0; i < ARRAYSIZE(kResolution); i++)
		if (ResMan.hasResource(kResolution[i].gui, Aurora::kFileTypeGUI))
			availableRes.insert(kResolution[i]);

	const int wWidth  = width;
	const int wHeight = height;

	const Resolution *foundRes = 0;
	for (std::set<Resolution>::const_iterator it = availableRes.begin(); it != availableRes.end(); ++it)
		if (it->width == wWidth && it->height == wHeight)
			foundRes = &*it;

	bool scale = false;
	if (!foundRes) {
		for (std::set<Resolution>::const_iterator it = availableRes.begin(); it != availableRes.end(); ++it) {
			if ((it->width == 800) && (it->height == 600)) {
				foundRes = &*it;
				break;
			}
		}
		if (!foundRes)
			throw Common::Exception("No gui with 800x600 resolution found.");
		scale = true;
	}

	load(foundRes->gui);

	// Make all the widgets invisible and scale them if needed.
	for (size_t i = 0; i < ARRAYSIZE(kKnownWidgets); i++) {
		Widget *widget = getWidget(kKnownWidgets[i].name);
		if (!widget)
			continue;

		widget->setInvisible(!kKnownWidgets[i].visible);

		float x, y, z;
		if (scale) {
			switch (kKnownWidgets[i].position) {
				case kPositionUpperLeft:
					widget->getPosition(x, y, z);
					widget->setPosition(-wWidth/2 + (400 + x), wHeight/2 - (300 - y), z);
					break;
				case kPositionUpperRight:
					widget->getPosition(x, y, z);
					widget->setPosition(wWidth/2 - (400 - x), wHeight/2 - (300 - y), z);
					break;
				case kPositionUpperMid:
					widget->getPosition(x, y, z);
					widget->setPosition(x, wHeight/2 - (300 - y), z);
					break;
				case kPositionLowerLeft:
					widget->getPosition(x, y, z);
					widget->setPosition(-wWidth/2 + (400 + x), -wHeight/2 + (300 + y), z);
					break;
				case kPositionLowerRight:
					widget->getPosition(x, y, z);
					widget->setPosition(wWidth/2 - (400 - x), -wHeight/2 + (300 + y), z);
					break;
				case kPositionLowerMid:
					widget->getPosition(x, y, z);
					widget->setPosition(x, -wHeight/2 + (300 + y), z);
					break;
				default:
					break;
			}
		}
	}
}
Example #2
0
void GlassWindow::workingWindow(bool w) {
	Widget *working = titleBarContainer.findWidgetById("working");
	working->setVisible(w);
}
void engine_display::on_pushButton_released()
{
    Widget *mainwindow = new Widget();
    mainwindow->show();
    this->close();
}
Example #4
0
File: uigui.cpp Project: tc-/GameUI
void Gui::mouseMove( int x, int y, MouseButtons mb )
{
//  cout << "Ui::Gui::mouseMove(  )"  << endl;

	if ( pChannelPopup != NULL ) {
		pChannelPopup->mouseMove( x, y, mb );
		if ( pChannelPopup != NULL ) {
			if ( !pChannelPopup->passEvents() )
				return;
		}
	}

  if ( pMouseChannelWidget != NULL ) {

		Widget* o =  pMouseChannelWidget->mouseMove( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );

    if ( pLastMouseOver != o ) {

      if ( (pLastMouseOver == pMouseChannelWidget) || (o == pMouseChannelWidget) ) {
        if ( o == pMouseChannelWidget ) {
          pMouseChannelWidget->mouseIn( mb );
        } else {
          pMouseChannelWidget->mouseOut( mb );
          pMouseChannelWidget->onDestroy.disconnect( this );
        }
      } else {
        pLastMouseOver->onDestroy.disconnect( this );
      }
      pLastMouseOver = o;
      pLastMouseOver->onDestroy.connect( this, &Gui::objectDestroyed );

    }

  } else {

    for( int i = 0; i < pPopups.count(); i++ ) {
      Popup* p = pPopups.get( i );
      Rect r = p->getRect();
      if ( r.pointInside( x, y ) ) {
        p->mouseMove( x, y, mb );
				if ( !p->passEvents() )
					return;
      }
    }

    Widget* o = fgFrame().mouseMove( x, y, mb );

    if ( o != NULL ) {
      if ( o != pLastMouseOver ) {

        if ( pLastMouseOver != NULL ) {
          pLastMouseOver->onDestroy.disconnect( this );
          pLastMouseOver->mouseOut( mb );
          pLastMouseOver = NULL;
        }

//        if ( o != &frame )
        o->mouseIn( mb );

        pLastMouseOver = o;
        pLastMouseOver->onDestroy.connect( this, &Gui::objectDestroyed );

      }
      //o->mouseMove( x, y, mb );

    } else {
      pLastMouseOver->onDestroy.disconnect( this );
      pLastMouseOver = NULL;
    }

  }
	if ( pMouseDragWidget != NULL ) {
		if ( ( Utils::max(x, pPressedX) - Utils::min(x, pPressedX) > 5 ) || ( Utils::max(y, pPressedY) - Utils::min(y, pPressedY) > 5 ) ) {
			DragObject* d = NULL;
			pMouseDragWidget->onDrag( pMouseDragWidget, x - pMouseDragWidget->absoluteXPos(), y - pMouseDragWidget->absoluteYPos(), &d );
			if ( d != NULL ) {
				pMouseDragWidget->mouseReleased( x - pMouseDragWidget->absoluteXPos(), y - pMouseDragWidget->absoluteYPos(), mb );
				d->popup( x - (d->width() / 2), y - (d->height() / 2), *this );
				if ( mouseChannelWidget() != NULL )
					unsetMouseChannelWidget( *mouseChannelWidget() );

				d->mousePressed( x, y, mb );
			}
			pMouseDragWidget->onDestroy.disconnect( this );
			pMouseDragWidget = NULL;
		}
	}
}
Example #5
0
/**
*  @brief
*    Send and process a message directly
*/
void Gui::SendMessage(const GuiMessage &cMessage)
{
	// Pass message to message filters
	for (uint32 i=0; i<m_lstMessageFilters.GetNumOfElements(); i++) {
		// Pass message to filter
		m_lstMessageFilters[i]->AddMessage(cMessage);
	}

	// Get widget
	Widget *pWidget = cMessage.GetWidget();

	// Process message
	switch (cMessage.GetType()) {
		// Exit application
		case MessageOnExit:
			// Set flag to leave application
			m_bActive = false;

			// Skip passing message to widget
			return;

		// Timer fired
		case MessageOnTimer:
		{
			// Get timer
			Timer *pTimer = cMessage.GetTimer();

			// Discard message, if the timer has already been destroyed
			if (pTimer && m_lstTimers.IsElement(pTimer)) {
				// Fire timer
				pTimer->Fire();
			}

			// Skip passing message to widget
			return;
		}

		// Widget has been destroyed
		case MessageOnDestroy:
			// Remove from parent widget
			if (pWidget->GetParent()) {
				pWidget->GetParent()->RemoveChild(pWidget);
			}

			// Remove from list of top-level widgets
			if (m_lstTopLevelWidgets.IsElement(pWidget)) {
				m_lstTopLevelWidgets.Remove(pWidget);
			}

			// Add widget to list of destroyed widgets
			m_lstDestroyedWidgets.Add(pWidget);

			// Pass message on to widget
			break;

		// Mouse has entered a widget
		case MessageOnMouseEnter:
			// Set new mouse-over widget
			if (m_pMouseOverWidget != pWidget) {
				// Update mouse-over widget
				m_pMouseOverWidgetNew = pWidget;
				UpdateMouseOverWidget();
			}
			break;

		// Mouse has left a widget
		case MessageOnMouseLeave:
			// Reset mouse-over widget
			if (m_pMouseOverWidget == pWidget) {
				// Update mouse-over widget
				m_pMouseOverWidgetNew = nullptr;
				UpdateMouseOverWidget();
			}
			break;

		// Widget has got the focus
		case MessageOnGetFocus:
			// Set focus widget
			if (m_pFocusWidget != pWidget) {
				// Update focus widget
				m_pFocusWidgetNew = pWidget;
				UpdateFocusWidget();
			}
			break;

		// Widget has lost the focus
		case MessageOnLooseFocus:
			// Set focus widget
			if (m_pFocusWidget == pWidget) {
				// Update focus widget
				m_pFocusWidgetNew = nullptr;
				UpdateFocusWidget();
			}
			break;

		case MessageOnUnknown:
		case MessageOnInternalMessage:
		case MessageOnWakeup:
		case MessageOnThemeChanged:
		case MessageOnUpdateContent:
		case MessageOnUpdateChildWidget:
		case MessageOnAddChildWidget:
		case MessageOnRemoveChildWidget:
		case MessageOnClose:
		case MessageOnCreate:
		case MessageOnShow:
		case MessageOnHide:
		case MessageOnEnable:
		case MessageOnDisable:
		case MessageOnActivate:
		case MessageOnDrawBackground:
		case MessageOnDraw:
		case MessageOnMove:
		case MessageOnSize:
		case MessageOnWindowState:
		case MessageOnEnterFullscreen:
		case MessageOnLeaveFullscreen:
		case MessageOnPreferredSize:
		case MessageOnAdjustContent:
		case MessageOnMouseOver:
		case MessageOnMouseMove:
		case MessageOnMouseHover:
		case MessageOnMousePosUpdate:
		case MessageOnMouseButtonDown:
		case MessageOnMouseButtonUp:
		case MessageOnMouseButtonClick:
		case MessageOnMouseButtonDoubleClick:
		case MessageOnMouseWheel:
		case MessageOnKeyDown:
		case MessageOnKeyUp:
		case MessageOnHotkey:
		case MessageOnDrop:
		case MessageOnUserMessage:
		default:
			// Nothing to do in here
			break;
	}

	// Pass message to widget
	if (pWidget) {
		pWidget->OnMessage(cMessage);
	}
}
Example #6
0
void Window::attach(Widget& w)
{
    begin();         // FTLK: begin attaching new Fl_Wigets to this window
    w.attach(*this); // let the Widget create its Fl_Wigits
    end();           // FTLK: stop attaching new Fl_Wigets to this window
}
Example #7
0
void
EditorItem::paintCell(QPainter *p, const QColorGroup & cg, int column, int width, int align)
{
	//int margin = static_cast<Editor*>(listView())->itemMargin();
	if(!d->property)
		return;

	if(column == 0)
	{
		QFont font = listView()->font();
		if(d->property->isModified())
			font.setBold(true);
		p->setFont(font);
		p->setBrush(cg.highlight());
		p->setPen(cg.highlightedText());
		KListViewItem::paintCell(p, cg, column, width, align);
		p->fillRect(parent() ? 0 : 50, 0, width, height()-1,
			QBrush(isSelected() ? cg.highlight() : backgroundColor()));
		p->setPen(isSelected() ? cg.highlightedText() : cg.text());
		int delta = -20+KPROPEDITOR_ITEM_MARGIN;
		if ((firstChild() && dynamic_cast<EditorGroupItem*>(parent()))) {
			delta = -KPROPEDITOR_ITEM_MARGIN-1;
		}
		if (dynamic_cast<EditorDummyItem*>(parent())) {
			delta = KPROPEDITOR_ITEM_MARGIN*2;
		}
		else if (parent() && dynamic_cast<EditorDummyItem*>(parent()->parent())) {
			if (dynamic_cast<EditorGroupItem*>(parent()))
				delta += KPROPEDITOR_ITEM_MARGIN*2;
			else
				delta += KPROPEDITOR_ITEM_MARGIN*5;
		}
		p->drawText(
			QRect(delta,2, width+listView()->columnWidth(1)-KPROPEDITOR_ITEM_MARGIN*2, height()),
			Qt::AlignLeft | Qt::AlignTop /*| Qt::SingleLine*/, text(0));

		p->setPen( KPROPEDITOR_ITEM_BORDER_COLOR );
		p->drawLine(width-1, 0, width-1, height()-1);
		p->drawLine(0, -1, width-1, -1);

		p->setPen( KPROPEDITOR_ITEM_BORDER_COLOR ); //! \todo custom color?
		if (dynamic_cast<EditorDummyItem*>(parent()))
			p->drawLine(0, 0, 0, height()-1 );
	}
	else if(column == 1)
	{
		QColorGroup icg(cg);
		icg.setColor(QColorGroup::Background, backgroundColor());
		p->setBackgroundColor(backgroundColor());
		Widget *widget = d->editor->createWidgetForProperty(d->property, false /*don't change Widget::property() */);
		if(widget) {
			QRect r(0, 0, d->editor->header()->sectionSize(1), height() - (widget->hasBorders() ? 0 : 1));
			p->setClipRect(r, QPainter::CoordPainter);
			p->setClipping(true);
			widget->drawViewer(p, icg, r, d->property->value());
			p->setClipping(false);
		}
	}
	p->setPen( KPROPEDITOR_ITEM_BORDER_COLOR ); //! \todo custom color?
	p->drawLine(0, height()-1, width, height()-1 );
}
Example #8
0
void GuiManager::runLoop() {
	Dialog * const activeDialog = getTopDialog();
	bool didSaveState = false;

	if (activeDialog == 0)
		return;

#ifdef ENABLE_EVENTRECORDER
	// Suspend recording while GUI is shown
	g_eventRec.suspendRecording();
#endif

	if (!_stateIsSaved) {
		saveState();
		_theme->enable();
		didSaveState = true;

		_useStdCursor = !_theme->ownCursor();
		if (_useStdCursor)
			setupCursor();

//		_theme->refresh();

		_redrawStatus = kRedrawFull;
		redraw();
	}

	_lastMousePosition.x = _lastMousePosition.y = -1;
	_lastMousePosition.time = 0;

	Common::EventManager *eventMan = _system->getEventManager();
	uint32 lastRedraw = 0;
	const uint32 waitTime = 1000 / 45;

	bool tooltipCheck = false;

	while (!_dialogStack.empty() && activeDialog == getTopDialog() && !eventMan->shouldQuit()) {
		redraw();

		// Don't "tickle" the dialog until the theme has had a chance
		// to re-allocate buffers in case of a scaler change.

		activeDialog->handleTickle();

		if (_useStdCursor)
			animateCursor();
//		_theme->updateScreen();
//		_system->updateScreen();

		if (lastRedraw + waitTime < _system->getMillis(true)) {
			_theme->updateScreen();
			_system->updateScreen();
			lastRedraw = _system->getMillis(true);
		}

		Common::Event event;

		while (eventMan->pollEvent(event)) {
			// We will need to check whether the screen changed while polling
			// for an event here. While we do send EVENT_SCREEN_CHANGED
			// whenever this happens we still cannot be sure that we get such
			// an event immediately. For example, we might have an mouse move
			// event queued before an screen changed event. In some rare cases
			// this would make the GUI redraw (with the code a few lines
			// below) when it is not yet updated for new overlay dimensions.
			// As a result ScummVM would crash because it tries to copy data
			// outside the actual overlay screen.
			if (event.type != Common::EVENT_SCREEN_CHANGED) {
				checkScreenChange();
			}

			// The top dialog can change during the event loop. In that case, flush all the
			// dialog-related events since they were probably generated while the old dialog
			// was still visible, and therefore not intended for the new one.
			//
			// This hopefully fixes strange behavior/crashes with pop-up widgets. (Most easily
			// triggered in 3x mode or when running ScummVM under Valgrind.)
			if (activeDialog != getTopDialog() && event.type != Common::EVENT_SCREEN_CHANGED)
				continue;

			processEvent(event, activeDialog);

			if (event.type == Common::EVENT_MOUSEMOVE) {
				tooltipCheck = true;
			}


			if (lastRedraw + waitTime < _system->getMillis(true)) {
				_theme->updateScreen();
				_system->updateScreen();
				lastRedraw = _system->getMillis(true);
			}
		}

		if (tooltipCheck && _lastMousePosition.time + kTooltipDelay < _system->getMillis(true)) {
			Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y);
			if (wdg && wdg->hasTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) {
				Tooltip *tooltip = new Tooltip();
				tooltip->setup(activeDialog, wdg, _lastMousePosition.x, _lastMousePosition.y);
				tooltip->runModal();
				delete tooltip;
			}
		}

		// Delay for a moment
		_system->delayMillis(10);
	}

	// WORKAROUND: When quitting we might not properly close the dialogs on
	// the dialog stack, thus we do this here to avoid any problems.
	// This is most noticable in bug #3481395 "LAUNCHER: Can't quit from unsupported game dialog".
	// It seems that Dialog::runModal never removes the dialog from the dialog
	// stack, thus if the dialog does not call Dialog::close to close itself
	// it will never be removed. Since we can have multiple run loops being
	// called we cannot rely on catching EVENT_QUIT in the event loop above,
	// since it would only catch it for the top run loop.
	if (eventMan->shouldQuit() && activeDialog == getTopDialog())
		getTopDialog()->close();

	if (didSaveState) {
		_theme->disable();
		restoreState();
		_useStdCursor = false;
	}

#ifdef ENABLE_EVENTRECORDER
	// Resume recording once GUI is shown
	g_eventRec.resumeRecording();
#endif
}
void OptionsCommand::onExecute(Context* context)
{
  // Load the window widget
  base::UniquePtr<Window> window(app::load_widget<Window>("options.xml", "options"));
  Widget* check_smooth = app::find_widget<Widget>(window, "smooth");
  Widget* check_autotimeline = app::find_widget<Widget>(window, "autotimeline");
  Widget* move_click2 = app::find_widget<Widget>(window, "move_click2");
  Widget* draw_click2 = app::find_widget<Widget>(window, "draw_click2");
  Widget* cursor_color_box = app::find_widget<Widget>(window, "cursor_color_box");
  Widget* grid_color_box = app::find_widget<Widget>(window, "grid_color_box");
  Widget* pixel_grid_color_box = app::find_widget<Widget>(window, "pixel_grid_color_box");
  m_checked_bg = app::find_widget<ComboBox>(window, "checked_bg_size");
  m_checked_bg_zoom = app::find_widget<Widget>(window, "checked_bg_zoom");
  Widget* checked_bg_color1_box = app::find_widget<Widget>(window, "checked_bg_color1_box");
  Widget* checked_bg_color2_box = app::find_widget<Widget>(window, "checked_bg_color2_box");
  Button* checked_bg_reset = app::find_widget<Button>(window, "checked_bg_reset");
  Widget* undo_size_limit = app::find_widget<Widget>(window, "undo_size_limit");
  Widget* undo_goto_modified = app::find_widget<Widget>(window, "undo_goto_modified");
  Widget* button_ok = app::find_widget<Widget>(window, "button_ok");

  // Cursor color
  ColorButton* cursor_color = new ColorButton(Editor::get_cursor_color(), IMAGE_RGB);
  cursor_color->setId("cursor_color");
  cursor_color_box->addChild(cursor_color);

  // Get global settings for documents
  IDocumentSettings* docSettings = context->getSettings()->getDocumentSettings(NULL);

  // Grid color
  ColorButton* grid_color = new ColorButton(docSettings->getGridColor(), IMAGE_RGB);
  grid_color->setId("grid_color");
  grid_color_box->addChild(grid_color);

  // Pixel grid color
  ColorButton* pixel_grid_color = new ColorButton(docSettings->getPixelGridColor(), IMAGE_RGB);
  pixel_grid_color->setId("pixel_grid_color");
  pixel_grid_color_box->addChild(pixel_grid_color);

  // Others
  if (get_config_bool("Options", "MoveClick2", false))
    move_click2->setSelected(true);

  if (get_config_bool("Options", "DrawClick2", false))
    draw_click2->setSelected(true);

  if (get_config_bool("Options", "MoveSmooth", true))
    check_smooth->setSelected(true);

  if (get_config_bool("Options", "AutoShowTimeline", true))
    check_autotimeline->setSelected(true);

  // Checked background size
  m_checked_bg->addItem("16x16");
  m_checked_bg->addItem("8x8");
  m_checked_bg->addItem("4x4");
  m_checked_bg->addItem("2x2");
  m_checked_bg->setSelectedItemIndex((int)RenderEngine::getCheckedBgType());

  // Zoom checked background
  if (RenderEngine::getCheckedBgZoom())
    m_checked_bg_zoom->setSelected(true);

  // Checked background colors
  m_checked_bg_color1 = new ColorButton(RenderEngine::getCheckedBgColor1(), IMAGE_RGB);
  m_checked_bg_color2 = new ColorButton(RenderEngine::getCheckedBgColor2(), IMAGE_RGB);

  checked_bg_color1_box->addChild(m_checked_bg_color1);
  checked_bg_color2_box->addChild(m_checked_bg_color2);

  // Reset button
  checked_bg_reset->Click.connect(Bind<void>(&OptionsCommand::onResetCheckedBg, this));

  // Undo limit
  undo_size_limit->setTextf("%d", get_config_int("Options", "UndoSizeLimit", 8));

  // Goto modified frame/layer on undo/redo
  if (get_config_bool("Options", "UndoGotoModified", true))
    undo_goto_modified->setSelected(true);

  // Show the window and wait the user to close it
  window->openWindowInForeground();

  if (window->getKiller() == button_ok) {
    int undo_size_limit_value;

    Editor::set_cursor_color(cursor_color->getColor());
    docSettings->setGridColor(grid_color->getColor());
    docSettings->setPixelGridColor(pixel_grid_color->getColor());

    set_config_bool("Options", "MoveSmooth", check_smooth->isSelected());
    set_config_bool("Options", "AutoShowTimeline", check_autotimeline->isSelected());
    set_config_bool("Options", "MoveClick2", move_click2->isSelected());
    set_config_bool("Options", "DrawClick2", draw_click2->isSelected());

    RenderEngine::setCheckedBgType((RenderEngine::CheckedBgType)m_checked_bg->getSelectedItemIndex());
    RenderEngine::setCheckedBgZoom(m_checked_bg_zoom->isSelected());
    RenderEngine::setCheckedBgColor1(m_checked_bg_color1->getColor());
    RenderEngine::setCheckedBgColor2(m_checked_bg_color2->getColor());

    undo_size_limit_value = undo_size_limit->getTextInt();
    undo_size_limit_value = MID(1, undo_size_limit_value, 9999);
    set_config_int("Options", "UndoSizeLimit", undo_size_limit_value);
    set_config_bool("Options", "UndoGotoModified", undo_goto_modified->isSelected());

    // Save configuration
    flush_config_file();
  }
}
Example #10
0
void FileSystemActor::onLaunch()
{
	assert(!filePath.isNull());

	if (!_onLaunchHandler.empty())
		_onLaunchHandler(this);

	// override for widgets
	Widget * w = widgetManager->getActiveWidgetForFile(getFullPath());
	if (w && w->isWidgetOverrideActor(this))
	{
		w->launchWidgetOverride(this);
		return;
	}
	
	// Do a quick pass to determine what needs to be created or not
	bool isWatchingHighlighted = cam->isWatchedActorHighlighted(this);
	bool zoomIntoImage = isFileSystemType(Image) && !isWatchingHighlighted && texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool launchImage = (isFileSystemType(Image) && isWatchingHighlighted) && !texMgr->isTextureState(thumbnailID, TextureLoaded);
	bool createTemporaryActor = !zoomIntoImage && !launchImage;
	bool createRandomAnimPath = createTemporaryActor;

	Actor * obj = NULL;
	if (createTemporaryActor)
	{
		obj = new Actor();
		Vec3 startPosition;

		// Set up the state of the Actor
		obj->pushActorType(Temporary);
		obj->setDims(getDims());
		obj->setGravity(false);
		obj->setCollisions(false);
		obj->setAlphaAnim(getAlpha(), 0.2f, 40);
		obj->setGlobalPose(getGlobalPose());
		obj->setObjectToMimic(this);
	}

	// Special case for launching a pileized actor
	Vec3 startPosition;
	if (isPileized())
	{
		startPosition = pileizedPile->getGlobalPosition();
	}else{
		startPosition = getGlobalPosition();
	}

	// create random animation path from the icon up to the camera eye
	if (createRandomAnimPath)
	{
		// Set an animation that moves the icon into the camera
 		CreateRandomAnimPath(obj, startPosition, cam->getEye(), 40);

		// Delete the object after the random animation is over.
		animManager->removeAnimation(obj);
		animManager->addAnimation(AnimationEntry(obj, (FinishedCallBack) DeleteActorAfterAnim));
	}

	// handle the launch override if there is one
	if (!getLaunchOverride().isEmpty())
	{
		fsManager->launchFileAsync(getLaunchOverride());
		return;
	}

	// Execute this Icon
	if (!isFileSystemType(Virtual))
	{
		// If this is a folder, then try and browse to it
		if (scnManager->isShellExtension && isFileSystemType(Folder))
		{			
			// try and send a custom message to the proxy window to move to the child
			incrementNumTimesLaunched();
			animManager->finishAnimation(this);
			SaveSceneToFile();
			winOS->ShellExtBrowseToChild(filePath);
			return;
		}
		// This is an image, so zoom to it if we are not already watching it
		else if (zoomIntoImage && isFileSystemType(Image) && texMgr->isTextureState(thumbnailID, TextureLoaded))
		{
			Key_EnableSlideShow();
			this->putToSleep();

			// record this zoom interaction
			statsManager->getStats().bt.interaction.actors.highlightedImage++;
			return;
		}

		// Execute it as normal
		// QString lnkTarget, lnkArgs, lnkWorkingDir;
		bool fileLaunched = false;
		/*
		if (isFileSystemType(Link))
		{
			fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &lnkArgs, &lnkWorkingDir);
			fileLaunched = fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir);
		}
		else
		*/
		fileLaunched = fsManager->launchFileAsync(filePath);

		if (fileLaunched)
		{
			// otherwise, just increment this file launch count and execute it
			// it is decided that images do not auto-grow (was a design decision)
			if (!launchImage)
			{
				incrementNumTimesLaunched();
			}

			// record this launch
			statsManager->getStats().bt.interaction.actors.launchedFile++;
		}
	}
	else
	{
		incrementNumTimesLaunched();
		fsManager->launchFile(filePath);
	}
}
Example #11
0
void RaceSetupScreen::init()
{
    Screen::init();
    input_manager->setMasterPlayerOnly(true);
    RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
    assert( w != NULL );

    race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
    if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
        PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
    {
        w->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
    }
    else
    {
        w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
    }

    DynamicRibbonWidget* w2 = getWidget<DynamicRibbonWidget>("gamemode");
    assert( w2 != NULL );
    w2->clearItems();

    // ---- Add game modes
    irr::core::stringw name1 = irr::core::stringw(
        RaceManager::getNameOf(RaceManager::MINOR_MODE_NORMAL_RACE)) + L"\n";
    //FIXME: avoid duplicating descriptions from the help menu!
    name1 +=  _("All blows allowed, so catch weapons and make clever use of them!");

    w2->addItem( name1, IDENT_STD, RaceManager::getIconOf(RaceManager::MINOR_MODE_NORMAL_RACE));

    irr::core::stringw name2 = irr::core::stringw(
        RaceManager::getNameOf(RaceManager::MINOR_MODE_TIME_TRIAL)) + L"\n";
    //FIXME: avoid duplicating descriptions from the help menu!
    name2 += _("Contains no powerups, so only your driving skills matter!");
    w2->addItem( name2, IDENT_TTRIAL, RaceManager::getIconOf(RaceManager::MINOR_MODE_TIME_TRIAL));

    if (PlayerManager::getCurrentPlayer()->isLocked(IDENT_FTL))
    {
        w2->addItem( _("Locked : solve active challenges to gain access to more!"),
            "locked", RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), true);
    }
    else
    {
        irr::core::stringw name3 = irr::core::stringw(
            RaceManager::getNameOf(RaceManager::MINOR_MODE_FOLLOW_LEADER)) + L"\n";
        //I18N: short definition for follow-the-leader game mode
        name3 += _("Keep up with the leader kart but don't overtake it!");
        w2->addItem(name3, IDENT_FTL, RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), false);
    }

    irr::core::stringw name4 = irr::core::stringw(_("Battle")) + L"\n";
    //FIXME: avoid duplicating descriptions from the help menu!
    name4 += _("Hit others with weapons until they lose all their lives.");
    w2->addItem( name4, IDENT_STRIKES, RaceManager::getIconOf(RaceManager::MINOR_MODE_FREE_FOR_ALL));

    irr::core::stringw name5 = irr::core::stringw(
        RaceManager::getNameOf(RaceManager::MINOR_MODE_SOCCER)) + L"\n";
    name5 += _("Push the ball into the opposite cage to score goals.");
    w2->addItem( name5, IDENT_SOCCER, RaceManager::getIconOf(RaceManager::MINOR_MODE_SOCCER));

#define ENABLE_EASTER_EGG_MODE
#ifdef ENABLE_EASTER_EGG_MODE
    if(race_manager->getNumLocalPlayers() == 1)
    {
        irr::core::stringw name1 = irr::core::stringw(
            RaceManager::getNameOf(RaceManager::MINOR_MODE_EASTER_EGG)) + L"\n";
        //FIXME: avoid duplicating descriptions from the help menu!
        name1 +=  _("Explore tracks to find all hidden eggs");

        w2->addItem( name1, IDENT_EASTER,
            RaceManager::getIconOf(RaceManager::MINOR_MODE_EASTER_EGG));
    }
#endif

    irr::core::stringw name6 = irr::core::stringw( _("Ghost replay race")) + L"\n";
    name6 += _("Race against ghost karts and try to beat them!");
    w2->addItem( name6, IDENT_GHOST, "/gui/icons/mode_ghost.png");

    w2->updateItemDisplay();

    // restore saved game mode
    switch (UserConfigParams::m_game_mode)
    {
    case CONFIG_CODE_NORMAL :
        w2->setSelection(IDENT_STD, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_TIMETRIAL :
        w2->setSelection(IDENT_TTRIAL, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_FTL :
        w2->setSelection(IDENT_FTL, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_3STRIKES :
        w2->setSelection(IDENT_STRIKES, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_EASTER :
        w2->setSelection(IDENT_EASTER, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_SOCCER :
        w2->setSelection(IDENT_SOCCER, PLAYER_ID_GAME_MASTER, true);
        break;
    case CONFIG_CODE_GHOST :
        w2->setSelection(IDENT_GHOST, PLAYER_ID_GAME_MASTER, true);
        break;
    }

    {
        RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
        assert(w != NULL);

        int index = w->findItemNamed("best");
        Widget* hardestWidget = &w->getChildren()[index];

        if (PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
        {
            hardestWidget->setBadge(LOCKED_BADGE);
            hardestWidget->setActive(false);
        }
        else
        {
            hardestWidget->unsetBadge(LOCKED_BADGE);
            hardestWidget->setActive(true);
        }
    }
}   // init
Example #12
0
void FileSystemActor::setFilePath(QString fullPath, bool skipTextureResolution /*=false*/)
{	
	if (_isAnimatedTexture)
		_animatedTextureSource.setPath(fullPath);

	// Save the Path (or Virtual Folder Name)
	filePath = fullPath;
	winOS->GetShortPathName(fullPath, shortPath);
	if (skipTextureResolution)
		return;

	// resolve the texture to load for this file if there is one
	QString ext = fsManager->getFileExtension(fullPath);
	QString texId;
	GLTextureDetail detail = FileIcon;
	GLTextureLoadPriority priority = NormalPriority;

	bool isVista = winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista);
	bool overrideSystemTextures = GLOBAL(settings).useThemeIconOverrides;
	int virtualIconId = winOS->GetIconTypeFromFileName(fullPath);
	if (virtualIconId > -1)
	{
		// mark this is a virtual icon
		pushFileSystemType(Virtual);
		pushFileSystemType(Folder);

		// check if we are overloading any virtual icons (only My Computer for now)
		if (overrideSystemTextures && 
			(virtualIconId == MyComputer) &&
			texMgr->hasTexture("override.virtual.mycomputer"))
		{
			texId = QT_NT("override.virtual.mycomputer");
			detail = HiResImage;
		}
		else
		{
			// otherwise, we will just load the icon later
			texId = fullPath;

			// NOTE: we force load these icons here because we do not do so if the 
			// texture id is set below
			loadThumbnailTexture(GLTextureObject(Load, texId, texId, FileIcon, priority, false));
		}
	}
	else
	{
		// not a virtual icon, just a random icon then
		unsigned int fileAttributes = fsManager->getFileAttributes(fullPath);

		// delete this object if it doesn't exist (and it's not a photo frame or volume)
		if (!fileAttributes &&
			!(isFileSystemType(PhotoFrame) || isFileSystemType(LogicalVolume)))
		{
			animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) DeleteActorAfterAnim));
			setAlpha(0.0f);
			return;
		}

		// make sure there's no lingering animations
		animManager->removeAnimation(this);
		setAlpha(1.0f);

		// XXX: check if we are using animated textures
		// _isAnimatedTexture = (fileExtension == ".gif");

		// check if this is a shortcut
		// NOTE: if it is a valid shortcut, the file attributes and extension
		//		 now refer to the target and not the shortcut itself
		if (fileAttributes && ext == ".lnk")
		{
			// resolve the shortcut target
			fsManager->getShortcutTarget(fullPath, &lnkFullPath);
			if (fsManager->isValidFileName(lnkFullPath))
			{
				pushFileSystemType(Link);
				popFileSystemType(DeadLink);

				fileAttributes = fsManager->getFileAttributes(lnkFullPath);
				ext = fsManager->getFileExtension(lnkFullPath);
			}
			else
			{
				pushFileSystemType(DeadLink);
			}
		}


		// check if it is a folder
		if (fileAttributes & Directory)
		{
			pushFileSystemType(Folder);

			// XXX: only override shortcuts, and not folders?
			/*
			if (!overrideSystemTextures || !enableFileTypeIconsForShortcuts)
			{
				texId = winOS->GetSystemIconInfo(getFullPath());
			}
			else 
			*/
			if (overrideSystemTextures)
			{
				texId = QT_NT("override.ext.folder");
				detail = HiResImage;
			}		
		}
		else
		{
			// normal file
			pushFileSystemType(File);
			hasExtension(true); //only files have extension, so the nameable extension hide only applies here

			// resolve some information about the file
			if (ext.size() > 0)
			{
				if (ext == ".exe")
					pushFileSystemType(Executable);
				else
				{
					// XXX: check if it's a document
					// pushFileSystemType(Document);

					if (overrideSystemTextures)
					{
						QString potentialOverrideTex = QString(QT_NT("override.ext")) + ext;
						if (texMgr->hasTexture(potentialOverrideTex))
						{
							texId = potentialOverrideTex;
							detail = HiResImage;
						}
					}
				}

				// load the thumbnail if this is an image
				// NOTE: we append the period because if the extension is empty
				// the search is always true
				if (GLOBAL(supportedExtensions).contains(ext + "."))
				{
					if (!isThumbnailized())
						enableThumbnail(true, !winOS->IsFileInUse(fullPath));
					pushFileSystemType(Image);
					pushFileSystemType(Thumbnail);
					hideText(true);
				}
			}
		}
	}

	// at this point, resolve the file icon texture id if there was no override
	if (texId.isEmpty())
	{
		texId = winOS->GetSystemIconInfo(fullPath);

		// mark the texture for loading
		loadThumbnailTexture(GLTextureObject(Load, texId, texId, detail, priority,false));
	}
	setTextureID(texId);

	// we also want to try and load thumbnails for normal files if they exist
	// (as long as it's not a widget file)
	Widget * w = widgetManager->getActiveWidgetForFile(fullPath);
	if (!isThumbnailized() && (detail == FileIcon) && !w)
	{
		FileSystemActorType typesToIgnore = FileSystemActorType(Executable | Virtual);
		// on vista, just queue the thumbnail for loading
		if (isVista && !isFileSystemType(typesToIgnore))
		{
			QString ext = fsManager->getFileExtension(getTargetPath());
			loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority));
		}
		// on windows xp, check if the thumbs db has a record first
		else if (winOS->IsWindowsVersion(WindowsXP))
		{
			if (texMgr->hasWinThumbnail(getTargetPath()))
			{
				loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority));
			}
		}
	}

	// XXX: (disabled) set the initial dimensions and weight of this file based on it's size
	// setDimsFromFileSize(this);

	// set the text
	if(!isFileSystemType(PhotoFrame)) {
		if (w && w->isWidgetOverrideActor(this))
		{
			setText(w->getWidgetOverrideLabel(this));
			Vec3 actorDims = getDims();
			float aspect = (actorDims.x / actorDims.y);
			Vec3 dims(GLOBAL(settings).xDist, GLOBAL(settings).zDist / aspect, GLOBAL(settings).yDist);
			float scale = w->getWidgetOverrideScale(this);
			if (scale > 0.0f)
			{
				dims *= scale;
				setSizeAnim(getDims(), dims, 25);
			}
		}
		else
			setText(getFileName(isFileSystemType(Link) || isFileSystemType(DeadLink)));
	}
	setRespectIconExtensionVisibility(!isFileSystemType(Folder));


	// New name was set, invalidate text
	textManager->invalidate();
	rndrManager->invalidateRenderer();
}
Example #13
0
	Widget* ResourceLayout::createWidget(const WidgetInfo& _widgetInfo, const std::string& _prefix, Widget* _parent, bool _template)
	{
		std::string widgetName = _widgetInfo.name;
		WidgetStyle style = _widgetInfo.style;
		std::string widgetLayer = _widgetInfo.layer;

		if (!widgetName.empty()) widgetName = _prefix + widgetName;

		if (_parent != nullptr && style != WidgetStyle::Popup) widgetLayer.clear();

		IntCoord coord;
		if (_widgetInfo.positionType == WidgetInfo::Pixels) coord = _widgetInfo.intCoord;
		else if (_widgetInfo.positionType == WidgetInfo::Relative)
		{
			if (_parent == nullptr || style == WidgetStyle::Popup)
				coord = CoordConverter::convertFromRelative(_widgetInfo.floatCoord, RenderManager::getInstance().getViewSize());
			else
				coord = CoordConverter::convertFromRelative(_widgetInfo.floatCoord, _parent->getClientCoord().size());
		}

		Widget* wid;
		if (nullptr == _parent)
			wid = Gui::getInstance().createWidgetT(_widgetInfo.type, _widgetInfo.skin, coord, _widgetInfo.align, widgetLayer, widgetName);
		else if (_template)
			wid = _parent->_createSkinWidget(style, _widgetInfo.type, _widgetInfo.skin, coord, _widgetInfo.align, widgetLayer, widgetName);
		else
			wid = _parent->createWidgetT(style, _widgetInfo.type, _widgetInfo.skin, coord, _widgetInfo.align, widgetLayer, widgetName);

		for (VectorStringPairs::const_iterator iter = _widgetInfo.properties.begin(); iter != _widgetInfo.properties.end(); ++iter)
		{
			wid->setProperty(iter->first, iter->second);
		}

		for (MapString::const_iterator iter = _widgetInfo.userStrings.begin(); iter != _widgetInfo.userStrings.end(); ++iter)
		{
			wid->setUserString(iter->first, iter->second);
			if (!_template)
				LayoutManager::getInstance().eventAddUserString(wid, iter->first, iter->second);
		}

		for (VectorWidgetInfo::const_iterator iter = _widgetInfo.childWidgetsInfo.begin(); iter != _widgetInfo.childWidgetsInfo.end(); ++iter)
		{
			createWidget(*iter, _prefix, wid);
		}

		for (std::vector<ControllerInfo>::const_iterator iter = _widgetInfo.controllers.begin(); iter != _widgetInfo.controllers.end(); ++iter)
		{
			MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(iter->type);
			if (item)
			{
				for (MapString::const_iterator iterProp = iter->properties.begin(); iterProp != iter->properties.end(); ++iterProp)
				{
					item->setProperty(iterProp->first, iterProp->second);
				}
				MyGUI::ControllerManager::getInstance().addItem(wid, item);
			}
			else
			{
				MYGUI_LOG(Warning, "Controller '" << iter->type << "' not found");
			}
		}

		return wid;
	}
Example #14
0
static void doMenu()
{
	Widget *w;
	int left, right, up, down, attack, xAxisMoved, yAxisMoved;

	left = FALSE;
	right = FALSE;
	up = FALSE;
	down = FALSE;
	attack = FALSE;

	if (menuInput.left == TRUE)
	{
		left = TRUE;
	}

	else if (menuInput.right == TRUE)
	{
		right = TRUE;
	}

	else if (menuInput.up == TRUE)
	{
		up = TRUE;
	}

	else if (menuInput.down == TRUE)
	{
		down = TRUE;
	}

	else if (menuInput.attack == TRUE)
	{
		attack = TRUE;
	}

	else if (input.left == TRUE)
	{
		left = TRUE;
	}

	else if (input.right == TRUE)
	{
		right = TRUE;
	}

	else if (input.up == TRUE)
	{
		up = TRUE;
	}

	else if (input.down == TRUE)
	{
		down = TRUE;
	}

	else if (input.attack == TRUE)
	{
		attack = TRUE;
	}

	if (down == TRUE)
	{
		menu.index++;

		if (menu.index == menu.widgetCount)
		{
			menu.index = 0;
		}

		playSound("sound/common/click");
	}

	else if (up == TRUE)
	{
		menu.index--;

		if (menu.index < 0)
		{
			menu.index = menu.widgetCount - 1;
		}

		playSound("sound/common/click");
	}

	else if (attack == TRUE)
	{
		w = menu.widgets[menu.index];

		if (w->clickAction != NULL)
		{
			w->clickAction();
		}

		playSound("sound/common/click");
	}

	else if (left == TRUE)
	{
		w = menu.widgets[menu.index];

		if (w->leftAction != NULL)
		{
			w->leftAction();
		}

		playSound("sound/common/click");
	}

	else if (right == TRUE)
	{
		w = menu.widgets[menu.index];

		if (w->rightAction != NULL)
		{
			w->rightAction();
		}

		playSound("sound/common/click");
	}

	xAxisMoved = input.xAxisMoved;
	yAxisMoved = input.yAxisMoved;

	memset(&menuInput, 0, sizeof(Input));
	memset(&input, 0, sizeof(Input));

	input.xAxisMoved = xAxisMoved;
	input.yAxisMoved = yAxisMoved;
}
Example #15
0
void Window::dispose() {
    Widget *widget = this;
    while (widget->parent())
        widget = widget->parent();
    ((Screen *) widget)->disposeWindow(this);
}
Example #16
0
File: ui.cpp Project: hyp/Arpheg
		void onMouseWheel(const input::events::MouseWheel& ev){
			if(focused) focused->onMouseWheel(ev);
		}
Example #17
0
void Window::center() {
    Widget *widget = this;
    while (widget->parent())
        widget = widget->parent();
    ((Screen *) widget)->centerWindow(this);
}
Example #18
0
File: ui.cpp Project: hyp/Arpheg
		void onKey(const input::events::Key& ev) {
			if(focused) focused->onKey(ev);
		}
Example #19
0
void Window::detach(Widget& b)
{
    b.hide();
}
Example #20
0
File: ui.cpp Project: hyp/Arpheg
		void onJoystick(const input::events::Joystick& ev) {
			if(focused) focused->onJoystick(ev);
		}
Example #21
0
File: uigui.cpp Project: tc-/GameUI
void Gui::render(  )
{
  List<UpdateWidget*>& l = Widget::updatedWidgets();
  if ( l.count() <= 0 ) return;
  int i = l.count() - 1;
  Widget* o = NULL;
  List<Widget*> tmpL;
  l.sort( &objectsListSortCallback );
  while( i >= 0 ){

    o = l.get( i )->o;
    Rect r = l.get( i )->r;

    if ( pFgFrame != NULL )
      fgFrame().getWidgetsInRect( tmpL, r );
    if ( pTopFrame != NULL )
      topFrame().getWidgetsInRect( tmpL, r );

    tmpL.sort( &objectListSortCallback );

    int i2 = 0;
    bool skip = false;
//    int before = tmpL.count();

    while ( (i2 < tmpL.count()) && ( o != NULL ) ) {

      Widget* o2 = tmpL.get( i2 );
			Rect r2( o2->absoluteXPos(), o2->absoluteYPos(), o2->width(), o2->height() );
      if ( o2->border() != NULL ) {
        if ( o2->border()->drawmode() != drawOpaque )
          r2.applyBorder( o2->border() );
      }
			if ( (r2.encloses( r )) && ( o2->drawmode() == drawOpaque ) && ( o2->visible() ) ) {
        if ( o2->zIndex() > o->zIndex() ) {

          skip = true;
          break;
        } else {
          while ( i2+1 < tmpL.count() ) {

            tmpL.remove( i2+1 );
          }
          break;
        }
      }
      i2++;
    }


    if ( !skip ) {

      for( int i2 = tmpL.count() - 1; i2 >= 0; i2-- ){

        Rect r2 = Rect( tmpL.get( i2 )->absoluteXPos(),
                        tmpL.get( i2 )->absoluteYPos(),
                        tmpL.get( i2 )->width(), tmpL.get( i2 )->height() );
        r2.crop( r );

        screen().pushClipRect( r2 );
        screen().pushClipRect( tmpL.get( i2 )->getClipRect() );
        screen().setRelativePoint( tmpL.get( i2 )->absoluteXPos(), tmpL.get( i2 )->absoluteYPos() );

        tmpL.get( i2 )->renderBorder( screen() );

        screen().setRelativePoint( tmpL.get( i2 )->absoluteXPos() + tmpL.get( i2 )->borderLeft(),
                                  tmpL.get( i2 )->absoluteYPos() + tmpL.get( i2 )->borderTop() );
        Rect r3( r2.left - tmpL.get( i2 )->absoluteXPos() - tmpL.get( i2 )->borderLeft(), r2.top - tmpL.get( i2 )->absoluteYPos() - tmpL.get( i2 )->borderTop(), r2.width, r2.height );
        tmpL.get( i2 )->render( screen(), r3 );

        screen().popClipRect();
        screen().popClipRect();
        screen().setRelativePoint( 0, 0 );

      }

      for( int i = 0; i < pPopups.count(); i++ ) {
        Popup* p = pPopups.get( i );
        r.crop( p->getRect() );
        if ( r.area() > 0 ) {
          Rect r = p->getRect();
          r.crop( r );
          p->render( r );
        }
      }
    } else {

    }
    tmpL.clear();
    i--;
  }

  Widget::clearUpdatedWidgets();

}
Example #22
0
	bool InputManager::injectMousePress(int _absx, int _absy, MouseButton _id)
	{
		Widget* old_key_focus = mWidgetKeyFocus;

		// если мы щелкнули не на гуй
		if (!isFocusMouse())
		{
			resetKeyFocusWidget();

			if (old_key_focus != mWidgetKeyFocus)
				eventChangeKeyFocus(mWidgetKeyFocus);

			return false;
		}

		// если активный элемент заблокирован
		//FIXME
		if (!mWidgetMouseFocus->getEnabled())
			return true;

		if (MouseButton::Left == _id)
		{
			// захват окна
			mLeftMouseCapture = true;
			// запоминаем место нажатия
			if (mLayerMouseFocus != nullptr)
			{
				IntPoint point = mLayerMouseFocus->getPosition(_absx, _absy);
				mLastLeftPressed = point;
			}
		}

		if (MouseButton::Right == _id)
		{
			// захват окна
			mRightMouseCapture = true;
			// запоминаем место нажатия
			if (mLayerMouseFocus != nullptr)
			{
				IntPoint point = mLayerMouseFocus->getPosition(_absx, _absy);
				mLastRightPressed = point;
			}
		}

		// ищем вверх тот виджет который может принимать фокус
		Widget* item = mWidgetMouseFocus;
		while ((item != nullptr) && (!item->getNeedKeyFocus()))
			item = item->getParent();

		// устанавливаем перед вызовом т.к. возможно внутри ктонить поменяет фокус под себя
		setKeyFocusWidget(item);

		if (mWidgetMouseFocus != nullptr)
		{
			mWidgetMouseFocus->_riseMouseButtonPressed(_absx, _absy, _id);

			// после пресса может сброситься
			if (mWidgetMouseFocus)
			{
				// поднимаем виджет, надо подумать что делать если поменялся фокус клавы
				LayerManager::getInstance().upLayerItem(mWidgetMouseFocus);

				// поднимаем пикинг Overlapped окон
				Widget* pick = mWidgetMouseFocus;
				do
				{
					// если оверлаппед, то поднимаем пикинг
					if (pick->getWidgetStyle() == WidgetStyle::Overlapped)
					{
						if (pick->getParent()) pick->getParent()->_forcePeek(pick);
					}

					pick = pick->getParent();
				}
				while (pick);
			}
		}

		if (old_key_focus != mWidgetKeyFocus)
			eventChangeKeyFocus(mWidgetKeyFocus);

		return true;
	}
Example #23
0
void Container::makeLayout(int x,int y,int w,int h) {
debug_output("Container::makeLayout(x: %d, y: %d, w: %d, h: %d)\n",x,y,w,h);
	Widget::makeLayout(x,y,w,h);
//	if(border) this->x += border,this->y += border,width -= border*2,height -= border*2;
	if(child) {
		Widget *c = child;
		int i,n = 0,sz[children],min,max,sum,exp,nexp,sp = (children-1)*spacing;
		int x1 = 0,y1 = 0,w1 = 0,h1 = 0,w2 = width,h2 = height;
		if(type==WIDGET_VOID) x1 += this->x,y1 += this->y;
		else if(type==WIDGET_FRAME)
			x1 += MulDiv(dbu_x,7,4),y1 += MulDiv(dbu_y,11,8),w2 -= MulDiv(dbu_x,7+7,4),h1 -= MulDiv(dbu_y,11+7,8);
		if((style&HORIZONTAL)) {
			for(i=0,c=child,min=0,max=0,sum=0,exp=0,nexp=0; c; ++i,c=c->next) {
				sum += sz[i] = n = c->getMinimumWidth();
				if(!min || min>n) min = n;
				if(max<n) max = n;
				if((c->style&EXPAND)) ++exp;
				else nexp += n;
			}
debug_output("Container::makeLayout(min: %d, max: %d, exp: %d, nexp: %d)\n",min,max,exp,nexp);
			if((style&HOMOGENOUS)) {
				for(w1=(w2-sp)/children,c=child; c; x1+=w1+spacing,c=c->next) {
					if(!c->next) w1 = w2-x1;
debug_output("Container::makeLayout(HOMOGENOUS x1: %d, w1: %d  %s)\n",x1,w1,c->text? c->text : "-");
					c->makeLayout(x1,y1,w1,h2);
				}
			} else {
				for(i=0,c=child; c; ++i,x1+=w1+spacing,c=c->next) {
					if((c->style&EXPAND)) {
						if(!c->next) w1 = w2-x1;
						else w1 = (w2-sp-nexp)/exp;
					} else w1 = sz[i];
debug_output("Container::makeLayout(x1: %d, w1: %d  %s)\n",x1,w1,c->text? c->text : "-");
					c->makeLayout(x1,y1,w1,h2);
				}
			}

		} else if((style&VERTICAL)) {
			for(i=0,c=child,min=0,max=0,sum=0,exp=0,nexp=0; c; ++i,c=c->next) {
				sum += sz[i] = n = c->getMinimumHeight();
				if(!min || min>n) min = n;
				if(max<n) max = n;
				if((c->style&EXPAND)) ++exp;
				else nexp += n;
			}
debug_output("Container::makeLayout(min: %d, max: %d, exp: %d, nexp: %d)\n",min,max,exp,nexp);
			if((style&HOMOGENOUS)) {
				for(h1=(h2-sp)/children,c=child; c; y1+=n+spacing,c=c->next) {
					if(!c->next) h1 = h2-y1;
debug_output("Container::makeLayout(HOMOGENOUS y1: %d, h1: %d  %s)\n",y1,h1,c->text? c->text : "-");
					c->makeLayout(x1,y1,w2,h1);
				}
			} else {
				for(i=0,c=child; c; ++i,y1+=h1+spacing,c=c->next) {
					if((c->style&EXPAND)) {
						if(!c->next) h1 = h2-y1;
						else h1 = (h2-sp-nexp)/exp;
					} else h1 = sz[i];
debug_output("Container::makeLayout(y1: %d, h1: %d  %s)\n",y1,h1,c->text? c->text : "-");
					c->makeLayout(x1,y1,w2,h1);
				}
			}
		} else if((style&TABLE)) {
			
		} else {
			for(; c; c=c->next)
				c->makeLayout(x,y,w,h);
		}
	}
}
Example #24
0
	bool InputManager::injectMouseMove(int _absx, int _absy, int _absz)
	{
		// запоминаем позицию
		mMousePosition.set(_absx, _absy);

		// вычисляем прирост по колеса
		int relz = _absz - mOldAbsZ;
		mOldAbsZ = _absz;

		// проверка на скролл
		if (relz != 0)
		{
			bool isFocus = isFocusMouse();
			if (mWidgetMouseFocus != nullptr)
				mWidgetMouseFocus->_riseMouseWheel(relz);
			return isFocus;
		}

		if (mLeftMouseCapture || mRightMouseCapture)
		{
			if (mWidgetMouseFocus != nullptr)
			{
				if (mLayerMouseFocus != nullptr)
				{
					IntPoint point = mLayerMouseFocus->getPosition(_absx, _absy);
					if (mLeftMouseCapture)
						mWidgetMouseFocus->_riseMouseDrag(point.left, point.top, MouseButton::Left);
					if (mRightMouseCapture)
						mWidgetMouseFocus->_riseMouseDrag(point.left, point.top, MouseButton::Right);
				}
			}
			else
			{
				mLeftMouseCapture = false;
				mRightMouseCapture = false;
			}

			return true;
		}

		Widget* old_mouse_focus = mWidgetMouseFocus;

		// ищем активное окно
		Widget* item = LayerManager::getInstance().getWidgetFromPoint(_absx, _absy);

		// ничего не изменилось
		if (mWidgetMouseFocus == item)
		{
			bool isFocus = isFocusMouse();
			if (mWidgetMouseFocus != nullptr)
			{
				if (mLayerMouseFocus != nullptr)
				{
					IntPoint point = mLayerMouseFocus->getPosition(_absx, _absy);
					mWidgetMouseFocus->_riseMouseMove(point.left, point.top);
				}
			}
			return isFocus;
		}

		if (item)
		{
			// поднимаемся до рута
			Widget* root = item;
			while (root->getParent()) root = root->getParent();

			// проверяем на модальность
			if (!mVectorModalRootWidget.empty())
			{
				if (root != mVectorModalRootWidget.back())
				{
					item = nullptr;
				}
			}

			if (item != nullptr)
			{
				mLayerMouseFocus = root->getLayer();
			}
		}

		//-------------------------------------------------------------------------------------//
		// новый вид рутового фокуса мыши
		Widget* save_widget = nullptr;

		// спускаемся по новому виджету и устанавливаем рутовый фокус
		Widget* root_focus = item;
		while (root_focus != nullptr)
		{
			if (root_focus->getRootMouseFocus())
			{
				save_widget = root_focus;
				break;
			}

			root_focus->_setRootMouseFocus(true);
			root_focus->_riseMouseChangeRootFocus(true);
			root_focus = root_focus->getParent();
		}

		// спускаемся по старому виджету и сбрасываем фокус
		root_focus = mWidgetMouseFocus;
		while (root_focus != nullptr)
		{
			if (root_focus == save_widget)
				break;

			root_focus->_setRootMouseFocus(false);
			root_focus->_riseMouseChangeRootFocus(false);
			root_focus = root_focus->getParent();
		}
		//-------------------------------------------------------------------------------------//

		// смена фокуса, проверяем на доступность виджета
		if ((mWidgetMouseFocus != nullptr) && (mWidgetMouseFocus->getEnabled()))
		{
			mWidgetMouseFocus->_riseMouseLostFocus(item);
		}

		if ((item != nullptr) && (item->getEnabled()))
		{
			item->_riseMouseMove(_absx, _absy);
			item->_riseMouseSetFocus(mWidgetMouseFocus);
		}

		// запоминаем текущее окно
		mWidgetMouseFocus = item;

		if (old_mouse_focus != mWidgetMouseFocus)
			eventChangeMouseFocus(mWidgetMouseFocus);

		return isFocusMouse();
	}
Example #25
0
/**
 * @brief Updates the toolkit input for repeating keys.
 */
void toolkit_update (void)
{
   unsigned int t;
   Window *wdw;
   Widget *wgt;
   char buf[2];
   SDL_Event event;
   int ret;

   /* Clean up the dead if needed. */
   if (!dialogue_isOpen()) { /* Hack, since dialogues use secondary loop. */
      if (toolkit_delayCounter > 0)
         toolkit_delayCounter--;
      else
         toolkit_purgeDead();
   }

   /* Killed all the windows. */
   if (windows == NULL) {
      SDL_ShowCursor(SDL_DISABLE);
      toolkit_open = 0; /* disable toolkit */
      if (paused)
         unpause_game();
   }

   /* Must have a key pressed. */
   if (input_key == 0)
      return;

   t = SDL_GetTicks();

   /* Should be repeating. */
   if (input_keyTime + INPUT_DELAY + input_keyCounter*INPUT_FREQ > t)
      return;

   /* Increment counter. */
   input_keyCounter++;

   /* Check to see what it affects. */
   if (windows != NULL) {
      /* Get the window. */
      wdw = toolkit_getActiveWindow();
      if (wdw == NULL)
         return;


      /* See if widget needs event. */
      for (wgt=wdw->widgets; wgt!=NULL; wgt=wgt->next) {
         if (wgt_isFlag( wgt, WGT_FLAG_RAWINPUT )) {
            if (wgt->rawevent != NULL) {
               event.type           = SDL_KEYDOWN;
               event.key.state      = SDL_PRESSED;
               event.key.keysym.sym = input_key;
               event.key.keysym.mod = 0;
               ret = wgt->rawevent( wgt, &event );
               if (ret != 0)
                  return;
            }
         }
      }

      /* Handle the focused widget. */
      wgt = toolkit_getFocus( wdw );
      if ((wgt != NULL) && (wgt->keyevent != NULL)) {
         wgt->keyevent( wgt, input_key, 0 );
      }
      if ((input_text != 0) && (wgt != NULL) && (wgt->textevent != NULL)) {
         buf[0] = input_text;
         buf[1] = '\0';
         wgt->textevent( wgt, buf );
      }
   }
}
Example #26
0
void Welcom::enterMain()
{
    Widget* widget = new Widget();
    this->close();
    widget->show();
}
Example #27
0
void flips(Widget& widget) {
	widget.flip();
}
Example #28
0
File: tk.c Project: mattjakob/s3d
int  button_released(void* p, int v, real x, real y, char* e)
{
  Widget *w = p;
  button_draw(w, 1);
  return w->f();
}
PassOwnPtr<WebCore::ContextMenu> ContextMenuClientImpl::customizeMenu(PassOwnPtr<WebCore::ContextMenu> defaultMenu)
{
    // Displaying the context menu in this function is a big hack as we don't
    // have context, i.e. whether this is being invoked via a script or in
    // response to user input (Mouse event WM_RBUTTONDOWN,
    // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked
    // in response to the above input events before popping up the context menu.
    if (!m_webView->contextMenuAllowed())
        return defaultMenu;

    HitTestResult r = m_webView->page()->contextMenuController()->hitTestResult();
    Frame* selectedFrame = r.innerNodeFrame();

    WebContextMenuData data;
    data.mousePosition = selectedFrame->view()->contentsToWindow(r.roundedPointInInnerNodeFrame());

    // Compute edit flags.
    data.editFlags = WebContextMenuData::CanDoNone;
    if (m_webView->focusedWebCoreFrame()->editor()->canUndo())
        data.editFlags |= WebContextMenuData::CanUndo;
    if (m_webView->focusedWebCoreFrame()->editor()->canRedo())
        data.editFlags |= WebContextMenuData::CanRedo;
    if (m_webView->focusedWebCoreFrame()->editor()->canCut())
        data.editFlags |= WebContextMenuData::CanCut;
    if (m_webView->focusedWebCoreFrame()->editor()->canCopy())
        data.editFlags |= WebContextMenuData::CanCopy;
    if (m_webView->focusedWebCoreFrame()->editor()->canPaste())
        data.editFlags |= WebContextMenuData::CanPaste;
    if (m_webView->focusedWebCoreFrame()->editor()->canDelete())
        data.editFlags |= WebContextMenuData::CanDelete;
    // We can always select all...
    data.editFlags |= WebContextMenuData::CanSelectAll;
    data.editFlags |= WebContextMenuData::CanTranslate;

    // Links, Images, Media tags, and Image/Media-Links take preference over
    // all else.
    data.linkURL = r.absoluteLinkURL();

    if (!r.absoluteImageURL().isEmpty()) {
        data.srcURL = r.absoluteImageURL();
        data.mediaType = WebContextMenuData::MediaTypeImage;
    } else if (!r.absoluteMediaURL().isEmpty()) {
        data.srcURL = r.absoluteMediaURL();

        // We know that if absoluteMediaURL() is not empty, then this
        // is a media element.
        HTMLMediaElement* mediaElement =
            toMediaElement(r.innerNonSharedNode());
        if (mediaElement->hasTagName(HTMLNames::videoTag))
            data.mediaType = WebContextMenuData::MediaTypeVideo;
        else if (mediaElement->hasTagName(HTMLNames::audioTag))
            data.mediaType = WebContextMenuData::MediaTypeAudio;

        if (mediaElement->error())
            data.mediaFlags |= WebContextMenuData::MediaInError;
        if (mediaElement->paused())
            data.mediaFlags |= WebContextMenuData::MediaPaused;
        if (mediaElement->muted())
            data.mediaFlags |= WebContextMenuData::MediaMuted;
        if (mediaElement->loop())
            data.mediaFlags |= WebContextMenuData::MediaLoop;
        if (mediaElement->supportsSave())
            data.mediaFlags |= WebContextMenuData::MediaCanSave;
        if (mediaElement->hasAudio())
            data.mediaFlags |= WebContextMenuData::MediaHasAudio;
        if (mediaElement->hasVideo())
            data.mediaFlags |= WebContextMenuData::MediaHasVideo;
        if (mediaElement->controls())
            data.mediaFlags |= WebContextMenuData::MediaControls;
    } else if (r.innerNonSharedNode()->hasTagName(HTMLNames::objectTag)
               || r.innerNonSharedNode()->hasTagName(HTMLNames::embedTag)) {
        RenderObject* object = r.innerNonSharedNode()->renderer();
        if (object && object->isWidget()) {
            Widget* widget = toRenderWidget(object)->widget();
            if (widget && widget->isPluginContainer()) {
                data.mediaType = WebContextMenuData::MediaTypePlugin;
                WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
                WebString text = plugin->plugin()->selectionAsText();
                if (!text.isEmpty()) {
                    data.selectedText = text;
                    data.editFlags |= WebContextMenuData::CanCopy;
                }
                data.editFlags &= ~WebContextMenuData::CanTranslate;
                data.linkURL = plugin->plugin()->linkAtPosition(data.mousePosition);
                if (plugin->plugin()->supportsPaginatedPrint())
                    data.mediaFlags |= WebContextMenuData::MediaCanPrint;

                HTMLPlugInImageElement* pluginElement = toHTMLPlugInImageElement(r.innerNonSharedNode());
                data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
                data.mediaFlags |= WebContextMenuData::MediaCanSave;

                // Add context menu commands that are supported by the plugin.
                if (plugin->plugin()->canRotateView())
                    data.mediaFlags |= WebContextMenuData::MediaCanRotate;
            }
        }
    }

    data.isImageBlocked =
        (data.mediaType == WebContextMenuData::MediaTypeImage) && !r.image();

    // If it's not a link, an image, a media element, or an image/media link,
    // show a selection menu or a more generic page menu.
    if (selectedFrame->document()->loader())
        data.frameEncoding = selectedFrame->document()->encoding();

    // Send the frame and page URLs in any case.
    data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame());
    if (selectedFrame != m_webView->mainFrameImpl()->frame()) {
        data.frameURL = urlFromFrame(selectedFrame);
        RefPtr<HistoryItem> historyItem = selectedFrame->loader()->history()->currentItem();
        if (historyItem)
            data.frameHistoryItem = WebHistoryItem(historyItem);
    }

    if (r.isSelected()) {
        if (!r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag) || !static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isPasswordField())
            data.selectedText = selectedFrame->editor()->selectedText().stripWhiteSpace();
    }

    if (r.isContentEditable()) {
        data.isEditable = true;
#if ENABLE(INPUT_SPEECH)
        if (r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) {
            data.isSpeechInputEnabled = 
                static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isSpeechEnabled();
        }  
#endif
        // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled
        // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks
        // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it.
        if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
            DocumentMarker marker;
            data.misspelledWord = selectMisspellingAsync(selectedFrame, marker);
            if (marker.description().length()) {
                Vector<String> suggestions;
                marker.description().split('\n', suggestions);
                data.dictionarySuggestions = suggestions;
            } else if (m_webView->spellCheckClient()) {
                int misspelledOffset, misspelledLength;
                m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
            }
        } else {
            data.isSpellCheckingEnabled = 
                m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled();
            // Spellchecking might be enabled for the field, but could be disabled on the node.
            if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode()) {
                data.misspelledWord = selectMisspelledWord(defaultMenu.get(), selectedFrame);
                if (m_webView->spellCheckClient()) {
                    int misspelledOffset, misspelledLength;
                    m_webView->spellCheckClient()->spellCheck(
                        data.misspelledWord, misspelledOffset, misspelledLength,
                        &data.dictionarySuggestions);
                    if (!misspelledLength)
                        data.misspelledWord.reset();
                }
            }
        }
        HTMLFormElement* form = selectedFrame->selection()->currentForm();
        if (form && r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) {
            HTMLInputElement* selectedElement = static_cast<HTMLInputElement*>(r.innerNonSharedNode());
            if (selectedElement) {
                WebSearchableFormData ws = WebSearchableFormData(WebFormElement(form), WebInputElement(selectedElement));
                if (ws.url().isValid())
                    data.keywordURL = ws.url();
            }
        }
    }

#if OS(DARWIN)
    if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "ltr") != FalseTriState)
        data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuItemChecked;
    if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "rtl") != FalseTriState)
        data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuItemChecked;
#endif // OS(DARWIN)

    // Now retrieve the security info.
    DocumentLoader* dl = selectedFrame->loader()->documentLoader();
    WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl);
    if (ds)
        data.securityInfo = ds->response().securityInfo();

    data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document()->referrerPolicy());

    // Filter out custom menu elements and add them into the data.
    populateCustomMenuItems(defaultMenu.get(), &data);

    data.node = r.innerNonSharedNode();

    WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame);
    if (m_webView->client())
        m_webView->client()->showContextMenu(selected_web_frame, data);

    return defaultMenu;
}
Example #30
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QGraphicsScene *scene = new QGraphicsScene();

    Widget *a = new Widget(Qt::blue, Qt::white, "a");
    a->setPreferredSize(100, 100);
    Widget *b = new Widget(Qt::green, Qt::black, "b");
    b->setPreferredSize(100, 100);
    Widget *c = new Widget(Qt::red, Qt::black, "c");
    c->setPreferredSize(100, 100);

    QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout();
/*
    //! [adding a corner anchor in two steps]
    layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop);
    layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft);
    //! [adding a corner anchor in two steps]
*/
    //! [adding a corner anchor]
    layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);
    //! [adding a corner anchor]

    //! [adding anchors]
    layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight);
    layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom);
    //! [adding anchors]

    // Place a third widget below the second.
    layout->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop);

/*
    //! [adding anchors to match sizes in two steps]
    layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft);
    layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight);
    //! [adding anchors to match sizes in two steps]
*/

    //! [adding anchors to match sizes]
    layout->addAnchors(b, c, Qt::Horizontal);
    //! [adding anchors to match sizes]

    // Anchor the bottom-right corner of the third widget to the bottom-right
    // corner of the layout.
    layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner);

    QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    w->setPos(20, 20);
    w->setMinimumSize(100, 100);
    w->setPreferredSize(320, 240);
    w->setLayout(layout);
    w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use"));
    scene->addItem(w);

    QGraphicsView *view = new QGraphicsView();
    view->setScene(scene);
    view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout"));

    view->resize(360, 320);
    view->show();

    return app.exec();
}