示例#1
0
/**
 * Create an layout containing a label and a check box widget.
 * The check box will be used to set the edit box #MAW_EDIT_BOX_MODE property.
 * Platform: iOS.
 */
HorizontalLayout* MainScreen::createModePropertyLayout()
{
	if (!isIOS())
	{
		return NULL;
	}

	HorizontalLayout* hLayout = new HorizontalLayout();
	hLayout->wrapContentVertically();

	Label* label = new Label();
	label->setText("Single line");
	hLayout->addChild(label);

	mSingleLineCheckBox = new CheckBox();
	mSingleLineCheckBox->setState(true);

	HorizontalLayout* spacer = new HorizontalLayout();
	int spacerWidth = this->getWidth() - label->getWidth() -
		mSingleLineCheckBox->getWidth();
	spacer->setWidth(spacerWidth);

	hLayout->addChild(spacer);
	hLayout->addChild(mSingleLineCheckBox);

	return hLayout;
}
示例#2
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout()
{
	// Create and add the main layout to the screen.
	mMainLayout = new VerticalLayout();
	mMainLayout->setBackgroundColor(0x220099);
	Screen::setMainWidget(mMainLayout);

	mGenderRadioGroup = new RadioGroup();
	mMainLayout->addChild(mGenderRadioGroup);
	mFemaleButton = new RadioButton();
	mFemaleButton->setTextColor(0xFF0000);
	mFemaleButton->setText("Female");
	mMaleButton = new RadioButton();
	mMaleButton->setText("Male");
	mMaleButton->setTextColor(0x0000FF);
	mUnknownButton = new RadioButton();
	mUnknownButton->setText("Alien");
	mUnknownButton->setTextColor(0x00FF00);
	mGenderRadioGroup->addView(mFemaleButton);
	mGenderRadioGroup->addView(mMaleButton);
	mGenderRadioGroup->addView(mUnknownButton);
	mClearGenderSelection = new Button();
	mClearGenderSelection->setText("Clear gender selection");
	mMainLayout->addChild(mClearGenderSelection);
	HorizontalLayout* getGenderLayout = new HorizontalLayout();
	getGenderLayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mMainLayout->addChild(getGenderLayout);
	mGetGenderSelection = new Button();
	mGetGenderSelection->setText("Get the gender selection");
	getGenderLayout->addChild(mGetGenderSelection);
	mGenderSelectionLabel = new Label();
	mGenderSelectionLabel->fillSpaceHorizontally();
	getGenderLayout->addChild(mGenderSelectionLabel);

	HorizontalLayout* getCheckedLayout = new HorizontalLayout();
	getCheckedLayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mMainLayout->addChild(getCheckedLayout);
	mGetGenderChecked = new Button();
	mGetGenderChecked->setText("Get male checked state");
	getCheckedLayout->addChild(mGetGenderChecked);
	mGenderCheckedLabel = new Label();
	mGenderCheckedLabel->fillSpaceHorizontally();
	getCheckedLayout->addChild(mGenderCheckedLabel);

	mToggleMaleButton = new Button();
	mToggleMaleButton->setText("Toggle(check) Male button");
	mMainLayout->addChild(mToggleMaleButton);

	mGenderSelectionEvent = new Label();
	mGenderSelectionEvent->setText("Radio Group event");
	mMainLayout->addChild(mGenderSelectionEvent);
	mRadioButtonSelectEvent = new Label();
	mRadioButtonSelectEvent->setText("Radio Button select event");
	mMainLayout->addChild(mRadioButtonSelectEvent);
	mradioButtonUnselectEvent = new Label();
	mradioButtonUnselectEvent->setText("Radio Button unselect event");
	mMainLayout->addChild(mradioButtonUnselectEvent);

}
示例#3
0
void SettingsScreen::createListViewItemEditModeLayout(VerticalLayout* listViewItemPropertiesVerticalLayout)
{
	HorizontalLayout* editModeLayout = new HorizontalLayout();
	editModeLayout->wrapContentVertically();
	mListViewItemEditModeCheckbox = new CheckBox();
	mListViewItemEditModeCheckbox->setState(false);
	Label* editModeLabel = new Label();
	editModeLabel->setText("Edit mode");
	editModeLayout->addChild(mListViewItemEditModeCheckbox);
	editModeLayout->addChild(editModeLabel);
	listViewItemPropertiesVerticalLayout->addChild(editModeLayout);
}
示例#4
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout()
{
	// Create and add the main layout to the screen.
	mMainLayout = new VerticalLayout();
	mMainLayout->setBackgroundColor(MAIN_LAYOUT_COLOR);
	Screen::setMainWidget(mMainLayout);

	// Create the "BUY" section.
	VerticalLayout* buyLayout = new VerticalLayout();
	buyLayout->wrapContentVertically();
	mMainLayout->addChild(buyLayout);
	Label* info = new Label();
	info->setText("Items for sale");
	info->setFontColor(INFO_LABELS_COLOR);
	buyLayout->addChild(info);

	// Add the list of available items for sale along with check boxes.
	for (int i=0; i < mProductNamesList.size(); i++)
	{
		HorizontalLayout* itemLayout = new HorizontalLayout();
		itemLayout->wrapContentVertically();
		CheckBox* itemCheckBox = new CheckBox();
		itemLayout->addChild(itemCheckBox);
		mItemsCheckBoxes.add(itemCheckBox);
		Label* itemId = new Label();
		itemId->setText(mProductNamesList[i]);
		itemId->setFontColor(ITEMS_COLOR);
		itemLayout->addChild(itemId);
		buyLayout->addChild(itemLayout);
	}

	// Use buy button to purchase the checked product it from the "BUY" section.
	mBuyButton = new Button();
	mBuyButton->setText("BUY");
	mMainLayout->addChild(mBuyButton);

	// Add a small break line between the two sections.
	HorizontalLayout* lineLayout = new HorizontalLayout();
	lineLayout->setHeight(BREAKLINE_HEIGHT);
	lineLayout->setBackgroundColor(BREAKLINE_COLOR);
	mMainLayout->addChild(lineLayout);

	// Create the "HISTORY" section.
	VerticalLayout* purchasedLayout = new VerticalLayout();
	Label* purchasedLabel = new Label();
	purchasedLabel->setText("Items you own");
	purchasedLabel->setFontColor(INFO_LABELS_COLOR);
	purchasedLayout->addChild(purchasedLabel);
	mPurchasedItemsList = new ListView();
	purchasedLayout->addChild(mPurchasedItemsList);
	mMainLayout->addChild(purchasedLayout);

}
示例#5
0
void SettingsScreen::createListViewItemUnhighlightedAnimationLayout(VerticalLayout* listViewItemPropertiesVerticalLayout)
{
	HorizontalLayout* unhighlightedAnimationLayout = new HorizontalLayout();
	unhighlightedAnimationLayout->wrapContentVertically();
	mListViewItemUnhighlightedCheckbox = new CheckBox();
	mListViewItemUnhighlightedCheckbox->setState(false);
	Label* unhighlightedAnimationLabel = new Label();
	unhighlightedAnimationLabel->setText("Unhighlighted animation");
	unhighlightedAnimationLayout->addChild(mListViewItemUnhighlightedCheckbox);
	unhighlightedAnimationLayout->addChild(unhighlightedAnimationLabel);
	listViewItemPropertiesVerticalLayout->addChild(unhighlightedAnimationLayout);
}
示例#6
0
void SettingsScreen::createListViewItemDeleteButtonTextLayout(VerticalLayout* listViewItemPropertiesVerticalLayout)
{
	HorizontalLayout* currentListViewItemDeleteButtonLayout = new HorizontalLayout();
	currentListViewItemDeleteButtonLayout->wrapContentVertically();
	mSetListViewItemDeleteTitleButton = new Button();
	mSetListViewItemDeleteTitleButton->setText("Set delete");
	mSetListViewItemDeleteTitleButton->fillSpaceHorizontally();
	currentListViewItemDeleteButtonLayout->addChild(mSetListViewItemDeleteTitleButton);
	mSetListViewItemDeleteTitleEditBox = new EditBox();
	mSetListViewItemDeleteTitleEditBox->fillSpaceHorizontally();
	currentListViewItemDeleteButtonLayout->addChild(mSetListViewItemDeleteTitleEditBox);
	listViewItemPropertiesVerticalLayout->addChild(currentListViewItemDeleteButtonLayout);
}
示例#7
0
/**
 * Create a new row for settings.
 * It contains a check box/button and a label.
 */
