本文整理汇总了C++中Popup::setFixedSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Popup::setFixedSize方法的具体用法?C++ Popup::setFixedSize怎么用?C++ Popup::setFixedSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Popup
的用法示例。
在下文中一共展示了Popup::setFixedSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Label
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;
});
//.........这里部分代码省略.........
示例2: Label
ExampleApplication() : nanogui::Screen(Eigen::Vector2i(1024, 768), "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, 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 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(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::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->setImages(icons);
popup->setFixedSize(Vector2i(245, 150));
auto img_window = new Window(this, "Selected image");
img_window->setPosition(Vector2i(675, 15));
img_window->setLayout(new GroupLayout());
auto img = new ImageView(img_window);
img->setPolicy(ImageView::SizePolicy::Expand);
img->setFixedSize(Vector2i(300, 300));
img->setImage(icons[0].first);
imgPanel->setCallback([&, img, imgPanel, imagePanelBtn](int i) {
img->setImage(imgPanel->images()[i].first); cout << "Selected item " << i << endl;
});
auto img_cb = new CheckBox(img_window, "Expand",
[img](bool state) { if (state) img->setPolicy(ImageView::SizePolicy::Expand);
else img->setPolicy(ImageView::SizePolicy::Fixed); });
img_cb->setChecked(true);
//.........这里部分代码省略.........
示例3: create
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)
{
//.........这里部分代码省略.........
示例4: Label
ExampleApplication() : nanogui::Screen(Eigen::Vector2i(1024, 768), "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; });
/* Alternative construction notation using variadic template */
b = window->add<Button>("Styled", ENTYPO_ICON_ROCKET);
b->setBackgroundColor(Color(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 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(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::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->setImages(icons);
popup->setFixedSize(Vector2i(245, 150));
auto img_window = new Window(this, "Selected image");
img_window->setPosition(Vector2i(710, 15));
img_window->setLayout(new GroupLayout());
auto img = new ImageView(img_window);
img->setPolicy(ImageView::SizePolicy::Expand);
img->setFixedSize(Vector2i(275, 275));
img->setImage(icons[0].first);
imgPanel->setCallback([&, img, imgPanel, imagePanelBtn](int i) {
img->setImage(imgPanel->images()[i].first); cout << "Selected item " << i << endl;
});
auto img_cb = new CheckBox(img_window, "Expand",
[img](bool state) { if (state) img->setPolicy(ImageView::SizePolicy::Expand);
//.........这里部分代码省略.........
示例5: create
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));
//.........这里部分代码省略.........