void SpriteSizeCommand::onExecute(Context* context)
{
  const ContextReader reader(UIContext::instance()); // TODO use the context in sprite size command
  const Sprite* sprite(reader.sprite());

  // load the window widget
  base::UniquePtr<Window> window(app::load_widget<Window>("sprite_size.xml", "sprite_size"));
  m_widthPx = app::find_widget<Entry>(window, "width_px");
  m_heightPx = app::find_widget<Entry>(window, "height_px");
  m_widthPerc = app::find_widget<Entry>(window, "width_perc");
  m_heightPerc = app::find_widget<Entry>(window, "height_perc");
  m_lockRatio = app::find_widget<CheckBox>(window, "lock_ratio");
  ComboBox* method = app::find_widget<ComboBox>(window, "method");
  Widget* ok = app::find_widget<Widget>(window, "ok");

  m_widthPx->setTextf("%d", sprite->width());
  m_heightPx->setTextf("%d", sprite->height());

  m_lockRatio->Click.connect(Bind<void>(&SpriteSizeCommand::onLockRatioClick, this));
  m_widthPx->EntryChange.connect(Bind<void>(&SpriteSizeCommand::onWidthPxChange, this));
  m_heightPx->EntryChange.connect(Bind<void>(&SpriteSizeCommand::onHeightPxChange, this));
  m_widthPerc->EntryChange.connect(Bind<void>(&SpriteSizeCommand::onWidthPercChange, this));
  m_heightPerc->EntryChange.connect(Bind<void>(&SpriteSizeCommand::onHeightPercChange, this));

  method->addItem("Nearest-neighbor");
  method->addItem("Bilinear");
  method->setSelectedItemIndex(get_config_int("SpriteSize", "Method",
                                              doc::algorithm::RESIZE_METHOD_NEAREST_NEIGHBOR));

  window->remapWindow();
  window->centerWindow();

  load_window_pos(window, "SpriteSize");
  window->setVisible(true);
  window->openWindowInForeground();
  save_window_pos(window, "SpriteSize");

  if (window->getKiller() == ok) {
    int new_width = m_widthPx->getTextInt();
    int new_height = m_heightPx->getTextInt();
    ResizeMethod resize_method =
      (ResizeMethod)method->getSelectedItemIndex();

    set_config_int("SpriteSize", "Method", resize_method);

    {
      SpriteSizeJob job(reader, new_width, new_height, resize_method);
      job.startJob();
      job.waitJob();
    }

    ContextWriter writer(reader);
    update_screen_for_document(writer.document());
  }
}
Exemplo n.º 2
0
    void updateCameraList()
    {
        cameraSelectorComboBox.clear();
        cameraSelectorComboBox.addItem ("No camera", 1);
        cameraSelectorComboBox.addSeparator();

        StringArray cameras = CameraDevice::getAvailableDevices();

        for (int i = 0; i < cameras.size(); ++i)
            cameraSelectorComboBox.addItem (cameras[i], i + 2);
    }