HorizontalLayout* MainScreen::createRow(Widget* check, Label* label)
{
	HorizontalLayout* hLayout = new HorizontalLayout();
	if ( check != NULL )
	{
		hLayout->addChild(check);
		HorizontalLayout* space = new HorizontalLayout();
		space->setWidth(10);
		hLayout->addChild(space);
	}
	hLayout->addChild(label);
	return hLayout;
}
示例#8
0
void SettingsScreen::createListViewItemFontColorLayout(VerticalLayout* listViewItemPropertiesVerticalLayout)
{
	HorizontalLayout* currentListViewItemFontColorLayout = new HorizontalLayout();
	currentListViewItemFontColorLayout->wrapContentVertically();
	mSetListViewItemFontColorButton = new Button();
	mSetListViewItemFontColorButton->setText("Set font color");
	mSetListViewItemFontColorButton->fillSpaceHorizontally();
	currentListViewItemFontColorLayout->addChild(mSetListViewItemFontColorButton);
	mSetListViewItemFontColorEditBox = new EditBox();
	mSetListViewItemFontColorEditBox->fillSpaceHorizontally();
	mSetListViewItemFontColorEditBox->setPlaceholder("ex: 0xFF0000");
	currentListViewItemFontColorLayout->addChild(mSetListViewItemFontColorEditBox);
	listViewItemPropertiesVerticalLayout->addChild(currentListViewItemFontColorLayout);
}
示例#9
0
void SettingsScreen::createListViewItemFontSizeLayout(VerticalLayout* listViewItemPropertiesVerticalLayout)
{
	HorizontalLayout* currentListViewItemFontSizeLayout = new HorizontalLayout();
	currentListViewItemFontSizeLayout->wrapContentVertically();
	mSetListViewItemFontSizeButton = new Button();
	mSetListViewItemFontSizeButton->setText("Set font size");
	mSetListViewItemFontSizeButton->fillSpaceHorizontally();
	currentListViewItemFontSizeLayout->addChild(mSetListViewItemFontSizeButton);
	mSetListViewItemFontSizeEditBox = new EditBox();
	mSetListViewItemFontSizeEditBox->fillSpaceHorizontally();
	mSetListViewItemFontSizeEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC);
	currentListViewItemFontSizeLayout->addChild(mSetListViewItemFontSizeEditBox);
	listViewItemPropertiesVerticalLayout->addChild(currentListViewItemFontSizeLayout);
}
示例#10
0
/**
 * Create a new row for settings.
 * It contains two widgets separated by a spacer.
 */
HorizontalLayout* SettingsScreen::createRow(
	Widget* firstWidget,
	Widget* secondWidget)
{
	HorizontalLayout* hLayout = new HorizontalLayout();
	if ( firstWidget != NULL )
	{
		hLayout->addChild(firstWidget);
		HorizontalLayout* space = new HorizontalLayout();
		space->setWidth(10);
		hLayout->addChild(space);
	}
	hLayout->addChild(secondWidget);
	return hLayout;
}
/**
 * Creates the set button text layout.
 */
void ButtonSettingsLayout::createSetButtonTextLayout()
{
	HorizontalLayout* setTextHorizontalLayout = new HorizontalLayout();
	setTextHorizontalLayout->setHeight(PROPERTY_LINE_HEIGHT);
	setTextButton = new Button();
	setTextButton->setText("Set button text:");
	setTextButton->fillSpaceHorizontally();
	setTextHorizontalLayout->addChild(setTextButton);

	setTextEditBox = new EditBox();
	setTextEditBox->setPlaceholder("Button text");
	setTextEditBox->fillSpaceHorizontally();
	setTextHorizontalLayout->addChild(setTextEditBox);

	this->addChild(setTextHorizontalLayout);
}
/**
 * Creates the get button text layout.
 */
void ButtonSettingsLayout::createGetButtonTextLayout()
{
	HorizontalLayout* getTextHorizontalLayout = new HorizontalLayout();
	getTextHorizontalLayout->setHeight(PROPERTY_LINE_HEIGHT);
	getTextButton = new Button();
	getTextButton->setText("Get button text:");
	getTextButton->fillSpaceHorizontally();
	getTextHorizontalLayout->addChild(getTextButton);

	getTextLabel = new Label();
	getTextLabel->setText("No text yet");
	getTextLabel->fillSpaceHorizontally();
	getTextHorizontalLayout->addChild(getTextLabel);

	this->addChild(getTextHorizontalLayout);
}
/**
 * Creates the get button text layout.
 */
void EditBoxSettingsLayout::createGetEditBoxTextLayout()
{
	HorizontalLayout* getTextHorizontalLayout = new HorizontalLayout();
	getTextHorizontalLayout->setHeight(PROPERTY_LINE_HEIGHT);
	getTextButton = new Button();
	getTextButton->setText("Get edit box text:");
	getTextButton->fillSpaceHorizontally();
	getTextHorizontalLayout->addChild(getTextButton);

	getTextLabel = new Label();
	getTextLabel->setText("No text yet");
	getTextLabel->fillSpaceHorizontally();
	getTextHorizontalLayout->addChild(getTextLabel);

	mEditBoxListView->addChild(getTextHorizontalLayout);
}
/**
 * Creates the set edit box placeholder text layout.
 */
