当前位置: 首页>>代码示例>>C++>>正文


C++ Popup类代码示例

本文整理汇总了C++中Popup的典型用法代码示例。如果您正苦于以下问题:C++ Popup类的具体用法?C++ Popup怎么用?C++ Popup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Popup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_node

void PopupMenu::_activate_submenu(int over) {

	Node* n = get_node(items[over].submenu);
	ERR_EXPLAIN("item subnode does not exist: "+items[over].submenu);
	ERR_FAIL_COND(!n);
	Popup *pm = n->cast_to<Popup>();
	ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
	ERR_FAIL_COND(!pm);
	if (pm->is_visible())
		return; //already visible!


	Point2 p = get_global_pos();
	Rect2 pr(p,get_size());
	Ref<StyleBox> style = get_stylebox("panel");
	pm->set_pos(p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y));
	pm->popup();

	PopupMenu *pum = pm->cast_to<PopupMenu>();
	if (pum) {

		pr.pos-=pum->get_global_pos();
		pum->clear_autohide_areas();
		pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y,pr.size.x,items[over]._ofs_cache));
		if (over<items.size()-1) {
			int from = items[over+1]._ofs_cache;
			pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y+from,pr.size.x,pr.size.y-from));
		}

	}

}
开发者ID:Martho42,项目名称:godot,代码行数:32,代码来源:popup_menu.cpp

示例2: qDebug

void CustomerInfoPanel::displayFiche(const QString & fichecontent, bool qtui, const QString & id)
{
    Popup * popup = NULL;
    for(int i = m_popups.size() - 1; i >= 0; i --) {
        if(id == m_popups[i]->id()) {
            qDebug() << Q_FUNC_INFO << "fiche id already there" << i << id;
            popup = m_popups[i];
            break;
        }
    }

    QBuffer * inputstream = new QBuffer(this);
    inputstream->open(QIODevice::ReadWrite);
    inputstream->write(fichecontent.toUtf8());
    inputstream->close();

    // Get Data and Popup the profile if ok
    if (popup == NULL) {
        popup = new Popup(m_autourl_allowed);
        m_popups.append(popup);
        popup->setId(id);
        connect(popup, SIGNAL(destroyed(QObject *)),
                this, SLOT(popupDestroyed(QObject *)));
        connect(popup, SIGNAL(wantsToBeShown(Popup *)),
                this, SLOT(showNewProfile(Popup *)));
        connect(popup, SIGNAL(actionFromPopup(const QString &, const QVariant &)),
                this, SLOT(actionFromPopup(const QString &, const QVariant &)));
        connect(popup, SIGNAL(newRemarkSubmitted(const QString &, const QString &)),
                b_engine, SLOT(sendNewRemark(const QString &, const QString &)));
    }
开发者ID:pcadottemichaud,项目名称:xivo-client-qt,代码行数:30,代码来源:customerinfopanel.cpp

示例3: time

void Manager::showPopup()
{
    Popup *pp = getRandomProvider<Popup>(adProviders);
    if (pp && showNextAd()) {
        time(&lastAdShownAt);
        pp->showPopupAd();
    }
}
开发者ID:JochenHeizmann,项目名称:avalon,代码行数:8,代码来源:Manager.cpp

示例4: main

int main(int argc, char* argv[]) {
        QApplication app(argc, argv);
		app.setStyleSheet("QPushButton { font: 20pt }");
        Popup *d = new Popup();
		d->setChar('a');
		//d->open();
        return app.exec();
}
开发者ID:andrewmh20,项目名称:uniCLAV,代码行数:8,代码来源:main.cpp

示例5: mouseReleased

void Gui::mouseReleased( int x, int y, MouseButtons mb )
{
  cout << "Ui::Gui::mouseReleased( " << x << ", " << y << " )"  << endl;

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

	if ( pMouseDragWidget != NULL ) {
		pMouseDragWidget->onDestroy.disconnect( this );
		pMouseDragWidget = NULL;
	}

  if ( pMouseChannelWidget != NULL ) {


    if ( pMousePressedWidget == pMouseChannelWidget ) {
      if ( pLastClick <= pDblClickTicks ) {
        pMouseChannelWidget->mouseDblClick( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );
				pMouseChannelWidget->mouseClick( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );
				pLastClick = pDblClickTicks + 1;
      } else {
        pMouseChannelWidget->mouseClick( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );
        pLastClick = 0;
      }
      pMousePressedWidget->onDestroy.disconnect( this );
      pMousePressedWidget = NULL;
    }
    pMouseChannelWidget->mouseReleased( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );

  } else {

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

    Widget* o = fgFrame().mouseReleased( x, y, mb );
    if ( o != NULL ) {
      if ( pMousePressedWidget == o ) {
        pMousePressedWidget->onDestroy.disconnect( this );
        pMousePressedWidget = NULL;
        o->mouseClick( x, y, mb );
      }
      //o->mouseReleased( x, y, mb );
    }
  }
}
开发者ID:dcthe1,项目名称:GameUI,代码行数:57,代码来源:uigui.cpp

示例6: msg_Warn

void TopWindow::processEvent( EvtMenu &rEvtMenu )
{
    Popup *pPopup = m_rWindowManager.getActivePopup();
    // We should never receive a menu event when there is no active popup!
    if( pPopup == NULL )
    {
        msg_Warn( getIntf(), "unexpected menu event, ignoring" );
        return;
    }

    pPopup->handleEvent( rEvtMenu );
}
开发者ID:CSRedRat,项目名称:vlc,代码行数:12,代码来源:top_window.cpp

示例7: switch

void ColorPicker::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_THEME_CHANGED: {

			btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
			bt_add_preset->set_icon(get_icon("add_preset"));

			_update_controls();
		} break;
		case NOTIFICATION_ENTER_TREE: {

			btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
			bt_add_preset->set_icon(get_icon("add_preset"));

			_update_color();

#ifdef TOOLS_ENABLED
			if (Engine::get_singleton()->is_editor_hint()) {
				PoolColorArray saved_presets = EditorSettings::get_singleton()->get_project_metadata("color_picker", "presets", PoolColorArray());

				for (int i = 0; i < saved_presets.size(); i++) {
					add_preset(saved_presets[i]);
				}
			}
#endif
		} break;
		case NOTIFICATION_PARENTED: {

			for (int i = 0; i < 4; i++)
				set_margin((Margin)i, get_constant("margin"));
		} break;
		case NOTIFICATION_VISIBILITY_CHANGED: {

			Popup *p = Object::cast_to<Popup>(get_parent());
			if (p)
				p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
		} break;
		case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {

			if (screen != NULL) {
				if (screen->is_visible()) {
					screen->hide();
				}
			}
		} break;
	}
}
开发者ID:ialex32x,项目名称:godot,代码行数:48,代码来源:color_picker.cpp