Exemplo n.º 3
0
void CtrlrFontManager::fillCombo (ComboBox &comboToFill, const bool showOsFonts, const bool showBuiltInFonts, const bool showImportedFonts, const bool showJuceFonts)
{
	comboToFill.clear();
	int i = 0;

	if (showJuceFonts)
	{
		comboToFill.addSectionHeading ("OS Default fonts");
		for (i=0; i<juceFonts.size(); i++)
		{
			comboToFill.addItem (juceFonts[i].getTypefaceName(), allFontCount + i + 1);
		}

		allFontCount += i;
	}

	if (showBuiltInFonts)
	{
		comboToFill.addSectionHeading ("Ctrlr Built-In fonts");
		for (i=0; i<builtInFonts.size(); i++)
		{
			comboToFill.addItem (builtInFonts[i].getTypefaceName(), allFontCount + i + 1);
		}

		allFontCount += i;
	}

	if (showImportedFonts)
	{
	    reloadImportedFonts();

		comboToFill.addSectionHeading ("Imported fonts (from resources)");
		for (i=0; i<importedFonts.size(); i++)
		{
			comboToFill.addItem (importedFonts[i].getTypefaceName(), allFontCount + i + 1);
		}

		allFontCount += i;
	}

	if (showOsFonts)
	{
		comboToFill.addSectionHeading ("OS Fonts");
		for (i=0; i<osFonts.size(); i++)
		{
			comboToFill.addItem (osFonts[i].getTypefaceName(), allFontCount + i + 1);
		}

		allFontCount += i;
	}
}
void ObjectEditorWidget::onAddItemActivated()
{
    if (! mCurrentObject)
        return;

    Interaction::InputEvent event = mWidgetToEvent.value(sender());
    AddActionDialog dialog(event);
    dialog.exec();

    if (dialog.result() == QDialog::Accepted && dialog.selectedAction()) {
        Action* action = dialog.selectedAction();
        action->setSceneObject(mCurrentObject);
        action->setParent(mCurrentObject);
        mCurrentObject->appendEventAction(event, action);
        ComboBox *comboBox = qobject_cast<ComboBox*>(sender());
        if(comboBox) {
            comboBox->addItem(action->icon(), action->toString(), qVariantFromValue(static_cast<QObject*>(action)));
        }
    }
}
QDockWidget *TikzCommandInserter::getDockWidget(QWidget *parent)
{
	QDockWidget *tikzDock = new QDockWidget(parent);
	tikzDock->setObjectName("CommandsDock");
	tikzDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	tikzDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	tikzDock->setWindowTitle(m_tikzSections.title);
	tikzDock->setWhatsThis(tr("<p>This is a list of TikZ "
	                          "commands.  You can insert these commands in your code by "
	                          "clicking on them.  You can obtain more commands by "
	                          "changing the category in the combo box.</p>"));

	QAction *focusTikzDockAction = new QAction(parent);
	focusTikzDockAction->setShortcut(QKeySequence(tr("Alt+I")));
	tikzDock->addAction(focusTikzDockAction);
	connect(focusTikzDockAction, SIGNAL(triggered()), tikzDock, SLOT(setFocus()));

	QLabel *commandsComboLabel = new QLabel(tr("Category:"));
	ComboBox *commandsCombo = new ComboBox;
	commandsCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	QStackedWidget *commandsStack = new QStackedWidget;
	connect(commandsCombo, SIGNAL(currentIndexChanged(int)), commandsStack, SLOT(setCurrentIndex(int)));

	QListWidget *tikzListWidget = new QListWidget;
	addListWidgetItems(tikzListWidget, m_tikzSections, false); // don't add children
	tikzListWidget->setMouseTracking(true);
	connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//	connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
	commandsCombo->addItem(tr("General"));
	commandsStack->addWidget(tikzListWidget);

	for (int i = 0; i < m_tikzSections.children.size(); ++i)
	{
		QListWidget *tikzListWidget = new QListWidget;
		addListWidgetItems(tikzListWidget, m_tikzSections.children.at(i));
		tikzListWidget->setMouseTracking(true);
		connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//		connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));

		QString comboItemText = m_tikzSections.children.at(i).title;
		commandsCombo->addItem(comboItemText.remove('&'));
		commandsStack->addWidget(tikzListWidget);
	}

	QGridLayout *tikzLayout = new QGridLayout;
	tikzLayout->addWidget(commandsComboLabel, 0, 0);
	tikzLayout->addWidget(commandsCombo, 0, 1);
	tikzLayout->addWidget(commandsStack, 1, 0, 1, 2);
	tikzLayout->setMargin(5);

	TikzCommandWidget *tikzWidget = new TikzCommandWidget;
	tikzWidget->setLayout(tikzLayout);
	tikzDock->setWidget(tikzWidget);
	tikzDock->setFocusProxy(commandsCombo);

	return tikzDock;
}
Exemplo n.º 6
0
void UploadWindow::handleCommand(int res)
{
	if (res == 1)
	{
		if (!smugMug.isUploading() || AlertWindow::showOkCancelBox(AlertWindow::InfoIcon, "Komodo Drop", 
			"There is an upload in progress, quit anyway?") == 1)
		{
			JUCEApplication::quit();
		}
	}
	else if (res == 2)
	{
		Settings::getInstance()->showSettingsDialog();
	}
	else if (res == 3)
	{
		AlertWindow::showMessageBox(AlertWindow::InfoIcon, "Komodo Drop " + JUCEApplication::getInstance()->getApplicationVersion(), 
			"Created By: Roland Rabien ([email protected])\nBased on JUCE (www.rawmaterialsoftware.com)");
	}
	else if (res == 4)
	{
		setVisible(!isVisible());
	}
	else if (res == 5)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		OwnedArray<Album> albums;
		smugMug.getAlbumList(albums);
		if (albums.size() > 0)
		{
			ComboBox* album = new ComboBox("");
			album->setSize(300, 26);
			album->setVisible(true);

			for (int i = 0; i < albums.size(); i++)
				album->addItem(albums[i]->getDisplayTitle(), i + 1);
			album->setSelectedItemIndex(0);
			
			AlertWindow aw("Komodo Drop", "Delete album:", AlertWindow::InfoIcon);
			aw.addCustomComponent(album);
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1)
			{
				smugMug.deleteAlbum(albums[album->getSelectedId() - 1]->id);
			}
			delete album;
		}
	}
	else if (res == 6)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		OwnedArray<Category> categories;
		smugMug.getCategoryList(categories);
		if (categories.size())
		{
			ComboBox* cats = new ComboBox("");
			cats->setSize(300, 26);
			cats->setVisible(true);

			for (int i = 0; i < categories.size(); i++)
				cats->addItem(categories[i]->title, categories[i]->id + 1);
			cats->setSelectedItemIndex(0);
			
			AlertWindow aw("Komodo Drop", "Delete category:", AlertWindow::InfoIcon);
			aw.addCustomComponent(cats);
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1)
			{
				smugMug.deleteCategory(cats->getSelectedId() - 1);
			}
			delete cats;
		}
	}
	else if (res == 7)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		OwnedArray<Category> categories;
		smugMug.getCategoryList(categories);

		OwnedArray<SubCategory> subCategories;
		smugMug.getSubCategoryList(subCategories);

		if (subCategories.size())
		{
			ComboBox* cats = new ComboBox("");
			cats->setSize(300, 26);
			cats->setVisible(true);

			for (int i = 0; i < subCategories.size(); i++)
			{
				int j;
				for (j = 0; j < categories.size(); j++)
				{
					if (categories[j]->id == subCategories[i]->parentId)
						break;
				}
				cats->addItem(categories[j]->title + " >> " + subCategories[i]->title, subCategories[i]->id + 1);
			}
			cats->setSelectedItemIndex(0);
			
			AlertWindow aw("Komodo Drop", "Delete sub category:", AlertWindow::InfoIcon);
			aw.addCustomComponent(cats);
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1)
			{
				smugMug.deleteSubCategory(cats->getSelectedId() - 1);
			}
			delete cats;
		}
	}
	else if (res == 8)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

			AlertWindow aw("Komodo Drop", "Create category:", AlertWindow::InfoIcon);
			aw.addTextEditor("name", "", "category name:");
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1 && aw.getTextEditorContents("name").isNotEmpty())
			{
				smugMug.createCategory(aw.getTextEditorContents("name"));
			}
	}
	else if (res == 9)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		OwnedArray<Category> categories;
		smugMug.getCategoryList(categories);

		if (categories.size())
		{
			ComboBox* cats = new ComboBox("");
			cats->setSize(300, 26);
			cats->setVisible(true);

			for (int i = 0; i < categories.size(); i++)
				cats->addItem(categories[i]->title, categories[i]->id + 1);
			cats->setSelectedItemIndex(0);
			
			AlertWindow aw("Komodo Drop", "Create sub category:", AlertWindow::InfoIcon);
			aw.addCustomComponent(cats);
			aw.addTextEditor("name", "", "sub category name:");
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1 && aw.getTextEditorContents("name").isNotEmpty())
			{
				smugMug.createSubCategory(cats->getSelectedId() - 1, aw.getTextEditorContents("name"));
			}
			delete cats;
		}
	}
	else if (res == 10)
	{
		smugMug.cancelUploads();
	}
	else if (res == 11)
	{
		FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory));
		if (fc.browseForMultipleFilesToOpen())
		{
			const Array<File>& files = fc.getResults();
			StringArray names;

			for (int i = 0; i < files.size(); i++)
				names.add(files[i].getFullPathName());

			filesDropped(names, 0, 0);
		}
	}
	else if (res == 12)
	{
		FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory));
		if (fc.browseForDirectory())
		{
			File dir = fc.getResult();

			Array<File> files;
			StringArray names;
			dir.findChildFiles(files, File::findFiles, false);

			for (int i = 0; i < files.size(); i++)
				names.add(files[i].getFullPathName());

			if (names.size())
				filesDropped(names, 0, 0);
		}
	}
	else if (res == 13)
	{
		FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory));
		if (fc.browseForDirectory())
		{
			File dir = fc.getResult();

			Array<File> files;
			StringArray names;
			dir.findChildFiles(files, File::findFiles, true);

			for (int i = 0; i < files.size(); i++)
				names.add(files[i].getFullPathName());

			if (names.size())
				filesDropped(names, 0, 0);
		}
	}
	else if (res == 19)
	{
		FileChooser fc("Komodo Drop", File::getSpecialLocation(File::userDocumentsDirectory));
		if (fc.browseForDirectory())
		{
			File dir = fc.getResult();
			
			Array<File> folders;
			dir.findChildFiles(folders, File::findDirectories, false);
			
			for (int i = 0; i < folders.size(); i++)
			{
				Array<File> files;
				folders[i].findChildFiles(files, File::findFiles, true);
				
				StringArray names;
				for (int j = 0; j < files.size(); j++)
					names.add(files[j].getFullPathName());
				
				if (names.size())
					filesDropped(names, 0, 0);
			}
		}		
	}
	else if (res == 14)
	{
		smugMug.showLogFile();
	}
	else if (res == 15)
	{
		smugMug.clearLogFile();
	}
	else if (res == 16)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		OwnedArray<Album> albums;
		smugMug.getAlbumList(albums);
		if (albums.size() > 0)
		{
			ComboBox* album = new ComboBox("");
			album->setSize(300, 26);
			album->setVisible(true);

			for (int i = 0; i < albums.size(); i++)
				album->addItem(albums[i]->getDisplayTitle(), i + 1);
			album->setSelectedItemIndex(0);
			
			AlertWindow aw("Komodo Drop", "Delete duplicate images from album:", AlertWindow::InfoIcon);
			aw.addCustomComponent(album);
			aw.addButton("ok", 1);
			aw.addButton("cancel", 2);

			if (aw.runModalLoop() == 1)
			{
				smugMug.deleteDuplicates(albums[album->getSelectedId() - 1]->id);
			}
			delete album;
		}
	}
	else if (res == 17)
	{
		smugMug.showQueue();
	}
	else if (res == 18)
	{
		if (!smugMug.isLoggedIn())
			smugMug.login(Settings::getInstance()->email, Settings::getInstance()->password);

		smugMug.showTopPhotos();
	}
}
Exemplo n.º 7
0
void OptionsCommand::onExecute(Context* context)
{
  // Load the window widget
  UniquePtr<Window> window(app::load_widget<Window>("options.xml", "options"));
  Widget* check_smooth = app::find_widget<Widget>(window, "smooth");
  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);

  // 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->setSelectedItem((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", "MoveClick2", move_click2->isSelected());
    set_config_bool("Options", "DrawClick2", draw_click2->isSelected());

    RenderEngine::setCheckedBgType((RenderEngine::CheckedBgType)m_checked_bg->getSelectedItem());
    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();
  }
}
Exemplo n.º 8
0
 void addLookAndFeel (LookAndFeel* laf, const String& name)
 {
     lookAndFeels.add (laf);
     lafBox.addItem (name, lafBox.getNumItems() + 1);
 }