void EditBoxSettingsLayout::createSetPlaceholderLayout()
{
	HorizontalLayout* getPlaceholderHorizontalLayout = new HorizontalLayout();
	getPlaceholderHorizontalLayout->setHeight(PROPERTY_LINE_HEIGHT);
	setPlaceholderButton = new Button();
	setPlaceholderButton->setText("Set placeholder text:");
	setPlaceholderButton->fillSpaceHorizontally();
	getPlaceholderHorizontalLayout->addChild(setPlaceholderButton);

	setPlaceholderEditBox = new EditBox();
	setPlaceholderEditBox->setPlaceholder("Edit box placeholder");
	setPlaceholderEditBox->fillSpaceHorizontally();
	getPlaceholderHorizontalLayout->addChild(setPlaceholderEditBox);

	mEditBoxListView->addChild(getPlaceholderHorizontalLayout);
}
示例#15
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout()
{
	// Create and add the main layout to the screen.
	mMainListView = new ListView();
	Screen::setMainWidget(mMainListView);

	Label* info1 = new Label();
	info1->setText("First edit box with Capitalize all characters");
	mMainListView->addChild(info1);

	mEditBox = new EditBox();
	mEditBox->setPlaceholder("Enter text...");
	mEditBox->setHeight(100);
	mEditBox->fillSpaceHorizontally();
	mMainListView->addChild(mEditBox);

	HorizontalLayout* layout = new HorizontalLayout();
	layout->setHeight(75);
	mMainListView->addChild(layout);

	mSetTextButton = new Button();
	mSetTextButton->setText("Reset text to DEFAULT ");
	layout->addChild(mSetTextButton);

	mGetTextButton = new Button();
	mGetTextButton->setText("Get text");
	layout->addChild(mGetTextButton);

	mGetTextLabel = new Label();
	mMainListView->addChild(mGetTextLabel);

	mKeyboardButton = new Button();
	mKeyboardButton->setText("Show/hide keyboard");
	mKeyboardButton->fillSpaceHorizontally();
	mMainListView->addChild(mKeyboardButton);

	// Create layout for widgets.
	this->createDecimalEditBoxView(mMaxTextLengthEditBox, mMainListView, MAX_TEXT_LENGTH_LABEL_TEXT);
	this->createDecimalEditBoxView(mMaxLinesEditBox, mMainListView, MAX_LINES_LABEL_TEXT);
	this->createDecimalEditBoxView(mMinLinesEditBox, mMainListView, MIN_LINES_LABEL_TEXT);
	this->createDecimalEditBoxView(mLinesNumberEditBox, mMainListView, LINES_NUMBER_LABEL_TEXT);
	this->createDecimalEditBoxView(mPlaceholderColorEditBox, mMainListView, PLACEHOLDER_COLOR_LABEL_TEXT);
	this->createInputModeListView(mMainListView);
	this->createInputFlagListView(mMainListView);

	maSetColor(0x8A2BE2);
}
示例#16
0
/**
 * Creates a horizontal layout, adds it to the main layout, initializes the
 * edit box and adds it to the horizontal layout.
 * @param editBox The editbox to be created and added on the screen.
 * @param mainLayout Widgets will be added to it.
 */
void MainScreen::createDecimalEditBoxView(EditBox* &editBox, ListView* mainListView, String text)
{
	// Create layout for widgets.
	HorizontalLayout* layout = new HorizontalLayout();
	layout->setHeight(65);

	mainListView->addChild(layout);

	// Add label with info.
	Label* label = new Label();
	label->setText(text);
	layout->addChild(label);

	// Create the edit box.
	editBox = new EditBox();
	editBox->setInputMode(EDIT_BOX_INPUT_MODE_DECIMAL);
	editBox->fillSpaceHorizontally();
	layout->addChild(editBox);
}
示例#17
0
/**
 * Create the dialog that will display receipt fields, on rows.
 */
void MainScreen::createReceiptDialog()
{
	mReceiptDialog = new Dialog();
	VerticalLayout* dialogLayout = new VerticalLayout();
	mReceiptDialog->setMainWidget(dialogLayout);

	HorizontalLayout* titleLayout = new HorizontalLayout();
	titleLayout->wrapContentVertically();
	titleLayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	Label* title = new Label("Product Receipt");
	title->setFontColor(RECEIPT_FIELD_COLOR);
	titleLayout->addChild(title);
	dialogLayout->addChild(titleLayout);

	Label* receiptProductIdInfo = new Label("Product ID");
	receiptProductIdInfo->setFontColor(RECEIPT_FIELD_COLOR);
	mReceiptProductId = new Label();
	Label* receiptAppId = new Label("App ID");
	receiptAppId->setFontColor(RECEIPT_FIELD_COLOR);
	mReceiptAppId = new Label();
	Label* receiptTransactionDate = new Label("Transaction date");
	receiptTransactionDate->setFontColor(RECEIPT_FIELD_COLOR);
	mReceiptTransactionDate = new Label();

	dialogLayout->addChild(receiptProductIdInfo);
	dialogLayout->addChild(mReceiptProductId);
	dialogLayout->addChild(receiptAppId);
	dialogLayout->addChild(mReceiptAppId);
	dialogLayout->addChild(receiptTransactionDate);
	dialogLayout->addChild(mReceiptTransactionDate);

	if ( getPlatform() == IOS )
	{
		Label* receiptTransactionId = new Label("Transaction ID");
		receiptTransactionId->setFontColor(RECEIPT_FIELD_COLOR);
		mReceiptTransactionId = new Label();
		Label* receiptVersionExternalId = new Label("Version external ID");
		receiptVersionExternalId->setFontColor(RECEIPT_FIELD_COLOR);
		mReceiptVersionExternalId = new Label();
		Label* receiptBid = new Label("BID");
		receiptBid->setFontColor(RECEIPT_FIELD_COLOR);
		mReceiptBid = new Label();
		dialogLayout->addChild(receiptTransactionId);
		dialogLayout->addChild(mReceiptTransactionId);
		dialogLayout->addChild(receiptVersionExternalId);
		dialogLayout->addChild(mReceiptVersionExternalId);
		dialogLayout->addChild(receiptBid);
		dialogLayout->addChild(mReceiptBid);
	}

	mReceiptOkButton = new Button();
	mReceiptOkButton->setText("Ok");

	dialogLayout->addChild(mReceiptOkButton);
}
示例#18
0
/**
 * Create ListView properties layout
 */
void SettingsScreen::createListViewPropertiesLayout()
{
	VerticalLayout* listViewPropertiesVerticalLayout = new VerticalLayout();
	listViewPropertiesVerticalLayout->wrapContentVertically();
	Label* mListViewPropertiesLabel = new Label();
	mListViewPropertiesLabel->setText("ListView properties");
	mListViewPropertiesLabel->setFontSize(TITLE_FONT_SIZE);
	mListViewPropertiesLabel->setFontColor(0xFF0000);
	listViewPropertiesVerticalLayout->addChild(mListViewPropertiesLabel);

	// create the allow selection layout
	HorizontalLayout* allowSelectionLayout = new HorizontalLayout();
	allowSelectionLayout->wrapContentVertically();
	mListViewAllowSelectionCheckbox = new CheckBox();
	mListViewAllowSelectionCheckbox->setState(true);
	Label* allowSelectionLabel = new Label();
	allowSelectionLabel->setText("Allow selection");
	allowSelectionLayout->addChild(mListViewAllowSelectionCheckbox);
	allowSelectionLayout->addChild(allowSelectionLabel);
	listViewPropertiesVerticalLayout->addChild(allowSelectionLayout);

	if (isIOS())
	{
		listViewPropertiesVerticalLayout->wrapContentVertically();

		// create the mode selection layout
		HorizontalLayout* modeSelectionLayout = new HorizontalLayout();
		modeSelectionLayout->wrapContentVertically();
		Label* setModeLabel = new Label();
		setModeLabel->setText("Set mode: ");
		modeSelectionLayout->addChild(setModeLabel);
		mDisplayCheckBox = new CheckBox();
		mDisplayCheckBox->setState(true);
		listViewPropertiesVerticalLayout->addChild(modeSelectionLayout);

		modeSelectionLayout = new HorizontalLayout();
		Label* setDisplayLabel = new Label();
		setDisplayLabel->setText("Display");
		modeSelectionLayout->addChild(mDisplayCheckBox);
		modeSelectionLayout->addChild(setDisplayLabel);
		mEditCheckBox = new CheckBox();
		mEditCheckBox->setState(false);
		Label* setEditLabel = new Label();
		setEditLabel->setText("Edit");
		modeSelectionLayout->addChild(mEditCheckBox);
		modeSelectionLayout->addChild(setEditLabel);
		listViewPropertiesVerticalLayout->addChild(modeSelectionLayout);

		createListViewItemSelectionStyleLayout(listViewPropertiesVerticalLayout);
	}

	ListViewItem* mListPropertiesItem = new ListViewItem();
	mListPropertiesItem->setSelectionStyle(LIST_VIEW_ITEM_SELECTION_STYLE_NONE);
	mListPropertiesItem->addChild(listViewPropertiesVerticalLayout);

	mPropertiesListView->addChild(mListPropertiesItem);
}
示例#19
0
/**
 * Creates the list manipulation UI (remove section, add/remove item).
 */