示例8: moveWindowToFront

void Screen::moveWindowToFront(Window *window) {
    mChildren.erase(std::remove(mChildren.begin(), mChildren.end(), window), mChildren.end());
    mChildren.push_back(window);
    /* Brute force topological sort (no problem for a few windows..) */
    bool changed = false;
    do {
        size_t baseIndex = 0;
        for (size_t index = 0; index < mChildren.size(); ++index)
            if (mChildren[index] == window)
                baseIndex = index;
        changed = false;
        for (size_t index = 0; index < mChildren.size(); ++index) {
            Popup *pw = dynamic_cast<Popup *>(mChildren[index]);
            if (pw && pw->parentWindow() == window && index < baseIndex) {
                moveWindowToFront(pw);
                changed = true;
                break;
            }
        }
    } while (changed);
}
开发者ID:arajar,项目名称:crawler,代码行数:21,代码来源:screen.cpp

示例9: createGameOverPopup

Popup* PopupFactory::createGameOverPopup(std::shared_ptr<Delegate> resetDelegate, std::shared_ptr<Delegate> quitDelegate)
{
    cocos2d::CCSize worldSize = cocos2d::CCDirector::sharedDirector()->getWinSize();
    
    std::vector<std::string>  buttonsImages = {"retry","quitbig"};
    std::vector<std::shared_ptr<Delegate>> delegates = {resetDelegate,quitDelegate};
    
    Popup *p = Popup::create();
    p->initPopup(worldSize.width - 300,
                 worldSize.height - 200 ,
                 buttonsImages ,
                 delegates,
                 "Game Over!",
                 100,
                 ""
                 );
    
    
    return p;

}
开发者ID:ricolynx,项目名称:Reflex,代码行数:21,代码来源:PopupFactory.cpp

