예제 #1
0
void LoadingScreen::initializeScreen(MAUtil::String &os)
{
			MAExtent ex = maGetScrSize();
			int screenWidth = EXTENT_X(ex);
			int screenHeight = EXTENT_Y(ex);

			mSplashScreen = new Screen();
			mSplashScreen->setBackgroundColor(40,40,40);

			//Layout that holds the screen elements
			RelativeLayout* relativeLayout = new RelativeLayout();
			relativeLayout->setSize(screenWidth, screenHeight);

			//The huge Reload "Circle"
			Image* logo = new Image();
			logo->setImage(SPLASH_IMAGE);
			logo->setSize(screenWidth,screenWidth);
			logo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT);

			//Indicator placed on top of the reload circle
			mIndicator = new ActivityIndicator();
			mIndicator->show();

			//Progress bar for the download
			mProgressBar = new ProgressBar();
			mProgressBar->setWidth((int)(screenWidth * 0.75));
			mProgressBar->setMaximumValue(100);

			//Padding between the progress bar and the cancel button
			HorizontalLayout *paddingLayout = new HorizontalLayout();
			paddingLayout->setHeight(screenHeight / 36);

			//the cancel button stops the download and returns the user
			//to the login screen
			if(os == "Android")
			{
				mCancelDownloadButton = new Button();
				((Button*)mCancelDownloadButton)->addButtonListener(this);
			}
			else
			{
				mCancelDownloadButton = new ImageButton();
				((ImageButton*)mCancelDownloadButton)->addButtonListener(this);
				((ImageButton*)mCancelDownloadButton)->setBackgroundImage(RELOAD_BG);
				mCancelDownloadButton->setFontColor(0x000000);
			}

			mCancelDownloadButton->setText("Cancel");
			mCancelDownloadButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
			mCancelDownloadButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
			mCancelDownloadButton->setWidth((int)(screenWidth * 0.75));
			mCancelDownloadButton->setHeight((int)(screenHeight * 0.1));

			//Spacing between the cancel button and the bottom of the screen
			HorizontalLayout *paddingLayout2 = new HorizontalLayout();
			paddingLayout2->setHeight(screenHeight / 15);

			VerticalLayout* logolayout = new VerticalLayout();
			logolayout->setSize(screenWidth, screenHeight);
			logolayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER);
			logolayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
			logolayout->addChild(logo);

			VerticalLayout* activitylayout = new VerticalLayout();
			activitylayout->setSize(screenWidth, screenHeight);
			activitylayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER);
			activitylayout->setChildVerticalAlignment(MAW_ALIGNMENT_CENTER);
			activitylayout->addChild(mIndicator);

			VerticalLayout* progresslayout = new VerticalLayout();
			progresslayout->setSize(screenWidth, screenHeight);
			progresslayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER);
			progresslayout->setChildVerticalAlignment(MAW_ALIGNMENT_BOTTOM);
			progresslayout->addChild(mProgressBar);
			progresslayout->addChild(paddingLayout);
			progresslayout->addChild(mCancelDownloadButton);
			progresslayout->addChild(paddingLayout2);

			relativeLayout->addChild(logolayout);
			relativeLayout->addChild(activitylayout);
			relativeLayout->addChild(progresslayout);
			mSplashScreen->setMainWidget(relativeLayout);
}
예제 #2
0
void LoginScreen::initializeScreen(MAUtil::String &os)
{
	maScreenSetFullscreen(1);
	MAExtent ex = maGetScrSize();
	int screenWidth = EXTENT_X(ex);
	int screenHeight = EXTENT_Y(ex);

	int centerH = screenWidth / 2;
	int buttonWidth = (int)((float)screenWidth * 0.75);
	if(screenHeight > 1000 && os.find("Android", 0) < 0)
	{
		buttonWidth = (int)((float)screenWidth * 0.4);
	}
	int buttonHeight = (int)((float)screenWidth * 0.15);
	if(screenHeight > 1000 && os.find("Android", 0) < 0)
	{
		buttonHeight = (int)((float)screenWidth * 0.07);
	}
	int buttonSpacing = (int)((float)buttonHeight * 0.3);
	if(os.find("Windows", 0) >= 0)
	{
		buttonSpacing = (int)((float)buttonHeight * 0.1);
	}
	int editBoxHeight = (int)((float)screenHeight * 0.07);
	if(screenHeight > 1000  && os.find("Android", 0) < 0)
	{
		editBoxHeight = (int)((float)screenHeight * 0.02);
	}
	int logoWidth = (int)((float)screenWidth * 0.75);
	int layoutTop = (int)((float)screenHeight * 0.3);
	if(screenHeight > 1000  && os.find("Android", 0) < 0)
	{
		layoutTop = (int)((float)screenHeight * 0.25);
	}
	int labelHeight = (int)((float)screenHeight * 0.05);
	if(screenHeight > 1000  && os.find("Android", 0) < 0)
	{
		labelHeight = (int)((float)screenHeight * 0.025);
	}
	int labelWidth = screenWidth;
	if(os.find("Android", 0) >= 0)
	{
		labelWidth = buttonWidth;
	}
	int labelSpacing = (int)((float)screenHeight * 0.02);
	if(screenHeight > 1000  && os.find("Android", 0) < 0)
	{
		labelSpacing = (int)((float)labelSpacing * 0.01);
	}
	int layoutHeight = (buttonHeight + buttonSpacing) * 2;
	int ipBoxButtonSpacing = (int)((float)screenHeight * 0.03);

	mLoginScreen = new Screen();

	//The reload Logo
	Image* logo = new Image();
	logo->setImage(LOGO_IMAGE);
	logo->wrapContentHorizontally();
	logo->wrapContentVertically();
	logo->setWidth(logoWidth);
	logo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT);
	logo->setPosition(centerH - logoWidth/2, screenHeight / 12);

	//The connect to server button
	if(os == "iPhone OS") //Android image buttons do not support text
	{
		mServerConnectButton = new ImageButton();
		((ImageButton*)mServerConnectButton)->addButtonListener(this);
		((ImageButton*)mServerConnectButton)->setBackgroundImage(CONNECT_BG);
		mServerConnectButton->setFontColor(0x000000);
	}
	else
	{
		mServerConnectButton = new Button();
		((Button*)mServerConnectButton)->addButtonListener(this);
	}

	mServerConnectButton->setText("Connect");
	mServerConnectButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	mServerConnectButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mServerConnectButton->setWidth(buttonWidth);
	mServerConnectButton->setHeight(buttonHeight);
	mServerConnectButton->setPosition(centerH - buttonWidth/2, layoutHeight - buttonHeight);

	//The edit box that receives the server IP
	mServerIPBox = new EditBox();
	mServerIPBox->setWidth(buttonWidth);
	//mServerIPBox->setHeight(editBoxHeight);
	mServerIPBox->addEditBoxListener(this);
	mServerIPBox->setPosition(centerH - buttonWidth/2,layoutHeight - buttonHeight - editBoxHeight - ipBoxButtonSpacing);

	//Label for the server IP edit box
	Label *serverIPLabel = new Label();
	serverIPLabel->setText("Server IP:");
	serverIPLabel->setFontColor(0xFFFFFF);
	serverIPLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	serverIPLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	serverIPLabel->setWidth(labelWidth);
	serverIPLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight - editBoxHeight - ipBoxButtonSpacing);


	/*
	 * The mConnectLayout and mDisconnectLayout are placed
	 * on top of each other inside a relative layout, and
	 * each is only shown when needed.
	 */
	mConnectLayout = new RelativeLayout();
	mConnectLayout->setWidth(screenWidth);
	mConnectLayout->setHeight(layoutHeight);
	mConnectLayout->addChild(serverIPLabel);
	mConnectLayout->addChild(mServerIPBox);
	mConnectLayout->addChild(mServerConnectButton);
	mConnectLayout->setPosition(0, layoutTop);

	//The disconnect button
	if(os == "iPhone OS")
	{
		mServerDisconnectButton = new ImageButton();
		((ImageButton*)mServerDisconnectButton)->addButtonListener(this);
		((ImageButton*)mServerDisconnectButton)->setBackgroundImage(CONNECT_BG);
		mServerDisconnectButton->setFontColor(0x000000);
	}
	else
	{
		mServerDisconnectButton = new Button();
		((Button*)mServerDisconnectButton)->addButtonListener(this);
	}


	mServerDisconnectButton->setText("Disconnect");
	mServerDisconnectButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	mServerDisconnectButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mServerDisconnectButton->setWidth(buttonWidth);
	mServerDisconnectButton->setHeight(buttonHeight);
	mServerDisconnectButton->setPosition(centerH - buttonWidth/2, layoutHeight - buttonHeight);

	//Some instructions for the user
	Label *instructionsLabel = new Label();
	instructionsLabel->setText("Use the Reload Web UI to load an app");
	instructionsLabel->setFontColor(0xFFFFFF);
	instructionsLabel->setWidth(labelWidth);
	instructionsLabel->setMaxNumberOfLines(2);
	instructionsLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	instructionsLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	instructionsLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight - ipBoxButtonSpacing);

	//Label with the Server IP
	mConnectedToLabel = new Label();
	mConnectedToLabel->setFontColor(0xFFFFFF);
	mConnectedToLabel->setWidth(labelWidth);
	mConnectedToLabel->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	mConnectedToLabel->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mConnectedToLabel->setPosition(centerH - labelWidth/2, layoutHeight - buttonHeight - labelHeight * 2 - labelSpacing - ipBoxButtonSpacing);

	/*
	 * The mConnectLayout and mDisconnectLayout are placed
	 * on top of each other inside a relative layout, and
	 * each is only shown when needed.
	 */
	mDisconnectLayout = new RelativeLayout();
	mDisconnectLayout->setWidth(screenWidth);
	mDisconnectLayout->setHeight(layoutHeight);
	mDisconnectLayout->addChild(mConnectedToLabel);
	mDisconnectLayout->addChild(instructionsLabel);
	mDisconnectLayout->addChild(mServerDisconnectButton);
	mDisconnectLayout->setPosition(0, layoutTop);

	//The layout that appears when the client is connected
	//is hidden on startup
	mDisconnectLayout->setVisible(false);

	//Button that loads the last loaded app
	if(os == "iPhone OS")
	{
		mLoadLastAppButton = new ImageButton();
		((ImageButton*)mLoadLastAppButton)->addButtonListener(this);
		((ImageButton*)mLoadLastAppButton)->setBackgroundImage(RELOAD_BG);
		mLoadLastAppButton->setFontColor(0x000000);
	}
	else
	{
		mLoadLastAppButton = new Button();
		((Button*)mLoadLastAppButton)->addButtonListener(this);
	}


	mLoadLastAppButton->setText("Reload last app");
	mLoadLastAppButton->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER);
	mLoadLastAppButton->setTextVerticalAlignment(MAW_ALIGNMENT_CENTER);
	mLoadLastAppButton->setWidth(buttonWidth);
	mLoadLastAppButton->setHeight(buttonHeight);
	mLoadLastAppButton->setPosition(centerH - buttonWidth/2, layoutTop + layoutHeight + buttonSpacing);

	//The info icon
	mInfoIcon = new ImageButton();
	mInfoIcon->addButtonListener(this);
	mInfoIcon->setBackgroundImage(INFO_ICON);
	mInfoIcon->setSize((int)(screenWidth * 0.1),(int)(screenWidth * 0.1));
	//mInfoIcon->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT);
	mInfoIcon->setPosition((int)(screenWidth * 0.85), (int)(screenHeight * 0.95) - (int)(screenWidth * 0.1) / 2);

	//A little MoSync logo at the lower right of the screen
	Image* mosynclogo = new Image();
	mosynclogo->setImage(MOSYNC_IMAGE);
	mosynclogo->setHeight((int)(screenWidth * 0.1));
	mosynclogo->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT);
	mosynclogo->setPosition((int)(screenWidth * 0.05),(int)(screenHeight * 0.95) - (int)(screenWidth * 0.1) / 2);

	Image *background = new Image();
	background->setSize(screenWidth, screenHeight);
	background->setImage(BACKGROUND);
	background->setScaleMode(IMAGE_SCALE_XY);

	RelativeLayout *mainLayout = new RelativeLayout();
	mainLayout->setSize(screenWidth, screenHeight);
	if(os.find("Windows", 0) < 0)
	{
		mainLayout->addChild(background);
	}
	mainLayout->addChild(logo);
	mainLayout->addChild(mConnectLayout);
	mainLayout->addChild(mDisconnectLayout);
	mainLayout->addChild(mLoadLastAppButton);
	mainLayout->addChild(mosynclogo);
	mainLayout->addChild(mInfoIcon);

	mLoginScreen->setMainWidget(mainLayout);
}