void ListScreen::createListManipulationLayout()
{
	mRemoveFirstSection = new Button();
	mRemoveFirstSection->setText("Remove first secction");
	mRemoveFirstSection->fillSpaceHorizontally();
	mMainLayout->addChild(mRemoveFirstSection);

	HorizontalLayout* itemManipulationLayout = new HorizontalLayout();
	itemManipulationLayout->wrapContentVertically();
	mAddItem = new Button();
	mAddItem->setText("Add item");
	mAddItem->fillSpaceHorizontally();
	itemManipulationLayout->addChild(mAddItem);

	mRemoveItem = new Button();
	mRemoveItem->setText("Remove item");
	mRemoveItem->fillSpaceHorizontally();
	itemManipulationLayout->addChild(mRemoveItem);

	mMainLayout->addChild(itemManipulationLayout);
}
示例#20
0
    void addCheckboxWidget(Layout* aTargetLayout)
    {
        VerticalLayout* betaWrapper = new VerticalLayout();
        betaWrapper->fillSpaceHorizontally();
        betaWrapper->wrapContentVertically();
        betaWrapper->setPaddingTop(int(mFontSize * 0.5));

        VerticalLayout* betaContainer = new VerticalLayout();
        betaContainer->fillSpaceHorizontally();
        betaContainer->wrapContentVertically();
        betaContainer->setBackgroundColor(AUX_COLOR);
        setRoundPadding(aTargetLayout);

        HorizontalLayout* subSettingsContainer = new HorizontalLayout();
        subSettingsContainer->fillSpaceHorizontally();
        subSettingsContainer->wrapContentVertically();
        subSettingsContainer->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
        subSettingsContainer->setChildHorizontalAlignment(MAW_ALIGNMENT_RIGHT);

        Label* betaText = new Label();
        betaText->setText("This is a checkBox");
        betaText->setFontColor(LABEL_FONT_COLOR);
        betaText->setFontSize(mFontSize);
        betaText->fillSpaceHorizontally();
        betaText->wrapContentVertically();
        betaText->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);

        CheckBox* betaCB = new CheckBox();
        betaCB->wrapContentHorizontally();
        betaCB->wrapContentVertically();
        betaCB->setState(true);

        subSettingsContainer->addChild(betaText);
        subSettingsContainer->addChild(betaCB);

        betaContainer->addChild(subSettingsContainer);

        betaWrapper->addChild(betaContainer);
        aTargetLayout->addChild(betaWrapper);
    }
示例#21
0
/**
 * Create ListView section properties layout
 */
void SettingsScreen::createListViewSectionPropertiesLayout()
{
	VerticalLayout* listViewSectionPropertiesVerticalLayout = new VerticalLayout();
	listViewSectionPropertiesVerticalLayout->wrapContentVertically();
	mListViewSectionLabel = new Label();
	mListViewSectionLabel->setText("No section in focus");
	mListViewSectionLabel->setFontSize(TITLE_FONT_SIZE);
	mListViewSectionLabel->setFontColor(0xFF0000);
	listViewSectionPropertiesVerticalLayout->addChild(mListViewSectionLabel);

	// create the current section title layout
	HorizontalLayout* currentSectionTitleLayout = new HorizontalLayout();
	currentSectionTitleLayout->wrapContentVertically();
	mSetListViewSectionTitleButton = new Button();
	mSetListViewSectionTitleButton->setText("Set title");
	mSetListViewSectionTitleButton->fillSpaceHorizontally();
	currentSectionTitleLayout->addChild(mSetListViewSectionTitleButton);
	mCurrentListViewSectionTitleEditBox = new EditBox();
	mCurrentListViewSectionTitleEditBox->fillSpaceHorizontally();
	currentSectionTitleLayout->addChild(mCurrentListViewSectionTitleEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionTitleLayout);

	// create the current section header text layout
	HorizontalLayout* currentSectionHeaderTextLayout = new HorizontalLayout();
	currentSectionHeaderTextLayout->wrapContentVertically();
	mSetListViewSectionHeaderButton = new Button();
	mSetListViewSectionHeaderButton->setText("Set header");
	mSetListViewSectionHeaderButton->fillSpaceHorizontally();
	currentSectionHeaderTextLayout->addChild(mSetListViewSectionHeaderButton);
	mCurrentListViewSectionHeaderEditBox = new EditBox();
	mCurrentListViewSectionHeaderEditBox->fillSpaceHorizontally();
	currentSectionHeaderTextLayout->addChild(mCurrentListViewSectionHeaderEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionHeaderTextLayout);

	// create the current section footer text layout
	HorizontalLayout* currentSectionFooterTextLayout = new HorizontalLayout();
	currentSectionFooterTextLayout->wrapContentVertically();
	mSetListViewSectionFooterButton = new Button();
	mSetListViewSectionFooterButton->setText("Set footer");
	mSetListViewSectionFooterButton->fillSpaceHorizontally();
	currentSectionFooterTextLayout->addChild(mSetListViewSectionFooterButton);
	mCurrentListViewSectionFooterEditBox = new EditBox();
	mCurrentListViewSectionFooterEditBox->fillSpaceHorizontally();
	currentSectionFooterTextLayout->addChild(mCurrentListViewSectionFooterEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionFooterTextLayout);

	if (isWindowsPhone() || isAndroid())
	{
		listViewSectionPropertiesVerticalLayout->wrapContentVertically();
		createListViewSectionHeaderPropertiesLayout(listViewSectionPropertiesVerticalLayout);
		createListViewSectionFooterPropertiesLayout(listViewSectionPropertiesVerticalLayout);
	}

	ListViewItem* mListSectionPropertiesItem = new ListViewItem();
	mListSectionPropertiesItem->setSelectionStyle(LIST_VIEW_ITEM_SELECTION_STYLE_NONE);
	mListSectionPropertiesItem->addChild(listViewSectionPropertiesVerticalLayout);

	mPropertiesListView->addChild(mListSectionPropertiesItem);
}
示例#22
0
/**
 * Creates and adds main layout to the screen.
 */