Exemplo n.º 9
0
int main(int argc, char * argv[])
{
  Font *font(FontFactory::create(
        (unsigned char*)_binary_sans_set_bin_start,
        (unsigned char*)_binary_sans_map_bin_start));
  TextAreaFactory::setFont(font);
  //TextAreaFactory::usePaletteData((const char*)_binary_vera_pal_bin_start, 32);
  Keyboard * keyBoard = new Keyboard();
  ScrollPane scrollPane;
  keyBoard->setTopLevel(&scrollPane);
#if 1
  TextField * tf = new TextField("Enter the value here. This line is too big to fit in");
  TextField * passwd = new TextField(std::string());
  RichTextArea * rich = (RichTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_RICH);
  Button * goBtn = new Button("Go");
  rich->appendText("This is some long text ");
  passwd->setSize(60,18);
  
  scrollPane.setTopLevel();
  scrollPane.add(rich);
  scrollPane.add(passwd);
  scrollPane.add(goBtn);
  scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height());
  scrollPane.add(tf);
  scrollPane.setScrollIncrement(13);

#else
  RichTextArea * rich = (RichTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_RICH);
  TextArea * t = TextAreaFactory::create();
  EditableTextArea * t2 = (EditableTextArea*)TextAreaFactory::create(TextAreaFactory::TXT_EDIT);
  // t2->setBackgroundColor(Color(31,31,0));

  
  ScrollPane * subPane = new ScrollPane;
  subPane->add(t2);
  subPane->setTopLevel(false);
  subPane->setSize(Canvas::instance().width(),Canvas::instance().height());
  subPane->setScrollIncrement(t2->font().height());
  subPane->setStretchChildren(true);
  
  
  ComboBox * emptyCombo = new ComboBox();
  ComboBox * oneValCombo = new ComboBox();
  ComboBox * combo = new ComboBox();
  combo->setSize(60, 18);
  ComboBox * combo2 = new ComboBox();
  combo2->setSize(90, 18);
  
  std::string str("Hello World");
  Button * b1 = new Button(str);

  str = "Combo box!";
  oneValCombo->addItem(str);
  combo->addItem(str);
  combo2->addItem(str);
  combo2->addItem(str);
  str = "Another One - with very wide text";
  Button * b2 = new Button(str);
  combo->addItem(str);
  combo2->addItem(str);
  combo2->addItem(str);
  str = "Three- wide, but fixed width";
  Button * b3 = new Button(str);
  b3->setSize(60, 18);
  combo2->addItem(str);
  combo2->addItem(str);
  str = "Go";
  Button * b4 = new Button(str);
  //b4->setSize(6*13, 10);
  str = "Last one!";
  Button * b5 = new Button(str);
  combo->addItem(str);
  combo2->addItem(str);
  combo2->addItem(str);

  t2->setListener(keyBoard);
  
  str = "A text field that has a very, very long and pointless string";
  TextField * tf1 = new TextField(str);
  tf1->setSize(160, 18);
  tf1->setListener(keyBoard);
  combo2->addItem(str);

  TextArea * rbLabel = TextAreaFactory::create();
  str = "Radio button label.";
  rbLabel->appendText(str);

  TextArea * cbLabel = TextAreaFactory::create();
  str = "CheckBox label.";
  cbLabel->appendText(str);

  RadioButton * rb = new RadioButton();
  RadioButton * rb2 = new RadioButton();
  RadioButton * rb3 = new RadioButton();
  CheckBox * cb = new CheckBox();
  ButtonGroup bg;
  bg.add(rb);
  bg.add(rb2);
  bg.add(rb3);
  keyBoard->setTopLevel(&scrollPane);
  scrollPane.setTopLevel();
  scrollPane.add(rich);
  scrollPane.add(t);
  scrollPane.add(b1);
  scrollPane.add(b2);
 
  scrollPane.add(b3);
  scrollPane.add(tf1);
  scrollPane.add(b4);
  scrollPane.add(emptyCombo);
  scrollPane.add(oneValCombo);
  scrollPane.add(combo2);
  scrollPane.add(rb);
  scrollPane.add(rb2);
  scrollPane.add(rb3);
  scrollPane.add(rbLabel);
  scrollPane.add(cb);
  scrollPane.add(cbLabel);
  scrollPane.add(subPane);
  scrollPane.add(combo);
  scrollPane.add(b5);
  
  scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height());
  scrollPane.setScrollIncrement(t->font().height());

  std::string richText1("This is normal text. ");
  std::string richText2("This is a link.");
  std::string richText3("Longer text, but still normal. ");
  std::string richText4("Normal text. ");
  std::string richText5("Link text. ");
  rich->appendText(richText1);
  rich->insertNewline();
  rich->appendText(richText1);
  rich->appendText(richText1);
  rich->appendText(richText3);
  rich->appendText(richText4);
  rich->addLink("www.link1.com");
  rich->appendText(richText2);
  rich->endLink();
  rich->appendText(richText3);
  rich->appendText(richText1);
  rich->addLink("www.link2.com");
  rich->appendText(richText5);
  rich->endLink();


  std::string s(_binary_test_map_bin_start, 1000);
  t->appendText(s);
  std::string s2(&_binary_test_map_bin_start[1200], 1300);
  t2->appendText(s2);
  subPane->setSize(t2->width(), 100);
  t2->setParentScroller(subPane);