示例10: createPausePopup

Popup* PopupFactory::createPausePopup(std::shared_ptr<Delegate> continueDelegate, std::shared_ptr<Delegate> quitDelegate)
{
    //std::cout << "Create popup pause"<< std::endl;
    
    cocos2d::CCSize worldSize = cocos2d::CCDirector::sharedDirector()->getWinSize();
    
    std::vector<std::string>  buttonsImages = {"play","quitbig"};
    std::vector<std::shared_ptr<Delegate>> delegates = {continueDelegate,quitDelegate};
    
    Popup *p = Popup::create();
    p->initPopup(worldSize.width - 300,
                 worldSize.height - 200 ,
                 buttonsImages ,
                 delegates,
                 "PAUSE",
                 100,
                 ""
                 );

    
    return p;
}
开发者ID:ricolynx,项目名称:Reflex,代码行数:22,代码来源:PopupFactory.cpp

示例11: get_node

void PopupMenu::_activate_submenu(int over) {

	Node *n = get_node(items[over].submenu);
	ERR_EXPLAIN("item subnode does not exist: " + items[over].submenu);
	ERR_FAIL_COND(!n);
	Popup *pm = Object::cast_to<Popup>(n);
	ERR_EXPLAIN("item subnode is not a Popup: " + items[over].submenu);
	ERR_FAIL_COND(!pm);
	if (pm->is_visible_in_tree())
		return; //already visible!

	Point2 p = get_global_position();
	Rect2 pr(p, get_size());
	Ref<StyleBox> style = get_stylebox("panel");

	Point2 pos = p + Point2(get_size().width, items[over]._ofs_cache - style->get_offset().y);
	Size2 size = pm->get_size();
	// fix pos
	if (pos.x + size.width > get_viewport_rect().size.width)
		pos.x = p.x - size.width;

	pm->set_position(pos);
	pm->popup();

	PopupMenu *pum = Object::cast_to<PopupMenu>(pm);
	if (pum) {

		pr.position -= pum->get_global_position();
		pum->clear_autohide_areas();
		pum->add_autohide_area(Rect2(pr.position.x, pr.position.y, pr.size.x, items[over]._ofs_cache));
		if (over < items.size() - 1) {
			int from = items[over + 1]._ofs_cache;
			pum->add_autohide_area(Rect2(pr.position.x, pr.position.y + from, pr.size.x, pr.size.y - from));
		}
	}
}
开发者ID:kubecz3k,项目名称:godot,代码行数:36,代码来源:popup_menu.cpp

示例12: initGraph