void ImageScreen::createMainLayout()
{
	HorizontalLayout* mainLayout = new HorizontalLayout();
	Screen::setMainWidget(mainLayout);

	mImage = new Image();
//	mImage->setHeight(this->getHeight());
//	mImage->setWidth(this->getWidth());
	mImage->fillSpaceHorizontally();
	mImage->fillSpaceVertically();
	mImage->setScaleMode(IMAGE_SCALE_XY);
	mainLayout->addChild(mImage);
}
示例#23
0
/**
 * Helper function to create list view item with
 * specific label and edit/check box.
 */
ListViewItem* CreateNotificationScreen::createListViewItem(const MAUtil::String& labelText, Widget* widget)//EditBox* editBox)
{
	ListViewItem* listItem;
	HorizontalLayout* hLayout;
	Widget* space;
	Label* label;

	hLayout = new HorizontalLayout();
	label = new Label();
	label->setText(labelText);
	hLayout->addChild(label);

	space = this->createSpacer();
	hLayout->addChild(space);

	widget->fillSpaceHorizontally();
	hLayout->addChild(widget);

	listItem = new ListViewItem();
	listItem->addChild(hLayout);
	return listItem;
}
示例#24
0
void FirstScreen::createRemoveItemDialog()
{
	mRemoveItemDialog = new Dialog();
	VerticalLayout* removeDialogLayout = new VerticalLayout();
	mRemoveItemDialog->addChild(removeDialogLayout);

	mItemsPicker = new CustomPicker();
	for (int i=0; i<mMenuItems.size(); i++)
	{
		HorizontalLayout* itemLayout = new HorizontalLayout();
		Label* info = new Label("Item on position" +MAUtil::integerToString(i));
		itemLayout->addChild(info);
		mItemsPicker->addChild(itemLayout);
	}

	mRemoveItemDone = new Button();
	mRemoveItemDone->setText("Remove selected item");
	mRemoveAllItemsDone = new Button();
	mRemoveAllItemsDone->setText("Remove ALL items");

	removeDialogLayout->addChild(mItemsPicker);
	removeDialogLayout->addChild(mRemoveItemDone);
	removeDialogLayout->addChild(mRemoveAllItemsDone);
}
示例#25
0
void SettingsScreen::createListViewSectionFooterPropertiesLayout(VerticalLayout* listViewSectionPropertiesVerticalLayout)
{
	// create the current section footer background color layout
	HorizontalLayout* currentSectionFooterBackgroundColorLayout = new HorizontalLayout();
	currentSectionFooterBackgroundColorLayout->wrapContentVertically();
	mSetSectionFooterBackgroundColor = new Button();
	mSetSectionFooterBackgroundColor->setText("Footer bg");
	mSetSectionFooterBackgroundColor->fillSpaceHorizontally();
	currentSectionFooterBackgroundColorLayout->addChild(mSetSectionFooterBackgroundColor);
	mFooterBackgroundColorEditBox = new EditBox();
	mFooterBackgroundColorEditBox->setPlaceholder("ex: 0xFF0000");
	mFooterBackgroundColorEditBox->fillSpaceHorizontally();
	currentSectionFooterBackgroundColorLayout->addChild(mFooterBackgroundColorEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionFooterBackgroundColorLayout);

	// create the current section footer font size layout
	HorizontalLayout* currentSectionFooterFontSizeLayout = new HorizontalLayout();
	currentSectionFooterFontSizeLayout->wrapContentVertically();
	mSetSectionFooterFontSize = new Button();
	mSetSectionFooterFontSize->setText("Footer font sz");
	mSetSectionFooterFontSize->fillSpaceHorizontally();
	currentSectionFooterFontSizeLayout->addChild(mSetSectionFooterFontSize);
	mFooterFontSizeEditBox = new EditBox();
	mFooterFontSizeEditBox->setInputMode(EDIT_BOX_INPUT_MODE_NUMERIC);
	mFooterFontSizeEditBox->fillSpaceHorizontally();
	currentSectionFooterFontSizeLayout->addChild(mFooterFontSizeEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionFooterFontSizeLayout);

	// create the current section footer font color layout
	HorizontalLayout* currentSectionFooterFontColorLayout = new HorizontalLayout();
	currentSectionFooterFontColorLayout->wrapContentVertically();
	mSetSectionFooterFontColor = new Button();
	mSetSectionFooterFontColor->setText("Footer font color");
	mSetSectionFooterFontColor->fillSpaceHorizontally();
	currentSectionFooterFontColorLayout->addChild(mSetSectionFooterFontColor);
	mFooterFontColorEditBox = new EditBox();
	mFooterFontColorEditBox->setPlaceholder("ex: 0xFF0000");
	mFooterFontColorEditBox->fillSpaceHorizontally();
	currentSectionFooterFontColorLayout->addChild(mFooterFontColorEditBox);
	listViewSectionPropertiesVerticalLayout->addChild(currentSectionFooterFontColorLayout);
}
示例#26
0
void MainScreen::createDialogMainLayout()
{
	VerticalLayout* dialogLayout = new VerticalLayout();
	dialogLayout->setPaddingLeft(10);
	dialogLayout->setPaddingRight(10);


	Label* info = new Label();
	info->setText(" Please fill in all the fields ");
	info->fillSpaceHorizontally();
	dialogLayout->addChild(info);

	VerticalLayout* genderLayout = new VerticalLayout();
	// set to wrap content
	genderLayout->setPaddingTop(20);
	genderLayout->setPaddingBottom(20);
	genderLayout->setPaddingLeft(20);

	Label* infoGender = new Label();
	infoGender->setText("Select gender");
	infoGender->setFontColor(0xFF7F24);
	genderLayout->addChild(infoGender);
	HorizontalLayout* femaleL = new HorizontalLayout();
	mGenderFemale = new CheckBox();
	mGenderFemale->setState(false);
	femaleL->addChild(mGenderFemale);
	Label* female = new Label();
	female->setText(" Female");
	femaleL->addChild(female);
	genderLayout->addChild(femaleL);

	HorizontalLayout* maleL = new HorizontalLayout();
	mGenderMale = new CheckBox();
	mGenderMale->setState(false);
	maleL->addChild(mGenderMale);
	Label* male = new Label();
	male->setText(" Male");
	maleL->addChild(male);
	genderLayout->addChild(maleL);

	dialogLayout->addChild(genderLayout);

	VerticalLayout* birthLayout = new VerticalLayout();
	birthLayout->setPaddingTop(20);
	birthLayout->setPaddingBottom(20);
	birthLayout->setPaddingLeft(20);

	Label* infoBirth = new Label();
	infoBirth->setText("Select age");
	infoBirth->setFontColor(0xFF7F24);
	birthLayout->addChild(infoBirth);

	mAge = new Slider();
	mAge->fillSpaceHorizontally();
	mAge->setValue(18);
	mAge->setMaximumValue(110);
	birthLayout->addChild(mAge);
	mAgeLabel = new Label();
	mAgeLabel->setText("18");
	birthLayout->addChild(mAgeLabel);
	dialogLayout->addChild(birthLayout);

	mDialogDismiss = new Button();
	mDialogDismiss->setText("Ready");
	dialogLayout->addChild(mDialogDismiss);

	mDialog = new Dialog();
	mDialog->setTitle("My Form");
	mDialog->canBeDismissed(false);

	mDialog->setMainWidget(dialogLayout);
}
示例#27
0
/**
 * Creates and adds main layout to the screen.
 */