#endif
  scrollPane.setLocation(0,0);
  scrollPane.setSize(Canvas::instance().width(),Canvas::instance().height());

  bool needsPainting = true;
  while(true)
  {
    swiWaitForVBlank();
    scanKeys();
    u16 keys = keysDownRepeat();
    //u16 keys = keysHeld();
    if (keys & KEY_UP) 
    {
      scrollPane.up();
      scrollPane.up();
      needsPainting = true;
    }
    if (keys & KEY_DOWN) 
    {
      scrollPane.down();
      scrollPane.down();
      needsPainting = true;
    }
    if (keys & KEY_X)
    {
      //printf("%s\n",t2->asString().c_str());
      break;
    }

    if (keys & KEY_Y) {
      scrollPane.setVisible(not scrollPane.visible());
      keyBoard->setVisible(not keyBoard->visible());
      needsPainting = true;
    }

    if (keys & KEY_TOUCH)
    {
      touchPosition tp;
      touchRead(&tp);
      Stylus stylus;
      stylus.update(Stylus::DOWN, true, tp.px, tp.py+SCREEN_HEIGHT);
      needsPainting = keyBoard->dirty();
      if (not needsPainting)
        needsPainting = scrollPane.dirty();
    }

    needsPainting |= keyBoard->tick();
    if (needsPainting)
    {
      scrollPane.paint(scrollPane.preferredSize());
      keyBoard->paint(scrollPane.preferredSize());
      Canvas::instance().endPaint();
    }
    needsPainting = false;
  }
  delete keyBoard;
}
Exemplo n.º 10
0
MainPanel::MainPanel()
	: TopLevelResizableLayout (this)
  , m_lastTypeId (0)
{
  setOpaque (true);

  const int w = 512;
  const int h = 512 + 102;
  const int gap = 4;
  const int x0 = 4;

  m_listeners.add (this);

  int x;
  int y = 4;

  x = x0;

  {
    ComboBox* c = new ComboBox;
    c->setBounds (x, y, 160, 24);
    addToLayout (c, anchorTopLeft);
    addAndMakeVisible (c);
    buildFamilyMenu (c);
    m_menuFamily = c;    
    c->addListener (this);
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap;

  {
    ComboBox* c = new ComboBox;
    c->setBounds (x, y, 120, 24);
    addToLayout (c, anchorTopLeft);
    addAndMakeVisible (c);
    buildFamilyMenu (c);
    m_menuType = c;    
    c->addListener (this);
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap;

  {
    ComboBox* c = new ComboBox;
    c->setBounds (x, y, 120, 24);
    c->addItem ("Amen Break", 1);
    c->addItem ("Sine Wave (440Hz)", 2);
    c->addItem ("White Noise", 3);
    c->addItem ("Pink Noise", 4);
    addToLayout (c, anchorTopLeft);
    addAndMakeVisible (c);
    m_menuAudio = c;    
    c->addListener (this);
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap;

  {
    CpuMeter* c = new CpuMeter (MainApp::getInstance().getAudioOutput().getAudioDeviceManager());
    c->setBounds (w - 80 - gap, y, 80, 24);
    addToLayout (c, anchorTopRight);
    addAndMakeVisible (c);
  }

  y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap;
  x = x0;

  x = w - gap;

  const int hfc = 80;

  {
    Slider* c = new Slider;
    c->setBounds (x - 20, y, 20, hfc + gap + 24);
    c->setSliderStyle (Slider::LinearVertical);
    c->setTextBoxStyle (Slider::NoTextBox, true, 0, 0);
    c->setRange (-40, 12);
    c->setValue (0);
    addAndMakeVisible (c);
    addToLayout (c, anchorTopRight);
    c->addListener (this);
    m_volumeSlider = c;
    
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getX() - gap;
 
  {
    Slider* c = new Slider;
    c->setBounds (x - 20, y, 20, hfc + gap + 24);
    c->setSliderStyle (Slider::LinearVertical);
    c->setTextBoxStyle (Slider::NoTextBox, true, 0, 0);
    c->setRange (-2, 2);
    c->setValue (0);
    addAndMakeVisible (c);
    addToLayout (c, anchorTopRight);
    c->addListener (this);
    m_tempoSlider = c;
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getX() - gap;
 
  int x1 = x - x0 + gap;

  {
    FilterControls* c = new FilterControls (m_listeners);
    c->setBounds (x0, y, x - x0, hfc);
    addToLayout (c, anchorTopLeft, anchorTopRight);
    addAndMakeVisible (c);
    m_listeners.add (c);
  }

  y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap;
  x = x0;

  {
    ComboBox* c = new ComboBox;
    c->setBounds (x, y, 120, 24);
    c->addItem ("Direct Form I", 1);
    c->addItem ("Direct Form II", 2);
    c->addItem ("Transposed Direct Form I", 3);
    c->addItem ("Transposed Direct Form II", 4);
    c->addItem ("Lattice Form", 5); c->setItemEnabled (5, false);
    c->addItem ("State Variable", 6); c->setItemEnabled (6, false);
    c->setSelectedId (1);
    addToLayout (c, anchorTopLeft);
    addAndMakeVisible (c);
    m_menuStateType = c;    
    c->addListener (this);
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap;

  {
    ComboBox* c = new ComboBox;
    c->setBounds (x, y, 200, 24);
    c->addItem ("Parameter Smoothing", 1);
    c->addItem ("Pole/Zero Interpolation", 2); c->setItemEnabled (2, false);
    c->addItem ("Coefficient Interpolation", 3); c->setItemEnabled (3, false);
    c->addItem ("No Smoothing", 4);
    c->setSelectedId (1);
    addToLayout (c, anchorTopLeft);
    addAndMakeVisible (c);
    m_menuSmoothing = c;    
    c->addListener (this);
  }

  x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap;

  {
    m_resetButton = new TextButton ("Reset");
    m_resetButton->setBounds (x1 - 60, y, 60, 24);
    m_resetButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight);
    addToLayout (m_resetButton, anchorTopRight);
    addAndMakeVisible (m_resetButton);
    m_resetButton->addListener (this);
  }

  y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap;
  x = x0;

  const Rectangle<int> r (x, y, w - (x + gap), h - (y + gap));
  createCharts (r);

	setSize (w, h);

  setMinimumSize (256, 256);

	activateLayout();

  m_menuFamily->setSelectedId (1);
  m_menuAudio->setSelectedId (1);
}
Exemplo n.º 11
0
		void UITestGameState::init(GameContainer* container, StateBasedGame* game) {
			Panel* root = new Panel();
			root->setSize(container->getWidth(), container->getHeight());
			root->setShowBorder(false);

			rightPanel = new ScrollPanel();
			rightPanel->setLocation(50, 50);
			rightPanel->setWidth(container->getWidth()/2);
			rightPanel->setHeight(container->getHeight()-100);
			rightPanel->m_layout = ScrollPanel::LAYOUT_FLOW;

			Label* label2 = new Label("A Text Label #2");
			label2->setMargin(10);
			rightPanel->add(label2);

			TextField* textField2 = new TextField();
			textField2->setMargin(10);
			textField2->setSize(200, 30);
			textField2->setText("A Text Field #2");
			rightPanel->add(textField2);

			Label* label3 = new Label("A Text Label #2");
			label3->setMargin(10);
			rightPanel->add(label3);

			ComboBox* comboBox = new ComboBox();
			comboBox->setMargin(10);
			comboBox->setSize(200, 30);
			comboBox->setItemChangedEvent((void*) &itemChangedEvent);
				ComboBoxItem* comboItemOne = new ComboBoxItem();
				comboItemOne->setText("Item One");
				comboBox->addItem(comboItemOne);
				ComboBoxItem* comboItemTwo = new ComboBoxItem();
				comboItemTwo->setText("Item Two");
				comboBox->addItem(comboItemTwo);
			rightPanel->add(comboBox);

			Label* label4 = new Label("A Text Label #3");
			label4->setMargin(10);
			rightPanel->add(label4);

			CheckBox* checkBox = new CheckBox();
			checkBox->setMargin(10);
			checkBox->setChecked(false);
			checkBox->setStateChangedEvent((void*) &stateChangedEvent);
			rightPanel->add(checkBox);

			CheckBox* checkBox2 = new CheckBox();
			checkBox2->setMargin(10);
			checkBox2->setChecked(true);
			rightPanel->add(checkBox2);

			Label* label5 = new Label("A Text Label four is big");
			label5->setMargin(10);
			rightPanel->add(label5);

			Button* button = new Button();
			button->setText("Click me!");
			button->setSize(50, 50);
			button->setEvent((void*) &buttonClickEvent);
			button->setMargin(10);
			rightPanel->add(button);


			root->add(rightPanel);

			m_rootUIComponent = root;
		}