本文整理汇总了C++中Button函数的典型用法代码示例。如果您正苦于以下问题:C++ Button函数的具体用法?C++ Button怎么用?C++ Button使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Button函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameState
MainMenuState::MainMenuState(Vector2 screenSize, ALLEGRO_KEYBOARD_STATE* keyState, ALLEGRO_KEYBOARD_STATE* prevKeyState, ALLEGRO_MOUSE_STATE* mouseState, ALLEGRO_MOUSE_STATE* prevMouseState, ALLEGRO_FONT* font)
: GameState(screenSize, keyState, prevKeyState, mouseState, prevMouseState)
{
cout << "Main State initialized" << endl;
this->font = font;
background = al_load_bitmap("assets/img/selectGameScreen/Starfield.png");
leftDoor = GameObject("assets/img/selectGameScreen/Leftblastdoor.png", Vector2(1, 1), 30, Vector2());
rightDoor = GameObject("assets/img/selectGameScreen/Rightblastdoor.png", Vector2(1, 1), 30, Vector2(457, 0));
//457 = 559 (size of left door) - 102 (overlap between doors)
mainButton = Button("assets/img/selectGameScreen/StartButton.png", Vector2(1, 1), 100, "assets/img/selectGameScreen/StartButton.png", Vector2(1, 1), 100, "assets/img/selectGameScreen/StartButtonHover.png", Vector2(2, 1), 100, Vector2(300, 200), true);
cout << "Main button loaded" << endl;
opening = false;
/***********************************************************************************************
****************************************** Planets ********************************************
***********************************************************************************************/
Vector2 center = Vector2(getScreenSize().x / 2, getScreenSize().y / 2);
planets.push_back(PlanetButton("Play", font, "assets/img/gameMenuCircles/Center.png", center, 0, 0, 0.001, 0.001));
planets.push_back(PlanetButton("Instructions", font, "assets/img/gameMenuCircles/Planet1.png", center, 175, M_PI / 2, 0.0003, 0.002));
planets.push_back(PlanetButton("Back", font, "assets/img/gameMenuCircles/Planet3.png", center, 350, M_PI, -0.0002, -0.0015));
planets.push_back(PlanetButton("Quit", font, "assets/img/gameMenuCircles/Planet2.png", center, 410, M_PI, -0.00015, 0.003));
}
示例2: playButtonLocation
MenuState::MenuState(sf::Font& mainFont, ScoreBoard* scoreBoard) {
if (!menuBg.load(menuResPath, sf::Vector2u(pixelSizeX, pixelSizeY), level, xPixels, yPixels))
throw std::runtime_error("Failed to load the tilemap probably because file was not found.");
sf::Vector2f playButtonLocation(screenResWidth / 2 - buttonSizeX / 2, screenResHeight / 2 - buttonSizeY / 2);
sf::Vector2f exitButtonLocation(playButtonLocation);
exitButtonLocation.y += buttonSizeY * 2;
playButton = Button("PLAY", playButtonLocation, mainFont);
exitButton = Button("EXIT", exitButtonLocation, mainFont);
playButton.activate();
introText.setString("SNAKE!");
introText.setColor(sf::Color(84, 191, 88));
introText.setPosition(screenResWidth / 2 - buttonSizeX + pixelSizeX, screenResHeight / 2 - 3 * buttonSizeY);
introText.setCharacterSize(210);
introText.setFont(mainFont);
highScore.setString(scoreBoard->getHighScore());
highScore.setCharacterSize(pixelSizeX * 3);
highScore.setPosition(pixelSizeX * 2, screenResHeight / 2 + pixelSizeY * 3);
highScore.setFont(mainFont);
highScoreHeader.setString("Highscore");
highScoreHeader.setCharacterSize(pixelSizeX * 3);
highScoreHeader.setPosition(0, screenResHeight / 2);
highScoreHeader.setFont(mainFont);
//buttonArr[0] = playButton;
//buttonArr[1] = exitButton;
//arrSize = 2;
//activeIndex = 0;
//snakeLogo;
}
示例3: main
void main() {
TRISA=0x01;
TRISB=0x00;
Start:
PORTA=0x00;
Data=0x00;
PORTA=0x02; //Set Latch HIGH
Delay_ms(2);
PORTA=0x00;
Delay_ms(1);
if (Button(&PORTA, 0, 1, 1))temp1=0;
else temp1=1;
Data|=temp1;
for(i=1;i<8;i++){//Read();
Delay_ms(1);
PORTA=0x04;
temp1=0;
if (Button(&PORTA, 0, 1, 1))temp1=0;
else temp1=BITS[i];
Data|=temp1;
Delay_ms(1);
PORTA=0x00;
}
PORTB=Data;
goto Start;
}
示例4: init
void init(){
grabber.init(pa("-i"));
bool c_arg = pa("-c");
gui << Draw().handle("draw").label("input image")
<< Image().handle("cropped").label("cropped")
<< ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1)
<< Button("save as ..").handle("saveAs")
<< Button("overwrite input").handle("overwrite")
<< Combo("0,90,180,270").handle("rot").label("rotation")
<< CheckBox("rectangular",!pa("-r")).handle("rect")
<< Button("Batch crop...").handle("batch")
<< ( HBox().label("rectification size")
<< Spinner(1,4096,640).handle("s1")
<< Label(":")
<< Spinner(1,4096,480).handle("s2")
)
<< (HBox()
<< Fps().handle("fps")
<< CamCfg()
)
)
<< Show();
if(!c_arg){
gui["batch"].registerCallback(batch_crop);
}
const ImgBase *image = grabber.grab();
if(!c_arg){
mouse_1 = new Mouse1(image->getSize());
gui["draw"].install(mouse_1);
}
mouse_2 = new Mouse2(image->getSize());
gui["draw"].install(mouse_2);
DrawHandle draw = gui["draw"];
draw->setImageInfoIndicatorEnabled(false);
if(!c_arg){
gui["rect"].registerCallback(rectangular_changed);
rectangular_changed();
if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){
gui["overwrite"].disable();
}else{
gui["overwrite"].registerCallback(overwrite);
}
gui["saveAs"].registerCallback(save_as);
}
}
示例5: generateMenu
void generateMenu(std::vector<Button> &buttons, std::vector<Sine> &sines) {
// draw buttons
buttons.push_back(Button(100, 150, "250"));
buttons.push_back(Button(100, 250, "1000"));
buttons.push_back(Button(100, 350, "2000"));
// load up sounds
sines.push_back(Sine(250));
sines.push_back(Sine(1000));
sines.push_back(Sine(2000));
}
示例6: NS_ENSURE_SUCCESS
NS_IMETHODIMP
TaskbarPreviewButton::SetImage(imgIContainer *img) {
if (Button().hIcon)
::DestroyIcon(Button().hIcon);
if (img) {
nsresult rv;
rv = nsWindowGfx::CreateIcon(img, PR_FALSE, 0, 0, &Button().hIcon);
NS_ENSURE_SUCCESS(rv, rv);
} else {
Button().hIcon = NULL;
}
return Update();
}
示例7: initWindowUploader
//need to add button for uploading
void initWindowUploader(int width, int height){
windowUploader = SDL_CreateWindow("Image To Upload", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height + (ButtonHeight + 26), 0);
rendererUploader = SDL_CreateRenderer(windowUploader, -1, 0);
string filepath = ExePath() + '\\' + "screenshot.bmp";
image = SDL_LoadBMP(filepath.c_str());
imageTexture = SDL_CreateTextureFromSurface(rendererUploader, image);
//uploadButton = SDL_LoadBMP("uploadbutton.bmp");
//buttonTexture = SDL_CreateTextureFromSurface(rendererUploader, uploadButton);
SDL_SetRenderDrawColor(rendererUploader, 255, 255, 255, 0);
SDL_RenderClear(rendererUploader);
SDL_Rect imageRect = { 0 , 0, width, height };
SDL_RenderCopy(rendererUploader, imageTexture, NULL, &imageRect);
//SDL_Rect buttonRect = { width - (ButtonWidth + 13), height + 13, ButtonWidth, ButtonHeight };
//SDL_RenderCopy(rendererUploader, buttonTexture, NULL, &buttonRect);
//add buttons
uploadButton = Button(width - (ButtonWidth + 13), height + 13, ButtonWidth, ButtonHeight, "UploadButtonSprite.bmp");
uploadButton.show(rendererUploader);
SDL_RenderPresent(rendererUploader);
uploaderRunning = true;
initKeyBindings();
}
示例8: visible
Menu::Menu() :
visible(true)
{
onCredits = false;
bg.LoadFromFile("img/menubg.png");
title.LoadFromFile("img/title.png");
float bx = 310, by = 430;
bLvl1 = Button(bx, by);
bLvl1.setText("Initiation");
bLvl1.setCallback(Menu::initLevel1);
by += 25;
bLvl2 = Button(bx, by);
bLvl2.setText("La tourmente");
bLvl2.setCallback(Menu::initLevel2);
by += 25;
bLvl3 = Button(bx, by);
bLvl3.setText("Challenge++");
bLvl3.setCallback(Menu::initLevel3);
by += 25;
bShowCredits = Button(580,715);
bShowCredits.setCallback(Menu::actionShowCredits);
bShowCredits.setText("Credits");
bHideCredits = Button(580,715);
bHideCredits.setCallback(Menu::actionHideCredits);
bHideCredits.setText("Retour");
}
示例9: button_test
LevelEditorMenu::LevelEditorMenu(ResourceManager* resourceManager) :
button_test(sf::Vector2f(10.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/test.png")),
button_save(sf::Vector2f(202.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/save.png")),
button_tiles(sf::Vector2f(394.0f, 10.0f), resourceManager->getTexture("Graphics/Menu/tiles.png")),
button_clear(sf::Vector2f(202.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/clear.png")),
button_toggleGrid(sf::Vector2f(10.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/toggle_grid.png")),
button_toggleCollisionLines(sf::Vector2f(394.0f, 45.0f), resourceManager->getTexture("Graphics/Menu/toggle_collision_lines.png"))
{
items.push_back(&button_save);
items.push_back(&button_test);
items.push_back(&button_tiles);
items.push_back(&button_toggleGrid);
items.push_back(&button_clear);
items.push_back(&button_toggleCollisionLines);
//! Buttons for button_tiles
float blockPosX = 10.0f, blockPosY = 80.0f;
for (int i = 0; i < BUTTONT_TILES_CHILDS_SIZE - 1; ++i) //! First 3 buttons are blocks
{
std::stringstream ss; ss << i + 1;
button_tiles_childs[i] = Button(sf::Vector2f(blockPosX, blockPosY), resourceManager->getTexture("Graphics/Menu/block" + ss.str() + ".png"));
blockPosX += 60.0f;
}
button_tiles_childs[3] = Button(sf::Vector2f(190.0f, 95.0f), resourceManager->getTexture("Graphics/Menu/collision_pointer.png"), nullptr, false);
for (int i = 0; i < BUTTONT_TILES_CHILDS_SIZE; ++i)
button_tiles.items.push_back(&button_tiles_childs[i]);
}
示例10: Button
MainMenu::MainMenu() {
playButton = Button(325,400,150,50,sf::Color(97,56,11),"New");
loadButton = Button(325,280,150,50,sf::Color(97,56,11),"Load");
title = sf::Text();
title.setString("Splunk");
title.setCharacterSize(50);
title.setFont(ResourceManager::PixelFont);
}
示例11: Button
NS_IMETHODIMP
TaskbarPreviewButton::SetHasBorder(PRBool hasBorder) {
if (hasBorder)
Button().dwFlags &= ~THBF_NOBACKGROUND;
else
Button().dwFlags |= THBF_NOBACKGROUND;
return Update();
}
示例12: setName
Options::Options(std::string menuName)
{
setName(menuName);
menuButtons = std::vector<Button>();
menuButtons.push_back(Button(73, 79, 230, 255, 400, 100, 100, 100, "Option1", "Option 1",12));
menuButtons.push_back(Button(135, 230, 84, 255, 400, 100, 100, 210, "Option2", "Option2",12));
menuButtons.push_back(Button(230, 78, 68, 255, 400, 100, 100, 320, "Back", "Go Back",12));
};
示例13: safe_new
void SongControl::showGui() {
if (_gui)
_gui->deleteMe();
_gui = safe_new(Frame(_gui_parent, 0, 0, 0, 0, 1));
safe_new(Button(_gui, 0, 0, "Play", playAction()));
safe_new(Button(_gui, 0, 0, "Stop", stopAction()));
safe_new(Button(_gui, 0, 0, "Plus", increaseTempoAction()));
safe_new(Button(_gui, 0, 0, "Minus", decreaseTempoAction()));
_gui->packHorizontally(5);
}
示例14: visible
IngameMenu::IngameMenu() :
visible(false)
{
float bx = 310, by = 250;
bQuit = Button(bx, by);
bQuit.setText("Quitter");
bQuit.setCallback(IngameMenu::quitAction);
by += 25;
bCancel = Button(bx, by);
bCancel.setText("Annuler");
bCancel.setCallback(IngameMenu::cancelAction);
by += 25;
}
示例15: NS_ENSURE_SUCCESS
NS_IMETHODIMP
TaskbarPreviewButton::SetImage(imgIContainer *img) {
if (Button().hIcon)
::DestroyIcon(Button().hIcon);
if (img) {
nsresult rv;
rv = nsWindowGfx::CreateIcon(img, false, 0, 0,
nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon),
&Button().hIcon);
NS_ENSURE_SUCCESS(rv, rv);
} else {
Button().hIcon = nullptr;
}
return Update();
}