void WorkspaceLayout::createMainLayout() {

	// Create the main layout.
	HorizontalLayout *controlButtonsContainer = new HorizontalLayout();
	controlButtonsContainer->fillSpaceHorizontally();
	controlButtonsContainer->setHeight(mWidgetHeight);

	if(mOS == "iPhone OS")
	{

		mRefreshButton = new ImageButton();
		((ImageButton*)mRefreshButton)->addButtonListener(this);
		((ImageButton*)mRefreshButton)->setBackgroundImage(RELOAD_BG);
		mRefreshButton->setFontColor(0x000000);

		mDisconnectButton = new ImageButton();
		((ImageButton*)mDisconnectButton)->addButtonListener(this);
		((ImageButton*)mDisconnectButton)->setBackgroundImage(RELOAD_BG);
		mDisconnectButton->setFontColor(0x000000);

		mSaveButton = new ImageButton();
		((ImageButton*)mSaveButton)->addButtonListener(this);
		((ImageButton*)mSaveButton)->setBackgroundImage(RELOAD_BG);
		mSaveButton->setFontColor(0x000000);

		mReloadButton = new ImageButton();
		((ImageButton*)mReloadButton)->addButtonListener(this);
		((ImageButton*)mReloadButton)->setBackgroundImage(CONNECT_BG);
		mReloadButton->setFontColor(0x000000);
	}
	else
	{
		mRefreshButton = new Button();
		((Button*)mRefreshButton)->addButtonListener(this);

		mDisconnectButton = new Button();
		((Button*)mDisconnectButton)->addButtonListener(this);

		mSaveButton = new Button();
		((Button*)mSaveButton)->addButtonListener(this);

		mReloadButton = new Button();
		((Button*)mReloadButton)->addButtonListener(this);
	}

	mRefreshButton->setText(REFRESH_LIST_BUTTON_TEXT);
	mRefreshButton->setHeight(mWidgetHeight);
	mRefreshButton->fillSpaceHorizontally();

	mDisconnectButton->setText(DISCONNECT_BUTTON_TEXT);
	mDisconnectButton->setHeight(mWidgetHeight);
	mDisconnectButton->fillSpaceHorizontally();

	controlButtonsContainer->addChild(mDisconnectButton);
	controlButtonsContainer->addChild(mRefreshButton);

	// Create Project Control Buttons SAVE and RELOAD
	mSaveButton->setText(SAVE_BUTTON_TEXT);
	mSaveButton->setWidth((int)(mScreenWidth * mSaveButtonWidthRatio));

	mReloadButton->setText(RELOAD_BUTTON_TEXT);
	mReloadButton->setWidth((int)(mScreenWidth * mReloadButtonWidthRatio));

	mListView = new ListView();
	mListView->allowSelection(true);
	mListView->addListViewListener(this);
	if(mOS.find("iPhone") >= 0)
	{
		this->setBackgroundColor(0x000000);
		mListView->setProperty(MAW_WIDGET_BACKGROUND_COLOR,"00000000");
	}

	this->addChild(controlButtonsContainer);
	this->addChild(mListView);

	// Create the activity indicator widgets
	mActivityIndicatorContainer = new RelativeLayout();
	mActivityIndicatorContainer->fillSpaceHorizontally();
	mActivityIndicatorContainer->fillSpaceVertically();

	/**
	 * FIXME Removing listView and adding Activity indicator causes
	 * the list view not getting events until some point,
	 * when removing activity indicator to add the list again.
	 */
	//ActivityIndicator *loadingProjectsIndicator = new ActivityIndicator();
	//loadingProjectsIndicator->setSize(80,80);
	//loadingProjectsIndicator->setPosition((int)(mScreenWidth*0.5) - 40, (int)(mScreenHeight*0.5) - 80 );
	//mActivityIndicatorContainer->addChild(loadingProjectsIndicator);


}
示例#28
0
/**
 * If there is no list populates the List View Widget with the project data
 * from mProjects vector. Else destroys and deallocates previous list items
 * and creates new ones.
 */