void View::create (WindowRef & ciWindow, const fs::path & assetFolder)
{
   try
   {
      initGraph (&fps, GRAPH_RENDER_FPS, "Frame Time");
      initGraph (&cpuGraph, GRAPH_RENDER_MS, "CPU Time");

      setSize (ciWindow->getSize());

      nanogui::Window * window = new nanogui::Window (this, "Button demo");
      window->setPosition (ivec2 (15, 15));
      window->setLayout (new GroupLayout());
      /* No need to store a pointer, the data structure will be automatically
         freed when the parent window is deleted */
      new Label (window, "Push buttons", "sans-bold");
      Button * b = new Button (window, "Plain button");
      b->setCallback ([] { cout << "pushed!" << endl; });
      b = new Button (window, "Styled", ENTYPO_ICON_ROCKET);
      b->setBackgroundColor (Colour (0, 0, 255, 25));
      b->setCallback ([] { cout << "pushed!" << endl; });
      new Label (window, "Toggle buttons", "sans-bold");
      b = new Button (window, "Toggle me");
      b->setFlags (Button::ToggleButton);
      b->setChangeCallback ([] (bool state)
      {
         cout << "Toggle button state: " << state << endl;
      });
      new Label (window, "Radio buttons", "sans-bold");
      b = new Button (window, "Radio button 1");
      b->setFlags (Button::RadioButton);
      b = new Button (window, "Radio button 2");
      b->setFlags (Button::RadioButton);
      new Label (window, "A tool palette", "sans-bold");
      Widget * tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new ToolButton (tools, ENTYPO_ICON_CLOUD);
      b = new ToolButton (tools, ENTYPO_ICON_FF);
      b = new ToolButton (tools, ENTYPO_ICON_COMPASS);
      b = new ToolButton (tools, ENTYPO_ICON_INSTALL);
      new Label (window, "Popup buttons", "sans-bold");
      PopupButton * popupBtn = new PopupButton (window, "Popup", ENTYPO_ICON_EXPORT);
      Popup * popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new Label (popup, "Arbitrary widgets can be placed here");
      new CheckBox (popup, "A check box");
      popupBtn = new PopupButton (popup, "Recursive popup", ENTYPO_ICON_FLASH);
      popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new CheckBox (popup, "Another check box");
      window = new nanogui::Window (this, "Basic widgets");
      window->setPosition (ivec2 (200, 15));
      window->setLayout (new GroupLayout());
      new Label (window, "Message dialog", "sans-bold");
      tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new Button (tools, "Info");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Information, "Title", "This is an information message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Warn");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a warning message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Ask");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a question message", "Yes", "No", true);
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });

	  std::string iconPath = assetFolder.string();
	  iconPath += "/icons";
     
      std::vector<std::pair<int, std::string>> icons = NanoUtil::loadImageDirectory (getContext(), iconPath);
      new Label (window, "Image panel & scroll panel", "sans-bold");
      PopupButton * imagePanelBtn = new PopupButton (window, "Image Panel");
      imagePanelBtn->setIcon (ENTYPO_ICON_FOLDER);
      popup = imagePanelBtn->popup();
      VScrollPanel * vscroll = new VScrollPanel (popup);
      ImagePanel * imgPanel = new ImagePanel (vscroll);
      imgPanel->setImages (icons);
      popup->setFixedSize (ivec2 (245, 150));
      new Label (window, "Selected image", "sans-bold");
      auto img = new ImageView (window);
      img->setFixedSize (ivec2 (40, 40));
//.........这里部分代码省略.........
开发者ID:DanGroom,项目名称:NanoguiBlock,代码行数:101,代码来源:View.cpp

示例13: ExampleApplication

    ExampleApplication() : nanogui::Screen(Eigen::Vector2i(800, 600), "NanoGUI Test") {
        using namespace nanogui;

        Window *window = new Window(this, "Button demo");
        window->setPosition(Vector2i(15, 15));
        window->setLayout(new GroupLayout());

        /* No need to store a pointer, the data structure will be automatically
           freed when the parent window is deleted */
        new Label(window, "Push buttons", "sans-bold");

        Button *b = new Button(window, "Plain button");
        b->setCallback([] { cout << "pushed!" << endl; });
        b = new Button(window, "Styled", ENTYPO_ICON_ROCKET);
        b->setBackgroundColor(Color(0, 0, 255, 255));
        b->setCallback([] { cout << "pushed!" << endl; });

        new Label(window, "Toggle buttons", "sans-bold");
        b = new Button(window, "Toggle me");
        b->setButtonFlags(Button::ToggleButton);
        b->setChangeCallback([](bool state) { cout << "Toggle button state: " << state << endl; });

        new Label(window, "Radio buttons", "sans-bold");
        b = new Button(window, "Radio button 1");
        b->setButtonFlags(Button::RadioButton);
        b = new Button(window, "Radio button 2");
        b->setButtonFlags(Button::RadioButton);

        new Label(window, "A tool palette", "sans-bold");
        Widget *tools = new Widget(window);
        tools->setLayout(new BoxLayout(BoxLayout::Horizontal, BoxLayout::Middle, 0, 6));

        b = new ToolButton(tools, ENTYPO_ICON_CLOUD);
        b = new ToolButton(tools, ENTYPO_ICON_FF);
        b = new ToolButton(tools, ENTYPO_ICON_COMPASS);
        b = new ToolButton(tools, ENTYPO_ICON_INSTALL);

        new Label(window, "Popup buttons", "sans-bold");
        PopupButton *popupBtn = new PopupButton(window, "Popup", ENTYPO_ICON_EXPORT);
        Popup *popup = popupBtn->popup();
        popup->setLayout(new GroupLayout());
        new Label(popup, "Arbitrary widgets can be placed here");
        new CheckBox(popup, "A check box");
        popupBtn = new PopupButton(popup, "Recursive popup", ENTYPO_ICON_FLASH);
        popup = popupBtn->popup();
        popup->setLayout(new GroupLayout());
        new CheckBox(popup, "Another check box");

        window = new Window(this, "Basic widgets");
        window->setPosition(Vector2i(200, 15));
        window->setLayout(new GroupLayout());

        new Label(window, "Message dialog", "sans-bold");
        tools = new Widget(window);
        tools->setLayout(new BoxLayout(BoxLayout::Horizontal, BoxLayout::Middle, 0, 6));
        b = new Button(tools, "Info");
        b->setCallback([&] {
            auto dlg = new MessageDialog(this, MessageDialog::Information, "Title", "This is an information message");

            dlg->setCallback([](int result) {  });
        });
        b = new Button(tools, "Warn");
        b->setCallback([&] {
            auto dlg = new MessageDialog(this, MessageDialog::Warning, "Title", "This is a warning message");
            dlg->setCallback([](int result) { cout << "Dialog result: " << result << endl; });
        });
        b = new Button(tools, "Ask");
        b->setCallback([&] {
            auto dlg = new MessageDialog(this, MessageDialog::Warning, "Title", "This is a question message", "Yes", "No", true);
            dlg->setCallback([](int result) { cout << "Dialog result: " << result << endl; });
        });

        std::vector<std::pair<int, std::string>>
            icons = loadImageDirectory(mNVGContext, "icons");

        new Label(window, "Image panel & scroll panel", "sans-bold");
        PopupButton *imagePanelBtn = new PopupButton(window, "Image Panel");
        imagePanelBtn->setIcon(ENTYPO_ICON_FOLDER);
        popup = imagePanelBtn->popup();
        VScrollPanel *vscroll = new VScrollPanel(popup);
        ImagePanel *imgPanel = new ImagePanel(vscroll);
        imgPanel->setImageData(icons);
        popup->setFixedSize(Vector2i(245, 150));
        new Label(window, "Selected image", "sans-bold");
        auto img = new ImageView(window);
        img->setFixedSize(Vector2i(40, 40));

        new Label(window, "File dialog", "sans-bold");
        tools = new Widget(window);
        tools->setLayout(new BoxLayout(BoxLayout::Horizontal, BoxLayout::Middle, 0, 6));
        b = new Button(tools, "Open");
        b->setCallback([&] {
            cout << "File dialog result: " << file_dialog(
                    { {"png", "Portable Network Graphics"}, {"txt", "Text file"} }, false) << endl;
        });
        b = new Button(tools, "Save");
        b->setCallback([&] {
            cout << "File dialog result: " << file_dialog(
                    { {"png", "Portable Network Graphics"}, {"txt", "Text file"} }, true) << endl;
        });
//.........这里部分代码省略.........
开发者ID:AndreaMelle,项目名称:omnipreview,代码行数:101,代码来源:example.cpp

示例14: initGraph

void View::create (WindowRef & ciWindow)
{
   try
   {
      initGraph (&fps, GRAPH_RENDER_FPS, "Frame Time");
      initGraph (&cpuGraph, GRAPH_RENDER_MS, "CPU Time");

      setSize (ciWindow->getSize());

      nanogui::Window * window = new nanogui::Window (this, "Button demo");
      window->setPosition (ivec2 (15, 15));
      window->setLayout (new GroupLayout());
      /* No need to store a pointer, the data structure will be automatically
         freed when the parent window is deleted */
      new Label (window, "Push buttons", "sans-bold");
      Button * b = new Button (window, "Plain button");
      b->setCallback ([] { cout << "pushed!" << endl; });
      b = new Button (window, "Styled", ENTYPO_ICON_ROCKET);
      b->setBackgroundColor (Colour (0, 0, 255, 25));
      b->setCallback ([] { cout << "pushed!" << endl; });
      new Label (window, "Toggle buttons", "sans-bold");
      b = new Button (window, "Toggle me");
      b->setFlags (Button::ToggleButton);
      b->setChangeCallback ([] (bool state)
      {
         cout << "Toggle button state: " << state << endl;
      });
      new Label (window, "Radio buttons", "sans-bold");
      b = new Button (window, "Radio button 1");
      b->setFlags (Button::RadioButton);
      b = new Button (window, "Radio button 2");
      b->setFlags (Button::RadioButton);
      new Label (window, "A tool palette", "sans-bold");
      Widget * tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new ToolButton (tools, ENTYPO_ICON_CLOUD);
      b = new ToolButton (tools, ENTYPO_ICON_FF);
      b = new ToolButton (tools, ENTYPO_ICON_COMPASS);
      b = new ToolButton (tools, ENTYPO_ICON_INSTALL);
      new Label (window, "Popup buttons", "sans-bold");
      PopupButton * popupBtn = new PopupButton (window, "Popup", ENTYPO_ICON_EXPORT);
      Popup * popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new Label (popup, "Arbitrary widgets can be placed here");
      new CheckBox (popup, "A check box");
      popupBtn = new PopupButton (popup, "Recursive popup", ENTYPO_ICON_FLASH);
      popup = popupBtn->popup();
      popup->setLayout (new GroupLayout());
      new CheckBox (popup, "Another check box");
      window = new nanogui::Window (this, "Basic widgets");
      window->setPosition (ivec2 (200, 15));
      window->setLayout (new GroupLayout());
      new Label (window, "Message dialog", "sans-bold");
      tools = new Widget (window);
      tools->setLayout (new BoxLayout (Orientation::Horizontal,
                                       Alignment::Middle, 0, 6));
      b = new Button (tools, "Info");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Information, "Title", "This is an information message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Warn");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a warning message");
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      b = new Button (tools, "Ask");
      b->setCallback ([&]
      {
         auto dlg = new MessageDialog (this, MessageDialog::Type::Warning, "Title", "This is a question message", "Yes", "No", true);
         dlg->setCallback ([] (int result)
         {
            cout << "Dialog result: " << result << endl;
         });
      });
      std::string iconPath ("E:/Code4/nanofish/projects/qdemos/cinder/ciNanogui/assets/icons");
      std::vector<std::pair<int, std::string>> icons = NanoUtil::loadImageDirectory (getContext(), iconPath);
      new Label (window, "Image panel & scroll panel", "sans-bold");
      PopupButton * imagePanelBtn = new PopupButton (window, "Image Panel");
      imagePanelBtn->setIcon (ENTYPO_ICON_FOLDER);
      popup = imagePanelBtn->popup();
      VScrollPanel * vscroll = new VScrollPanel (popup);
      ImagePanel * imgPanel = new ImagePanel (vscroll);
      imgPanel->setImages (icons);
      popup->setFixedSize (ivec2 (245, 150));
      new Label (window, "Selected image", "sans-bold");
      auto img = new ImageView (window);
      img->setFixedSize (ivec2 (40, 40));
      img->setImage (icons[0].first);
      imgPanel->setCallback ([ &, img, imgPanel, imagePanelBtn] (int i)
      {
//.........这里部分代码省略.........
开发者ID:Reymenta-Visuals,项目名称:ciNanoGui,代码行数:101,代码来源:View.cpp

示例15: mousePressed

void Gui::mousePressed( int x, int y, MouseButtons mb )
{
	cout << "Ui::Gui::mousePressed( " << x << ", " << y << " )"  << endl;

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

  if ( pMouseChannelWidget != NULL ) {

    if ( pMousePressedWidget != NULL ) {
      pMousePressedWidget->onDestroy.disconnect( this );
    }

    pMousePressedWidget = pMouseChannelWidget;
    pMousePressedWidget->onDestroy.connect( this, &Gui::objectDestroyed );
		pMouseChannelWidget->mousePressed( x - pMouseChannelWidget->absoluteXPos(), y - pMouseChannelWidget->absoluteYPos(), mb );

  } else {

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

    setFocusedWidget( o );

    if ( ( o != NULL ) ) {

      if ( pMousePressedWidget != NULL ) {
        pMousePressedWidget->onDestroy.disconnect( this );
      }

			if ( pMouseDragWidget != NULL ) {
				pMouseDragWidget->onDestroy.disconnect( this );
			}

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

		} else {
			if ( pMouseDragWidget != NULL ) {
				pMouseDragWidget->onDestroy.disconnect( this );
				pMouseDragWidget = NULL;
			}
		}
  }
	pPressedX = x;
	pPressedY = y;
}
开发者ID:dcthe1,项目名称:GameUI,代码行数:62,代码来源:uigui.cpp


注:本文中的Popup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。