void WorkspaceLayout::updateProjectList(MAUtil::Vector <reloadProject> * projects)
{
	// Remove The ListView and add An Activity Indicator
	lprintfln("Updating Project List");
	mListView->setVisible(false);

	/**
	 * FIXME Removing listView and adding Activity indicator causes
	 * the list view not getting events until some point,
	 * when removing activity indicator to add the list again.
	 */
	//this->removeChild(mListView);
	//this->addChild(mActivityIndicatorContainer);

	// If there was a project Selected before update remove the
	// control buttons
	if(mSelectedProject != -1)
	{
		Widget *h = mListView->getChild(mSelectedProject)->getChild(0);
		h->removeChild(h->getChild(1));
		h->removeChild(h->getChild(1));
	}

	// ReInitialize selected project
	mSelectedProject = -1;
	mSelectedProjectName = "";

	// Delete all the widgets from the ListView
	int prProjects = mListView->countChildWidgets();
	if(prProjects != 0)
	{
		for(int i = 0; i < prProjects; i++)
		{
			Widget *listItemWidget = mListView->getChild(0); // list Item Widget

			Widget *hLayout = listItemWidget->getChild(0); // horizontal layout widget
			for( int j = 0; j < hLayout->countChildWidgets(); j++)
			{
				Widget * w = hLayout->getChild(0);
				hLayout->removeChild(w);
				delete w;
			}

			listItemWidget->removeChild(hLayout);

			delete hLayout;

			mListView->removeChild(listItemWidget);
			delete listItemWidget;
		}
	}

	// Re-populate the ListView with projects
	for (MAUtil::Vector <reloadProject>::iterator i = projects->begin(); i != projects->end(); i++)
	{
		// New List Itemprojects
		ListViewItem* item = new ListViewItem();
		item->setHeight(mWidgetHeight);
		item->fillSpaceHorizontally();

		// New Horizontal Layout
		HorizontalLayout *itemHorizontalLayout = new HorizontalLayout();
		itemHorizontalLayout->fillSpaceHorizontally();
		itemHorizontalLayout->setHeight(mWidgetHeight);

		// New Label
		Label* projectNameLabel = new Label();
		projectNameLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_LEFT);
		projectNameLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
		projectNameLabel->setText(i->name);
		projectNameLabel->fillSpaceHorizontally();
		projectNameLabel->fillSpaceVertically();

		if (mOS.find("iPhone") >= 0)
		{
			itemHorizontalLayout->setWidth(item->getWidth());
			projectNameLabel->setFontColor(0xffffff);
		}

		itemHorizontalLayout->addChild(projectNameLabel);

		item->addChild(itemHorizontalLayout);

		mListView->addChild(item);
	}
	mListView->setVisible(true);

	// Remove Indicator and Add Project ListView
	//this->addChild(mListView);
	//this->removeChild(mActivityIndicatorContainer);

}
示例#29
0
文件: TestJob.cpp 项目: asyr625/tinia
bool TestJob::init()
{


   m_model->addStateListener(this);
   tinia::model::Viewer viewer;
   viewer.height = 500;
   viewer.width = 500;
   m_model->addElement("viewer", viewer);
   m_model->addElement<std::string>( "boundingbox", "-1.1 -1.1 -1.1 1.1 1.1 1.1" );
   m_model->addElement<int>( "renderlist", 0 );

   m_model->addElement<bool>("myTab", false);
   m_model->addAnnotation("myTab", "My tab");
      m_model->addElement<bool>("myBool", false);
   m_model->addElement<std::string>("myVal", "THIS WORKS!");

   const char* restrictions[] = {"select1", "select2", "select3", "select4"};
   m_model->addElementWithRestriction<std::string>("myVal2", "select3",
                                                       &restrictions[0], &restrictions[4]);

   m_model->addAnnotation("myVal2", "My special value");

   m_model->addConstrainedElement<int>("myIntBA", 5,0, 900);
   m_model->addConstrainedElement<double>("myDouble", 10., 0., 11.);
   m_model->addElement<bool>("myButton", false);

   m_model->addElement<bool>( "details", true, "Popup" );

   m_model->addAnnotation("myButton", "My pushButton");

   tinia::model::File file;
   m_model->addElement("SpecialFile", file);
   m_model->addAnnotation("SpecialFile", "Open file");
   m_model->addElement("SpecialFileName", file.name());

   using namespace tinia::model::gui;
   TabLayout* root = new TabLayout();
   HorizontalLayout *superLayout = new HorizontalLayout();

   Grid *mainGrid = new Grid(16, 1);
   //superLayout->addChild(mainGrid);
   Tab *mainTab = new Tab("myTab");
   mainTab->setChild(superLayout);
   root->addChild(mainTab);


   TabLayout *subTablayout = new TabLayout();
   Tab* subTab = new Tab("myBool");

   subTablayout->addChild(subTab);

   subTab->setChild(mainGrid);

   superLayout->addChild(subTablayout);

   // Simple Label-input-layout
   Grid *input1Grid = new Grid(4,3);
   mainGrid->setChild(0,0, input1Grid);
   input1Grid->setChild(0, 0, new Label("myVal"));
   input1Grid->setChild(0, 1, (new TextInput("myVal"))->setEnabledKey( "myTab", true ) );

   input1Grid->setChild(1,0, new Label("myVal2"));
   input1Grid->setChild(1,1, new ComboBox("myVal2"));

   input1Grid->setChild(2,0, new Label("myVal2"));
   input1Grid->setChild(2,1, new RadioButtons("myVal2"));

   PopupButton* popup = new PopupButton("details", false);
   input1Grid->setChild(2, 2, popup );
   popup->setEnabledKey( "myTab" );

   PopupButton* popup2 = new PopupButton( "myVal", true );
   input1Grid->setChild(3, 2, popup2 );

   popup2->setChild( new TextInput("myVal" ) );


   ElementGroup* popup_group = new ElementGroup( "myTab", true );
   popup->setChild( popup_group );
   popup_group->setChild( new RadioButtons( "myVal2" ) );


   mainGrid->setChild(1, 0, new SpinBox("myIntBA"));
   mainGrid->setChild(2, 0, new TextInput("myIntBA"));
   mainGrid->setChild(3, 0, new CheckBox("myTab"));
   mainGrid->setChild(4, 0, new CheckBox("myTab"));
   mainGrid->setChild(5, 0, new Button("myButton"));
   mainGrid->setChild(6, 0, new HorizontalSlider("myIntBA"));
   mainGrid->setChild(8,0, new DoubleSpinBox("myDouble"));
   mainGrid->setChild(9, 0, new CheckBox("myBool"));
   mainGrid->setChild(10, 0, new VerticalExpandingSpace());
   mainGrid->setChild(11, 0, new Label("myDouble", true ) );
   mainGrid->setChild(12, 0, new FileDialogButton("SpecialFile"));
   mainGrid->setChild(13, 0, new Label("SpecialFileName", true));

   ElementGroup* elemGroup = new ElementGroup("myTab", false);
   elemGroup->setVisibilityKey( "myTab" );

   elemGroup->setChild( new TextInput("myVal") );
   mainGrid->setChild(7, 0, elemGroup);

   Grid* canvasGrid = new Grid(2,1);
   Canvas *canvas = new Canvas("viewer", "renderlist", "boundingbox" );

   canvasGrid->setChild(0,0, canvas);
   VerticalLayout* verticalLayout = new VerticalLayout;
   verticalLayout->setVisibilityKey( "myBool" );
   verticalLayout->addChild(elemGroup);
   verticalLayout->addChild(elemGroup);
   verticalLayout->addChild(elemGroup);
   canvasGrid->setChild(1,0, verticalLayout);
   superLayout->addChild(canvasGrid);
   m_model->setGUILayout(root, DESKTOP);



   // ---- Set up renderlist data

   // Geometry for a simple line segment cube
   float wire_cube_pos[12*2*3] = {
       0.f, 0.f, 0.f,  1.f, 0.f, 0.f,
       0.f, 1.f, 0.f,  1.f, 1.f, 0.f,
       0.f, 0.f, 0.f,  0.f, 1.f, 0.f,
       1.f, 0.f, 0.f,  1.f, 1.f, 0.f,
       0.f, 0.f, 0.f,  0.f, 0.f, 1.f,
       0.f, 1.f, 0.f,  0.f, 1.f, 1.f,
       1.f, 0.f, 0.f,  1.f, 0.f, 1.f,
       1.f, 1.f, 0.f,  1.f, 1.f, 1.f,
       0.f, 0.f, 1.f,  1.f, 0.f, 1.f,
       0.f, 1.f, 1.f,  1.f, 1.f, 1.f,
       0.f, 0.f, 1.f,  0.f, 1.f, 1.f,
       1.f, 0.f, 1.f,  1.f, 1.f, 1.f,
   };
   m_renderlist_db.createBuffer( "wire_cube_pos" )->set( wire_cube_pos, 12*2*3 );
   m_renderlist_db.createAction<tinia::renderlist::Draw>( "wire_cube_draw" )
           ->setNonIndexed( tinia::renderlist::PRIMITIVE_LINES, 0, 12*2 );
   // Solid color shader
   std::string solid_vs =
           "uniform mat4 MVP;\n"
           "attribute vec3 position;\n"
           "void\n"
           "main()\n"
           "{\n"
           "    gl_Position = MVP * vec4( position, 1.0 );\n"
           "}\n";
   std::string solid_fs =
           "#ifdef GL_ES\n"
           "precision highp float;\n"
           "#endif\n"
           "uniform vec3 color;\n"
           "void\n"
           "main()\n"
           "{\n"
           "    gl_FragColor = vec4( color, 1.0 );\n"
           "}\n";
   m_renderlist_db.createShader( "solid" )
           ->setVertexStage( solid_vs )
           ->setFragmentStage( solid_fs );
   m_renderlist_db.createAction<tinia::renderlist::SetShader>( "solid_use" )
           ->setShader( "solid" );
   m_renderlist_db.createAction<tinia::renderlist::SetUniforms>( "solid_orient" )
           ->setShader( "solid" )
           ->setSemantic( "MVP", tinia::renderlist::SEMANTIC_MODELVIEW_PROJECTION_MATRIX );
   m_renderlist_db.createAction<tinia::renderlist::SetUniforms>( "solid_white" )
           ->setShader( "solid" )
           ->setFloat3( "color", 1.f, 1.f, 1.f );
   m_renderlist_db.createAction<tinia::renderlist::SetUniforms>( "solid_green" )
           ->setShader( "solid" )
           ->setFloat3( "color", 0.f, 1.f, 0.f );

   // Combine the wire cube geometry with the solid shader
   m_renderlist_db.createAction<tinia::renderlist::SetInputs>( "solid_wire_cube_input" )
           ->setShader( "solid" )
           ->setInput( "position", "wire_cube_pos", 3 );

   // Position and scale the two instances, encoded as a transform matric and its inverse
   float shape0_to_world[16] = {
       2.f, 0.f, 0.f, -1.0f,
       0.f, 2.f, 0.f, -1.0f,
       0.f, 0.f, 2.f, -1.0f,
       0.f, 0.f, 0.f,  1.f,
   };
   float shape0_from_world[16] = {
       0.5f,  0.f,  0.f,  1.0f,
       0.f,  0.5f,  0.f,  1.0f,
       0.f,  0.f,  0.5f,  1.0f,
       0.f,  0.f,  0.f,   1.f,
   };
   m_renderlist_db.createAction<tinia::renderlist::SetLocalCoordSys>( "shape0_pos" )
           ->setOrientation( shape0_from_world, shape0_to_world );

   float shape1_to_world[16] = {
       1.f, 0.f, 0.f, -0.5f,
       0.f, 1.f, 0.f, -0.5f,
       0.f, 0.f, 1.f, -0.5f,
       0.f, 0.f, 0.f,  1.f,
   };
   float shape1_from_world[16] = {
       1.f,  0.f,  0.f,  0.5f,
       0.f,  1.f,  0.f,  0.5f,
       0.f,  0.f,  1.f,  0.5f,
       0.f,  0.f,  0.f,   1.f,
   };
   m_renderlist_db.createAction<tinia::renderlist::SetLocalCoordSys>( "shape1_pos" )
           ->setOrientation( shape1_from_world, shape1_to_world );

   // Set up draw order
   m_renderlist_db.drawOrderClear()
           ->drawOrderAdd( "solid_use")
           ->drawOrderAdd( "solid_wire_cube_input" )

           ->drawOrderAdd( "shape0_pos" )      // sets transform matrices
           ->drawOrderAdd( "solid_orient" )    // updates uniforms
           ->drawOrderAdd( "solid_white" )     // set color uniform
           ->drawOrderAdd( "wire_cube_draw" )  // invoke draw call

           ->drawOrderAdd( "shape1_pos" )
           ->drawOrderAdd( "solid_orient" )
           ->drawOrderAdd( "solid_green" )
           ->drawOrderAdd( "wire_cube_draw" );

   m_renderlist_db.process();
   m_model->updateElement<int>( "renderlist", m_renderlist_db.latest() );

   glewInit();
#ifndef __APPLE__
   static const GLfloat quad[ 4*4 ] = {
        1.f, -1.f, 0.f, 1.f,
        1.f,  1.f, 0.f, 1.f,
       -1.f, -1.f, 0.f, 1.f,
       -1.f,  1.f, 0.f, 1.f
   };
   glGenVertexArrays( 1, &m_gpgpu_quad_vertex_array );
   glBindVertexArray( m_gpgpu_quad_vertex_array );
   glGenBuffers( 1, &m_gpgpu_quad_buffer );
   glBindBuffer( GL_ARRAY_BUFFER, m_gpgpu_quad_buffer );
   glBufferData( GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STATIC_DRAW );
   glVertexPointer( 4, GL_FLOAT, 0, NULL );
   glEnableClientState( GL_VERTEX_ARRAY );
   glBindBuffer( GL_ARRAY_BUFFER, 0 );
   glBindVertexArray( 0 );
   CHECK_GL;

   glBindVertexArray( m_gpgpu_quad_vertex_array );
   glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
   glBindVertexArray( 0 );
   CHECK_GL;
#endif
   CHECK_GL;



    return true;
}
示例#30
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout()
{
	// create the first screen
	Screen* firstScreen = new Screen();
    firstScreen->setTitle("Edit box");

    // create the vertical layout that will contain all the
    // elements from the first screen
    VerticalLayout* firstScreenVerticalLayout = new VerticalLayout();

    // edit box creation
	mEditBox = new EditBox();
	mEditBox->setPlaceholder("Enter text...");
	mEditBox->setHeight((mScreenHeight/12)*2);
	mEditBox->fillSpaceHorizontally();
	firstScreenVerticalLayout->addChild(mEditBox);

	// create the horizontal layout that will contain the
	// set text button (resets the text to 'DEFAULT') and the
	// get text button
	HorizontalLayout* layout = new HorizontalLayout();
	layout->setHeight(mScreenHeight/12);
	firstScreenVerticalLayout->addChild(layout);

	mSetTextButton = new Button();
	mSetTextButton->setText("Reset text to DEFAULT ");
	layout->addChild(mSetTextButton);

	mGetTextButton = new Button();
	mGetTextButton->setText("Get text");
	layout->addChild(mGetTextButton);

	mGetTextLabel = new Label();
	firstScreenVerticalLayout->addChild(mGetTextLabel);

	// create and add the show/hide keyboard button
	mKeyboardButton = new Button();
	mKeyboardButton->setText("Show/hide keyboard");
	mKeyboardButton->setHeight(mScreenHeight/12);
	mKeyboardButton->fillSpaceHorizontally();
	firstScreenVerticalLayout->addChild(mKeyboardButton);

	// Create layout for widgets.
	this->createDecimalEditBoxView(mMaxTextLengthEditBox, firstScreenVerticalLayout, MAX_TEXT_LENGTH_LABEL_TEXT);
	this->createDecimalEditBoxView(mMaxLinesEditBox, firstScreenVerticalLayout, MAX_LINES_LABEL_TEXT);
	this->createDecimalEditBoxView(mMinLinesEditBox, firstScreenVerticalLayout, MIN_LINES_LABEL_TEXT);
	this->createDecimalEditBoxView(mLinesNumberEditBox, firstScreenVerticalLayout, LINES_NUMBER_LABEL_TEXT);
	this->createDecimalEditBoxView(mPlaceholderColorEditBox, firstScreenVerticalLayout, PLACEHOLDER_COLOR_LABEL_TEXT);

	// Create widgets for testing MAW_EDIT_BOX_MODE property on iOS.
	if (isIOS())
	{
		firstScreenVerticalLayout->addChild(this->createModePropertyLayout());
	}

	// set the main widget for the first screen and
	// then add it as a application tab
	firstScreen->setMainWidget(firstScreenVerticalLayout);
	this->addTab(firstScreen);

	// create the second screen and the horizontal
	// layout that will contain the input modes and flags lists
	Screen* secondScreen = new Screen();
	secondScreen->setTitle("Modes/flags");
	VerticalLayout* secondScreenVerticalLayout = new VerticalLayout();

	this->createInputModeListView(secondScreenVerticalLayout);

	// create a black separator between the lists
	HorizontalLayout* separatorLayout = new HorizontalLayout();
	separatorLayout->setBackgroundColor(0x000000);
	separatorLayout->setHeight(mScreenHeight/12);
	secondScreenVerticalLayout->addChild(separatorLayout);

	this->createInputFlagListView(secondScreenVerticalLayout);

	// set the main widget for the second screen and
	// then add it as a application tab
	secondScreen->setMainWidget(secondScreenVerticalLayout);
	this->addTab(secondScreen);

	maSetColor(0x8A2BE2);
}