void Initialize(ID3D11Device* device) { TwBar* tweakBar = Settings.TweakBar(); EnableSun.Initialize(tweakBar, "EnableSun", "Sun Light", "Enable Sun", "Enables the sun light", true); Settings.AddSetting(&EnableSun); SunAreaLightApproximation.Initialize(tweakBar, "SunAreaLightApproximation", "Sun Light", "Sun Area Light Approximation", "Controls whether the sun is treated as a disc area light in the real-time shader", true); Settings.AddSetting(&SunAreaLightApproximation); SunTintColor.Initialize(tweakBar, "SunTintColor", "Sun Light", "Sun Tint Color", "The color of the sun", Float3(1.0000f, 1.0000f, 1.0000f), false, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ColorUnit::None); Settings.AddSetting(&SunTintColor); SunIntensityScale.Initialize(tweakBar, "SunIntensityScale", "Sun Light", "Sun Intensity Scale", "Scale the intensity of the sun", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunIntensityScale); SunSize.Initialize(tweakBar, "SunSize", "Sun Light", "Sun Size", "Angular radius of the sun in degrees", 0.2700f, 0.0100f, 340282300000000000000000000000000000000.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunSize); NormalizeSunIntensity.Initialize(tweakBar, "NormalizeSunIntensity", "Sun Light", "Normalize Sun Intensity", "", false); Settings.AddSetting(&NormalizeSunIntensity); SunDirType.Initialize(tweakBar, "SunDirType", "Sun Light", "Sun Dir Type", "Input direction type for the sun", SunDirectionTypes::UnitVector, 2, SunDirectionTypesLabels); Settings.AddSetting(&SunDirType); SunDirection.Initialize(tweakBar, "SunDirection", "Sun Light", "Sun Direction", "Director of the sun", Float3(-0.7500f, 0.9770f, -0.4000f)); Settings.AddSetting(&SunDirection); SunAzimuth.Initialize(tweakBar, "SunAzimuth", "Sun Light", "Sun Azimuth", "Angle around the horizon", 0.0000f, 0.0000f, 360.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunAzimuth); SunElevation.Initialize(tweakBar, "SunElevation", "Sun Light", "Sun Elevation", "Elevation of sun from ground. 0 degrees is aligned on the horizon while 90 degrees is directly overhead", 0.0000f, 0.0000f, 90.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunElevation); Turbidity.Initialize(tweakBar, "Turbidity", "Sky", "Turbidity", "Atmospheric turbidity (thickness) uses for procedural sun and sky model", 2.0000f, 1.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&Turbidity); GroundAlbedo.Initialize(tweakBar, "GroundAlbedo", "Sky", "Ground Albedo", "Ground albedo color used for procedural sun and sky model", Float3(0.5000f, 0.5000f, 0.5000f), false, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ColorUnit::None); Settings.AddSetting(&GroundAlbedo); MSAAMode.Initialize(tweakBar, "MSAAMode", "Anti Aliasing", "MSAAMode", "MSAA mode to use for full-resolution rendering", MSAAModes::MSAANone, 2, MSAAModesLabels); Settings.AddSetting(&MSAAMode); FilterSize.Initialize(tweakBar, "FilterSize", "Anti Aliasing", "Filter Size", "Filter radius for MSAA resolve", 2.0000f, 0.0000f, 6.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&FilterSize); EnableAlbedoMaps.Initialize(tweakBar, "EnableAlbedoMaps", "Scene", "Enable Albedo Maps", "Enables albedo maps", true); Settings.AddSetting(&EnableAlbedoMaps); EnableNormalMaps.Initialize(tweakBar, "EnableNormalMaps", "Scene", "Enable Normal Maps", "Enables normal maps", true); Settings.AddSetting(&EnableNormalMaps); NormalMapIntensity.Initialize(tweakBar, "NormalMapIntensity", "Scene", "Normal Map Intensity", "Intensity of the normal map", 0.5000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NormalMapIntensity); DiffuseIntensity.Initialize(tweakBar, "DiffuseIntensity", "Scene", "Diffuse Intensity", "Diffuse albedo intensity parameter for the material", 0.7500f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&DiffuseIntensity); Roughness.Initialize(tweakBar, "Roughness", "Scene", "Specular Roughness", "Specular roughness parameter for the material", 0.2500f, 0.0010f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&Roughness); SpecularIntensity.Initialize(tweakBar, "SpecularIntensity", "Scene", "Specular Intensity", "Specular intensity parameter for the material", 0.0400f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SpecularIntensity); NumParticles.Initialize(tweakBar, "NumParticles", "Particles", "Num Particles (x1024)", "The number of particles to render, in increments of 1024", 8, 0, 32); Settings.AddSetting(&NumParticles); EmitRadius.Initialize(tweakBar, "EmitRadius", "Particles", "Emit Radius", "The radius in which to emit particles", 2.0000f, 0.0100f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitRadius); EmitCenterX.Initialize(tweakBar, "EmitCenterX", "Particles", "Emit Center X", "The X coordinate of the point from which to emit particles", 0.0000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterX); EmitCenterY.Initialize(tweakBar, "EmitCenterY", "Particles", "Emit Center Y", "The Y coordinate of the point from which to emit particles", 2.5000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterY); EmitCenterZ.Initialize(tweakBar, "EmitCenterZ", "Particles", "Emit Center Z", "The Z coordinate of the point from which to emit particles", 0.0000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterZ); RotationSpeed.Initialize(tweakBar, "RotationSpeed", "Particles", "Rotation Speed", "Controls how fast to rotate the particles around the emitter center", 0.5000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&RotationSpeed); AbsorptionScale.Initialize(tweakBar, "AbsorptionScale", "Particles", "Absorption Scale", "Scaled the absorption coefficient used for particle self-shadowing", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&AbsorptionScale); SortParticles.Initialize(tweakBar, "SortParticles", "Particles", "Sort Particles", "Enables sorting each particle by their depth", true); Settings.AddSetting(&SortParticles); EnableParticleAlbedoMap.Initialize(tweakBar, "EnableParticleAlbedoMap", "Particles", "Enable Particle Albedo Map", "Enables or disables sampling an albedo map in the particle pixel shader", true); Settings.AddSetting(&EnableParticleAlbedoMap); BillboardParticles.Initialize(tweakBar, "BillboardParticles", "Particles", "Billboard Particles", "Enables or disabled billboarding of particles towards the camera", true); Settings.AddSetting(&BillboardParticles); RenderLowRes.Initialize(tweakBar, "RenderLowRes", "Particles", "Render Low-Res", "Renders the particles at half resolution", true); Settings.AddSetting(&RenderLowRes); LowResRenderMode.Initialize(tweakBar, "LowResRenderMode", "Particles", "Low-Res Render Mode", "Specifies the technique to use for upscaling particles from half resolution", LowResRenderModes::MSAA, 2, LowResRenderModesLabels); Settings.AddSetting(&LowResRenderMode); ResolveSubPixelThreshold.Initialize(tweakBar, "ResolveSubPixelThreshold", "Particles", "Resolve Sub-Pixel Threshold", "Threshold used during low-resolution resolve for determining pixels containing sub-pixel edges", 0.0250f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ResolveSubPixelThreshold); CompositeSubPixelThreshold.Initialize(tweakBar, "CompositeSubPixelThreshold", "Particles", "Composite Sub-Pixel Threshold", "Threshold used during low-resolution composite for determining pixels containing sub-pixel edges", 0.1000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CompositeSubPixelThreshold); ProgrammableSamplePoints.Initialize(tweakBar, "ProgrammableSamplePoints", "Particles", "Programmable Sample Points", "Use programmable sample positions when rendering low-resolution particles with 'MSAA' mode", true); Settings.AddSetting(&ProgrammableSamplePoints); ProgrammableSamplePoints.SetVisible(false); NearestDepthThreshold.Initialize(tweakBar, "NearestDepthThreshold", "Particles", "Nearest-Depth Threshold", "Depth threshold to use for nearest-depth upsampling", 0.2500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NearestDepthThreshold); BloomExposure.Initialize(tweakBar, "BloomExposure", "Post Processing", "Bloom Exposure Offset", "Exposure offset applied to generate the input of the bloom pass", -4.0000f, -10.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomExposure); BloomMagnitude.Initialize(tweakBar, "BloomMagnitude", "Post Processing", "Bloom Magnitude", "Scale factor applied to the bloom results when combined with tone-mapped result", 1.0000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomMagnitude); BloomBlurSigma.Initialize(tweakBar, "BloomBlurSigma", "Post Processing", "Bloom Blur Sigma", "Sigma parameter of the Gaussian filter used in the bloom pass", 2.5000f, 0.5000f, 2.5000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomBlurSigma); EnableVSync.Initialize(tweakBar, "EnableVSync", "Debug", "Enable VSync", "Enables or disables vertical sync during Present", true); Settings.AddSetting(&EnableVSync); TakeScreenshot.Initialize(tweakBar, "TakeScreenshot", "Debug", "Take Screenshot", "Captures the screen output (before HUD rendering), and saves it to a file"); Settings.AddSetting(&TakeScreenshot); ShowMSAAEdges.Initialize(tweakBar, "ShowMSAAEdges", "Debug", "Show MSAAEdges", "When using MSAA low-res render mode, shows pixels that use subpixel data", false); Settings.AddSetting(&ShowMSAAEdges); TwHelper::SetOpened(tweakBar, "Sun Light", false); TwHelper::SetOpened(tweakBar, "Sky", false); TwHelper::SetOpened(tweakBar, "Anti Aliasing", false); TwHelper::SetOpened(tweakBar, "Scene", false); TwHelper::SetOpened(tweakBar, "Particles", true); TwHelper::SetOpened(tweakBar, "Post Processing", false); TwHelper::SetOpened(tweakBar, "Debug", true); CBuffer.Initialize(device); }
void ProjectGiraffeTab4::showProfile(void) { RemoveAllControls(); //add scroll panel ScrollPanel *scrollPanel = new ScrollPanel(); scrollPanel->Construct(Rectangle(0, 160, GetBounds().width, GetBounds().height - 160)); User *cUser = User::currentUser(); // Avatar button? image? Button* avatarButton = new Button(); avatarButton->Construct(Rectangle(10, 10, 250, 250), ""); avatarButton->SetName("avatarButton"); avatarButton->SetActionId(ID_BUTTON_AVATAR); avatarButton->AddActionEventListener(*this); AddControl(*avatarButton); if (_avatarContextMenu == null) { _avatarContextMenu = new ContextMenu(); _avatarContextMenu->Construct(Point(135, 420), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD); _avatarContextMenu->AddItem("Choose from library", ID_CONTEXT_CHOOSE); _avatarContextMenu->AddItem("Take photo", ID_CONTEXT_TAKE); _avatarContextMenu->AddActionEventListener(*this); _avatarContextMenu->SetShowState(false); _avatarContextMenu->Invalidate(true); } Label* usernameLabel = new Label(); usernameLabel->Construct(Rectangle(270, 10, GetBounds().width - 20, 60), cUser->username()); usernameLabel->SetTextConfig(48, LABEL_TEXT_STYLE_BOLD); usernameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); usernameLabel->SetName("usernameLabel"); AddControl(*usernameLabel); Label* postsLabel = new Label(); postsLabel->Construct(Rectangle(270, 80, GetBounds().width/3, 40), "posts"); postsLabel->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD); postsLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); postsLabel->SetName("postsLabel"); AddControl(*postsLabel); /* // logout button Button* logoutButton = new Button(); logoutButton->Construct(Rectangle(GetBounds().width/2 + 30, 10, 300, 80), "Logout"); // centerHorizontally(updateButton1, this); logoutButton->SetName("logoutButton"); logoutButton->SetActionId(ID_BUTTON_LOGOUT); logoutButton->AddActionEventListener(*this); scrollPanel->AddControl(*logoutButton); // Avatar button? image? Button* avatarButton = new Button(); avatarButton->Construct(Rectangle(10, 10, 250, 250), ""); avatarButton->SetName("avatarButton"); avatarButton->SetActionId(ID_BUTTON_AVATAR); avatarButton->AddActionEventListener(*this); scrollPanel->AddControl(*avatarButton); if (_avatarContextMenu == null) { _avatarContextMenu = new ContextMenu(); _avatarContextMenu->Construct(Point(135, 420), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD); _avatarContextMenu->AddItem("Choose from library", ID_CONTEXT_CHOOSE); _avatarContextMenu->AddItem("Take photo", ID_CONTEXT_TAKE); _avatarContextMenu->AddActionEventListener(*this); _avatarContextMenu->SetShowState(false); _avatarContextMenu->Invalidate(true); } */ // Create tableView _tableView = new TableView(); _tableView->Construct(Rectangle(0,270,GetBounds().width, GetBounds().height-270), \ true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); _tableView->SetItemProvider(this); _tableView->AddTableViewItemEventListener(*this); AddControl(*_tableView); _items = new (std::nothrow) ArrayList(); updateItems(); Draw(); }
void circle_push(){ kind.hide(); shapes.push_back(new Circle(Point(inbox_x.get_int(), inbox_y.get_int()), radius)); attach(shapes[shapes.size()-1]); menu.show(); }
void Frame::reconfigure() { // Calculate own position displayX = posX + marginX; displayY = posY + marginY; // Are there buttons in the first place? if (buttons.size() > 0) { int currentX = displayX; int currentY = displayY; // Add the largest distance (padding or button margin) to the starting position if (buttons[0].marginX > paddingX) { currentX += buttons[0].marginX; } else { currentX += paddingX; } // Calculate sizes and positions for the buttons for (int i = 0; i < buttons.size(); i++) { Button* b = &buttons[i]; b->calcMinSize(); int buttonWidth = b->getMinWidth(); int buttonHeight = b->getMinHeight(); int buttonX = currentX; int buttonY; if (b->marginY > paddingY) { buttonY = currentY + b->marginY; } else { buttonY = currentY + paddingY; } b->reconfigure(buttonX, buttonY, buttonWidth, buttonHeight); currentX += b->getDisplayWidth(); // If button is not the last button if (i < buttons.size()-1) { if (b->marginX > buttons[i+1].marginX) { currentX += b->marginX; } else { currentX += buttons[i+1].marginX; } } else { if (b->marginX > paddingX) { displayWidth = currentX + b->marginX - displayX; } else { displayWidth = currentX + paddingX - displayX; } } int totalHeight = 0; // Get the total height of the button, displayHeight + margin or padding if (b->marginY > paddingY) { totalHeight = 2*b->marginY + b->getDisplayHeight(); } else { totalHeight = 2*paddingX + b->getDisplayHeight(); } // Figure out the height of the frame if (totalHeight > displayHeight) { displayHeight = totalHeight; } } } else { // There are no buttons displayWidth = 2*paddingX; displayHeight = 2*paddingY; } }
int main() { // Initializing GRRLIB GRRLIB_Init(); // Initializing Wiimotes WPAD_Init(); // IR init rmode = VIDEO_GetPreferredMode(NULL); GXRModeObj *rmode = IR_Init(); WPAD_SetVRes(WPAD_CHAN_ALL,rmode->fbWidth,rmode->xfbHeight); WPAD_SetDataFormat(WPAD_CHAN_0,WPAD_FMT_BTNS_ACC_IR); //IR pointer ir_t irPointer; // Data textures GRRLIB_texImg * texFont = GRRLIB_LoadTexture(font_png); GRRLIB_InitTileSet(texFont, 8, 16, 0); GRRLIB_texImg* pointer = GRRLIB_LoadTexture(pointer_png); GRRLIB_SetMidHandle(pointer,true); // Objects Button left; left.initButton(0, maxY/2, 15, 60); Button right; right.initButton(maxX-15, maxY/2, 15, 60); Circle move; move.initCircle(maxX/2, maxY/2, 10); // Globals variables bool finProgramme = false; int pass = 0; float b=0.0; float speed = 3; int scoreL = 0; int scoreR = 0; while (!finProgramme){ WPAD_ScanPads(); //Scan wiimotes WPAD_IR(WPAD_CHAN_0, &irPointer); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) finProgramme = true; //==================== DRAW START ======================== GRRLIB_Rectangle(left.x, left.y, left.width, left.height, 0xFF0000FF, 1); GRRLIB_Rectangle(right.x, right.y, right.width, right.height, 0x00FF00FF, 1); GRRLIB_Circle(move.x, move.y, move.radius, CLR_WHITE, 2); //GRRLIB_DrawImg(irPointer.x, irPointer.y, pointer, 0, 1, 1, CLR_WHITE); //GRRLIB_DrawImg(0,0,titlescreen,0,1,1,CLR_UNKNOW); char* posX =(char*)malloc(sizeof(char)); char* posY =(char*)malloc(sizeof(char)); char* showScoreL = (char*)malloc(sizeof(char)); char* showScoreR = (char*)malloc(sizeof(char)); sprintf(posX,"%.3f",irPointer.x); sprintf(posY,"%.3f",irPointer.y); sprintf(showScoreL, "%d", scoreL); sprintf(showScoreR, "%d", scoreR); GRRLIB_Printf(20 + 15, 16 + 15, texFont, CLR_WHITE, 2, posX); GRRLIB_Printf(20 + 15, 16 + 60, texFont, CLR_WHITE, 2, posY); GRRLIB_Printf(300, 50, texFont, 0xFF0000FF, 2, showScoreL); GRRLIB_Printf(340, 50, texFont, 0x00FF00FF, 2, showScoreR); free(posX); free(posY); free(showScoreL); free(showScoreR); GRRLIB_Render(); //================== DRAW END ============================== // Calculate the new positions, speeds, etc… isMoving(move, right, left, pass, speed, b); // Move the player's pointer bMove(right, irPointer); // Move the IA player ia(left, move, speed); // If the ball reaches one side of the screen, // Start a new game and count the points ! if(move.x - move.radius > maxX) { scoreL += 1; move.x = maxX/2; move.y = maxY/2; b = 0.0; pass = 0; speed = 3; } if (move.x + move.radius < 0) { scoreR += 1; move.x = maxX/2; move.y = maxY/2; b = 0.0; pass = 0; speed = 3; } } // Clean memory GRRLIB_Exit(); exit(0); }
Control* Button::create(Theme::Style* style, Properties* properties) { Button* button = new Button(); button->initialize("Button", style, properties); return button; }
void WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc) { for (const auto &i : waypoint.files_embed) { if (images.full()) break; TCHAR path[MAX_PATH]; LocalPath(path, i.c_str()); if (!images.append().LoadFile(path)) images.shrink(images.size() - 1); } const Layout layout(rc, waypoint); WindowStyle dock_style; dock_style.Hide(); dock_style.ControlParent(); WindowStyle button_style; button_style.Hide(); button_style.TabStop(); if (allow_navigation) goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button, button_style, *this, GOTO); if (!images.empty()) { magnify_button.Create(parent, layout.magnify_button, button_style, new SymbolButtonRenderer(look.button, _T("+")), *this, MAGNIFY); shrink_button.Create(parent, layout.shrink_button, button_style, new SymbolButtonRenderer(look.button, _T("-")), *this, SHRINK); } if (allow_navigation) { previous_button.Create(parent, layout.previous_button, button_style, new SymbolButtonRenderer(look.button, _T("<")), *this, PREVIOUS); next_button.Create(parent, layout.next_button, button_style, new SymbolButtonRenderer(look.button, _T(">")), *this, NEXT); } close_button.Create(parent, look.button, _("Close"), layout.close_button, button_style, dialog, mrOK); info_dock.Create(parent, layout.main, dock_style); info_dock.SetWidget(&info_widget); details_panel.Create(parent, look, layout.main, dock_style); details_text.Create(details_panel, layout.details_text); details_text.SetFont(look.text_font); details_text.SetText(waypoint.details.c_str()); #ifdef HAVE_RUN_FILE const unsigned num_files = std::distance(waypoint.files_external.begin(), waypoint.files_external.end()); if (num_files > 0) { file_list.Create(details_panel, layout.file_list, WindowStyle(), layout.file_list_item_height); file_list.SetItemRenderer(&file_list_handler); file_list.SetCursorHandler(&file_list_handler); file_list.SetLength(num_files); } #endif commands_dock.Create(parent, layout.main, dock_style); commands_dock.SetWidget(&commands_widget); if (!images.empty()) image_window.Create(parent, layout.main, dock_style, [this](Canvas &canvas, const PixelRect &rc){ OnImagePaint(canvas, rc); }); last_page = 2 + images.size(); }
void ExportTemplateManager::_update_template_list() { while (current_hb->get_child_count()) { memdelete(current_hb->get_child(0)); } while (installed_vb->get_child_count()) { memdelete(installed_vb->get_child(0)); } DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir()); d->list_dir_begin(); Set<String> templates; if (err == OK) { bool isdir; String c = d->get_next(&isdir); while (c != String()) { if (isdir && !c.begins_with(".")) { templates.insert(c); } c = d->get_next(&isdir); } } d->list_dir_end(); memdelete(d); String current_version = VERSION_FULL_CONFIG; Label *current = memnew(Label); current->set_h_size_flags(SIZE_EXPAND_FILL); current_hb->add_child(current); if (templates.has(current_version)) { current->add_color_override("font_color", get_color("success_color", "Editor")); Button *redownload = memnew(Button); redownload->set_text(TTR("Re-Download")); current_hb->add_child(redownload); redownload->connect("pressed", this, "_download_template", varray(current_version)); Button *uninstall = memnew(Button); uninstall->set_text(TTR("Uninstall")); current_hb->add_child(uninstall); current->set_text(current_version + " " + TTR("(Installed)")); uninstall->connect("pressed", this, "_uninstall_template", varray(current_version)); } else { current->add_color_override("font_color", get_color("error_color", "Editor")); Button *redownload = memnew(Button); redownload->set_text(TTR("Download")); redownload->connect("pressed", this, "_download_template", varray(current_version)); current_hb->add_child(redownload); current->set_text(current_version + " " + TTR("(Missing)")); } for (Set<String>::Element *E = templates.back(); E; E = E->prev()) { HBoxContainer *hbc = memnew(HBoxContainer); Label *version = memnew(Label); version->set_modulate(get_color("disabled_font_color", "Editor")); String text = E->get(); if (text == current_version) { text += " " + TTR("(Current)"); } version->set_text(text); version->set_h_size_flags(SIZE_EXPAND_FILL); hbc->add_child(version); Button *uninstall = memnew(Button); uninstall->set_text(TTR("Uninstall")); hbc->add_child(uninstall); uninstall->connect("pressed", this, "_uninstall_template", varray(E->get())); installed_vb->add_child(hbc); } }
void GameMenu::createBlocks() { int fontSize = 17; this->font = new Font("../src/fonts/Coalition.ttf",fontSize); // std::vector<glm::vec3> kolory; // kolory ={ // glm::vec3(0.612, 0, 0), // }; // std::vector<std::string> nazwy; // nazwy = { // "Player 1" // }; // int caterpillars = 1; float pionowyMargines,poziomyMargines; pionowyMargines = 10.0f; poziomyMargines = -10.0f; float temp = (60.0f/2000.0f)*this->listaSpritowFG[0]->size.y/2; this->blockHeight = (this->listaSpritowBG[0]->size.y -((this->listaButtonow[0]->pos.y/2 - this->listaSpritowBG[0]->pos.y/2 - temp)+this->listaButtonow[0]->size.y)-poziomyMargines)/4.0f; // back->addTextM(nazwy[0],-back->size.x/2+this->font->length(nazwy[0],1.0f)/2.0+2*pionowyMargines,0.0f,1.0f,glm::vec3(1.0f,1.0f,1.0f)); // back->addTextM(tekst,back->pos.x+this->font->length(tekst,1.0f)/2.0+2*pionowyMargines+40.0f,0.0f,1.0f,glm::vec3(1.0f,1.0f,1.0f)); // std::cout << "Tworzenie plusa" << std::endl; // Button *plus = new Button(this->buttonCount,0.0f,0.0f,25.0f,25.0f,"../src/img/plus.png",increase); // plus->setTraM(back->teksty[0]->x+this->font->length(tekst,1.0f)+1,0.0f,0.8f); // plus->setTraM(back->teksty[0]->x , back->teksty[0]->y,0.8f); int playerCount = Setting::getInstance().players.size(); int tempCount = this->buttonCount; this->blocks.resize(playerCount); // this->blocks.resize(1); this->moveY = this->listaSpritowBG[0]->size.y/2-this->blockHeight/2-temp-20.0f; for (int i = 0; i < playerCount; i++) { // for (int i = 0; i < 1; i++) { // player newPlayer; this->blocks[i].playerNumber=i; // std::cout << Setting::getInstance().players[i].kolor.x << std::endl; //Tworzenie tla i napisu Sprite *back = new Sprite(this->listaSpritowBG[0]->pos.x + pionowyMargines, -this->blockHeight / 2, this->listaSpritowBG[0]->size.x - 2 * pionowyMargines, this->blockHeight, glm::vec4(Setting::getInstance().players[i].kolor,1.0f)); back->font = this->font; this->blocks[i].back=back; // float moveY = this->listaSpritowBG[0]->size.y/2-back->size.y/2-temp-20.0f; std::string tekst = Setting::getInstance().players[i].nazwa + " - Caterpillars: " + to_string(Setting::getInstance().players[i].caterpillarsCount); // back->setTraM(0.0f,this->moveY,0.4f); // back->addTextLM(tekst, 40.0f, 0.0f, 1.0f, glm::vec3(1.0f, 1.0f, 1.0f)); //PLUS tempCount++; Button *plus = new Button(tempCount, 0.0f, 0.0f, 25.0f, 25.0f, "../src/img/plus.png", increase); plus->binds = i; this->blocks[i].plus = plus; // plus->setTraM(back->teksty[0]->x + this->font->length(back->teksty[0]->text, 1.0f) + 15, this->moveY, 0.8f); plus->kolor.a = 0.6f; //MINUS tempCount++; Button *minus = new Button(tempCount, 0.0f, 0.0f, 25.0f, 25.0f, "../src/img/minus.png", decrease); minus->binds = i; this->blocks[i].minus=minus; // minus->setTraM(back->teksty[0]->x + this->font->length(back->teksty[0]->text, 1.0f) + 15, moveY - 25.0f, 0.8f); minus->kolor.a = 0.6f; // back->addText("Catterpillars: " + to_string(caterpillars),back->teksty[0]->x,back->teksty[0]->y,1.0f,glm::vec3(1.0f,1.0f,1.0f)); // this->listaButtonow.push_back(plus); // this->listaButtonow.push_back(minus); // this->listaSpritowBG.push_back(back); // this->blocks[i].czyRysowac = true; // if(i==0 || i ==3){ // this->kolejnosc.push_back(i); // } // this->kolejnosc.push_back(i); tempCount++; Button *del = new Button(tempCount,(float)-this->blockHeight -40.0f,-back->size.y/2.0f,(float)2.0f*this->blockHeight+80.0f,(float)back->size.y,"../src/img/delete.png",deletePlayer); del->font = this->font; del->addTextM("Delete Player",0.0f,0.0f,1.0f,glm::vec3(0.712, 0, 0)); del->binds = i; del->kolor.a = 0.6f; this->blocks[i].del=del; } tempCount++; this->buttonAdd = new Button(tempCount, this->listaSpritowBG[0]->pos.x + pionowyMargines, -this->blockHeight / 2, this->listaSpritowBG[0]->size.x - 2 * pionowyMargines, this->blockHeight, "../src/img/add.png", addPlayer); this->buttonAdd->kolor.a = 0.6f; // this->buttonAdd->font = this->font; this->buttonAdd->initFont("../src/fonts/Coalition.ttf",fontSize*2-5); this->buttonAdd->addTextM("+ Add new player",0.0f,0.0f,1.0f,glm::vec3(0.412, 0.941, 0.067)); }
void CocosDenshionTest::addButtons() { auto lblMusic = Label::createWithTTF("Control Music", "fonts/arial.ttf", 24); addChildAt(lblMusic, 0.25f, 0.9f); Button *btnPlay = Button::createWithText("play"); btnPlay->onTriggered([]() { SimpleAudioEngine::getInstance()->playBackgroundMusic(MUSIC_FILE, true); }); addChildAt(btnPlay, 0.1f, 0.75f); Button *btnStop = Button::createWithText("stop"); btnStop->onTriggered([]() { SimpleAudioEngine::getInstance()->stopBackgroundMusic(); }); addChildAt(btnStop, 0.25f, 0.75f); Button *btnRewindMusic = Button::createWithText("rewind"); btnRewindMusic->onTriggered([]() { SimpleAudioEngine::getInstance()->rewindBackgroundMusic(); }); addChildAt(btnRewindMusic, 0.4f, 0.75f); Button *btnPause = Button::createWithText("pause"); btnPause->onTriggered([]() { SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); }); addChildAt(btnPause, 0.1f, 0.65f); Button *btnResumeMusic = Button::createWithText("resume"); btnResumeMusic->onTriggered([]() { SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); }); addChildAt(btnResumeMusic, 0.25f, 0.65f); Button *btnIsPlayingMusic = Button::createWithText("is playing"); btnIsPlayingMusic->onTriggered([]() { if (SimpleAudioEngine::getInstance()->isBackgroundMusicPlaying()) CCLOG("background music is playing"); else CCLOG("background music is not playing"); }); addChildAt(btnIsPlayingMusic, 0.4f, 0.65f); auto lblSound = Label::createWithTTF("Control Effects", "fonts/arial.ttf", 24); addChildAt(lblSound, 0.75f, 0.9f); Button *btnPlayEffect = Button::createWithText("play"); btnPlayEffect->onTriggered([this]() { const float pitch = _sliderPitch->getValue(); const float pan = _sliderPan->getValue(); const float gain = _sliderGain->getValue(); _soundId = SimpleAudioEngine::getInstance()->playEffect(EFFECT_FILE, false, pitch, pan, gain); }); addChildAt(btnPlayEffect, 0.6f, 0.8f); Button *btnPlayEffectInLoop = Button::createWithText("play in loop"); btnPlayEffectInLoop->onTriggered([this]() { const float pitch = _sliderPitch->getValue(); const float pan = _sliderPan->getValue(); const float gain = _sliderGain->getValue(); _soundId = SimpleAudioEngine::getInstance()->playEffect(EFFECT_FILE, true, pitch, pan, gain); }); addChildAt(btnPlayEffectInLoop, 0.75f, 0.8f); Button *btnStopEffect = Button::createWithText("stop"); btnStopEffect->onTriggered([this]() { SimpleAudioEngine::getInstance()->stopEffect(_soundId); }); addChildAt(btnStopEffect, 0.9f, 0.8f); Button *btnUnloadEffect = Button::createWithText("unload"); btnUnloadEffect->onTriggered([this]() { SimpleAudioEngine::getInstance()->unloadEffect(EFFECT_FILE); }); addChildAt(btnUnloadEffect, 0.6f, 0.7f); Button *btnPauseEffect = Button::createWithText("pause"); btnPauseEffect->onTriggered([this]() { SimpleAudioEngine::getInstance()->pauseEffect(_soundId); }); addChildAt(btnPauseEffect, 0.75f, 0.7f); Button *btnResumeEffect = Button::createWithText("resume"); btnResumeEffect->onTriggered([this]() { SimpleAudioEngine::getInstance()->resumeEffect(_soundId); }); addChildAt(btnResumeEffect, 0.9f, 0.7f); Button *btnPauseAll = Button::createWithText("pause all"); btnPauseAll->onTriggered([this]() { SimpleAudioEngine::getInstance()->pauseAllEffects(); }); addChildAt(btnPauseAll, 0.6f, 0.6f); Button *btnResumeAll = Button::createWithText("resume all"); btnResumeAll->onTriggered([this]() { SimpleAudioEngine::getInstance()->resumeAllEffects(); }); addChildAt(btnResumeAll, 0.75f, 0.6f); Button *btnStopAll = Button::createWithText("stop all"); btnStopAll->onTriggered([this]() { SimpleAudioEngine::getInstance()->stopAllEffects(); }); addChildAt(btnStopAll, 0.9f, 0.6f); }
UIElement *UserInterface::createElement(SlotType *iter, UIElement* parent) { UIElement *el = nullptr; // ----------- КНОПКА if (iter->choiceValue.button != nullptr) { Button *b = new Button(iter); el = b; buttonIndex[b->getName()] = b; } else if (iter->choiceValue.image != nullptr) { el = new Image(iter); } else if (iter->choiceValue.text != nullptr) { el = new TextLabel(iter); } else if (iter->choiceValue.tableContainer != nullptr) { TableContainer *tabCont = new TableContainer(iter); for (auto subIter : iter->choiceValue.tableContainer->slot) { tabCont->add(createElement(subIter, tabCont)); } tabCont->pack(); el = tabCont; tableIndex[tabCont->getName()] = tabCont; } else if (iter->choiceValue.input != nullptr) { InputField *ipf = new InputField(iter); el = ipf; inputIndex[ipf->getName()] = ipf; } else if (iter->choiceValue.ddlb != nullptr) { DropDownListBox *lb = new DropDownListBox(iter); ddlbIndex[lb->getName()] = lb; el = lb; } else if (iter->choiceValue.context != nullptr) { ButtonContextMenu *b = new ButtonContextMenu(iter); el = b; if (b->getName().size() > 0) { if (contextMenuIndex.find(el->getName()) != contextMenuIndex.end()) { logger.warn("Context Menu with name %s already exists!", el->getName().c_str()); } contextMenuIndex[el->getName()] = b; } } else if (iter->choiceValue.dialog != nullptr) { Dialog *d = new Dialog(iter); for (auto subIter : iter->choiceValue.dialog->slot) { d->add(createElement(subIter)); } el = d; } else if (iter->choiceValue.imagePicker != nullptr) { ImagePicker *ip = new ImagePicker(iter); imagePickerIndex[ip->getName()] = ip; el = ip; } else if (iter->choiceValue.rgb != nullptr) { RGBSlider *s = new RGBSlider(iter); el = s; rgbSliderIndex[s->getName()] = s; } else if (iter->choiceValue.healthbar != nullptr) { el = new Healthbar(iter); } else if (iter->choiceValue.slider != nullptr) { Slider *s = new Slider(iter); el = s; sliderIndex[s->getName()] = s; } else if (iter->choiceValue.checkbox != nullptr) { Checkbox *lb = new Checkbox(iter); checkboxIndex[lb->getName()] = lb; el = lb; } else if (iter->choiceValue.radio != nullptr) { RadioButton *r = new RadioButton(iter); checkboxIndex[r->getName()] = r; el = r; } else if (iter->choiceValue.labelsList!=nullptr){ LabelsList* ll = new LabelsList(iter); el = ll; } else if (iter->choiceValue.lineContainer!=nullptr){ el = new LineContainer(iter); } else if(iter->choiceValue.containerSelector!=nullptr){ ContainerSelector* cs; if(parent==nullptr) { cs = new ContainerSelector(iter,nullptr); }else{ TableContainer *contParent = dynamic_cast<TableContainer *>(parent); if(contParent==nullptr){ logger.error("ContainerSelector [%s] parent can be only TableContainer", iter->name.c_str()); return nullptr; } cs = new ContainerSelector(iter,contParent); } containerSelectorIndex[cs->getName()]=cs; el=cs; } //common atrs if (el != nullptr) { el->setVisible(iter->visible); el->setEnabled(iter->enabled); } return el; }
NpcPostDialog::NpcPostDialog(int npcId): Window(_("NPC")), mNpcId(npcId) { setContentSize(400, 180); // create text field for receiver gcn::Label *senderText = new Label(_("To:")); senderText->setPosition(5, 5); mSender = new TextField; mSender->setPosition(senderText->getWidth() + 5, 5); mSender->setWidth(65); // create button for sending Button *sendButton = new Button(_("Send"), "send", this); sendButton->setPosition(400 - sendButton->getWidth(), 170 - sendButton->getHeight()); Button *cancelButton = new Button(_("Cancel"), "cancel", this); cancelButton->setPosition(sendButton->getX() - (cancelButton->getWidth() + 2), sendButton->getY()); // create textfield for letter mText = new TextBox; mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight())); mText->setEditable(true); // create scroll box for letter text ScrollArea *scrollArea = new ScrollArea(mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, mSender->getHeight() + 5, 380, 140 - (mSender->getHeight() + sendButton->getHeight()))); add(senderText); add(mSender); add(scrollArea); add(sendButton); add(cancelButton); center(); instances.push_back(this); setVisible(true); PlayerInfo::setNPCPostCount(PlayerInfo::getNPCPostCount() + 1); }
const bool LayerControl::ButtonClicked(const int x, const int y, Button &button) { return ((x > button.GetX() && x < (button.GetX() + CONTROL_BUTTON_WIDTH)) && (y > button.GetX() && y < (button.GetY() + CONTROL_BUTTON_HEIGHT))); }
//Test harness int instinct_main() { //Sets win coordinates, buttons, and quit_count win.coord(0,0,100,100); Button toggle = Button( Point(75,90),"Show / Hide"); Button main = Button(Point(35,40),"Noname BUTTON"); int quit_count = 0; //allows the user to keep clicking until main button is clicked 2 times while(quit_count < 2) { toggle.draw(); main.draw(); win.output_buffer(); Point click = win.get_mouse("Click!"); win.clear_buffer(); //Determines wheather to movie button, hide button, or transform button if(toggle.is_clicked(click) == true) { if(main.is_shown() == true) { main.hide(); } else { main.show(); } } else if(main.is_clicked(click) == true) { main = Button(click,"Click to QUIT"); quit_count++; } if(main.is_shown() == true) { main.center(click); } } return 0; }
EditorFontImportDialog(EditorFontImportPlugin *p_plugin) { plugin=p_plugin; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer); vbc->add_child(hbc); VBoxContainer *vbl = memnew( VBoxContainer ); hbc->add_child(vbl); hbc->set_v_size_flags(SIZE_EXPAND_FILL); vbl->set_h_size_flags(SIZE_EXPAND_FILL); VBoxContainer *vbr = memnew( VBoxContainer ); hbc->add_child(vbr); vbr->set_h_size_flags(SIZE_EXPAND_FILL); source = memnew( LineEditFileChooser ); source->get_file_dialog()->set_access(FileDialog::ACCESS_FILESYSTEM); source->get_file_dialog()->set_mode(FileDialog::MODE_OPEN_FILE); source->get_file_dialog()->add_filter("*.ttf;TrueType"); source->get_file_dialog()->add_filter("*.otf;OpenType"); source->get_line_edit()->connect("text_entered",this,"_src_changed"); vbl->add_margin_child("Source Font:",source); font_size = memnew( SpinBox ); vbl->add_margin_child("Source Font Size:",font_size); font_size->set_min(3); font_size->set_max(256); font_size->set_val(16); font_size->connect("value_changed",this,"_font_size_changed"); dest = memnew( LineEditFileChooser ); // List<String> fl; Ref<Font> font= memnew(Font); dest->get_file_dialog()->add_filter("*.fnt ; Font" ); //ResourceSaver::get_recognized_extensions(font,&fl); //for(List<String>::Element *E=fl.front();E;E=E->next()) { // dest->get_file_dialog()->add_filter("*."+E->get()); //} vbl->add_margin_child("Dest Resource:",dest); HBoxContainer *testhb = memnew( HBoxContainer ); test_string = memnew( LineEdit ); test_string->set_text("The quick brown fox jumps over the lazy dog."); test_string->set_h_size_flags(SIZE_EXPAND_FILL); test_string->set_stretch_ratio(5); testhb->add_child(test_string); test_color = memnew( ColorPickerButton ); test_color->set_color(get_color("font_color","Label")); test_color->set_h_size_flags(SIZE_EXPAND_FILL); test_color->set_stretch_ratio(1); test_color->connect("color_changed",this,"_update_text3"); testhb->add_child(test_color); vbl->add_spacer(); vbl->add_margin_child("Test: ",testhb); HBoxContainer *upd_hb = memnew( HBoxContainer ); // vbl->add_child(upd_hb); upd_hb->add_spacer(); Button *update = memnew( Button); upd_hb->add_child(update); update->set_text("Update"); update->connect("pressed",this,"_update"); options = memnew( _EditorFontImportOptions ); prop_edit = memnew( PropertyEditor() ); vbr->add_margin_child("Options:",prop_edit,true); options->connect("changed",this,"_prop_changed"); prop_edit->hide_top_label(); Panel *panel = memnew( Panel ); vbc->add_child(panel); test_label = memnew( Label ); test_label->set_autowrap(true); panel->add_child(test_label); test_label->set_area_as_parent_rect(); panel->set_v_size_flags(SIZE_EXPAND_FILL); test_string->connect("text_changed",this,"_update_text2"); set_title("Font Import"); timer = memnew( Timer ); add_child(timer); timer->connect("timeout",this,"_update"); timer->set_wait_time(0.4); timer->set_one_shot(true); get_ok()->connect("pressed", this,"_import"); get_ok()->set_text("Import"); error_dialog = memnew ( ConfirmationDialog ); add_child(error_dialog); error_dialog->get_ok()->set_text("Accept"); set_hide_on_ok(false); }
void ListBox::updateLine(bool _reset) { // сбрасываем if (_reset) { mOldSize.clear(); mLastRedrawLine = 0; _resetContainer(false); } // позиция скролла int position = mTopIndex * mHeightLine + mOffsetTop; // если высота увеличивалась то добавляем виджеты if (mOldSize.height < mCoord.height) { int height = (int)mWidgetLines.size() * mHeightLine - mOffsetTop; // до тех пор, пока не достигнем максимального колличества, и всегда на одну больше while ( (height <= (_getClientWidget()->getHeight() + mHeightLine)) && (mWidgetLines.size() < mItemsInfo.size()) ) { // создаем линию Widget* widget = _getClientWidget()->createWidgetT("Button", mSkinLine, 0, height, _getClientWidget()->getWidth(), mHeightLine, Align::Top | Align::HStretch); Button* line = widget->castType<Button>(); // подписываемся на всякие там события line->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); line->eventMouseButtonDoubleClick += newDelegate(this, &ListBox::notifyMouseDoubleClick); line->eventMouseWheel += newDelegate(this, &ListBox::notifyMouseWheel); line->eventMouseSetFocus += newDelegate(this, &ListBox::notifyMouseSetFocus); line->eventMouseLostFocus += newDelegate(this, &ListBox::notifyMouseLostFocus); line->_setContainer(this); // присваиваем порядковый номер, для простоты просчета line->_setInternalData((size_t)mWidgetLines.size()); // и сохраняем mWidgetLines.push_back(line); height += mHeightLine; } // проверяем на возможность не менять положение списка if (position >= mRangeIndex) { // размер всех помещается в клиент if (mRangeIndex <= 0) { // обнуляем, если надо if (position || mOffsetTop || mTopIndex) { position = 0; mTopIndex = 0; mOffsetTop = 0; mLastRedrawLine = 0; // чтобы все перерисовалось // выравниваем int offset = 0; for (size_t pos = 0; pos < mWidgetLines.size(); pos++) { mWidgetLines[pos]->setPosition(0, offset); offset += mHeightLine; } } } else { // прижимаем список к нижней границе int count = _getClientWidget()->getHeight() / mHeightLine; mOffsetTop = mHeightLine - (_getClientWidget()->getHeight() % mHeightLine); if (mOffsetTop == mHeightLine) { mOffsetTop = 0; count --; } int top = (int)mItemsInfo.size() - count - 1; // выравниваем int offset = 0 - mOffsetTop; for (size_t pos = 0; pos < mWidgetLines.size(); pos++) { mWidgetLines[pos]->setPosition(0, offset); offset += mHeightLine; } // высчитываем положение, должно быть максимальным position = top * mHeightLine + mOffsetTop; // если индех изменился, то перерисовываем линии if (top != mTopIndex) { mTopIndex = top; _redrawItemRange(); } } } // увеличился размер, но прокрутки вниз небыло, обновляем линии снизу _redrawItemRange(mLastRedrawLine); } // if (old_cy < mCoord.height) // просчитываем положение скролла if (mWidgetScroll != nullptr) mWidgetScroll->setScrollPosition(position); mOldSize.width = mCoord.width; mOldSize.height = mCoord.height; #if MYGUI_DEBUG_MODE == 1 _checkMapping("ListBox::updateLine"); #endif }
bool QWhatsThisPrivate::eventFilter( QObject * o, QEvent * e ) { if ( !o || !e ) return FALSE; switch( state ) { case FinalPress: if( e->type() == Event_MouseButtonRelease ) { state = Inactive; qApp->removeEventFilter( this ); if ( whatsThat ) whatsThat->hide(); return TRUE; } else if ( e->type() == Event_MouseMove ) { return TRUE; } break; case Displaying: if ( e->type() == Event_MouseButtonPress ) { if ( !qstrcmp( "QWhatsThisPrivate::Button", o->className() ) ) { state = Inactive; qApp->removeEventFilter( this ); } else { state = FinalPress; } if ( whatsThat ) whatsThat->hide(); return TRUE; } else if ( e->type() == Event_MouseButtonRelease || e->type() == Event_MouseMove ) { return TRUE; } else if ( e->type() == Event_Accel ) { if ( whatsThat ) whatsThat->hide(); ((QKeyEvent *)e)->accept(); state = Inactive; qApp->removeEventFilter( this ); } else if ( e->type() == Event_FocusOut || e->type() == Event_FocusIn ) { if ( whatsThat ) whatsThat->hide(); state = Inactive; qApp->removeEventFilter( this ); } break; case Waiting: if ( e->type() == Event_MouseButtonPress && o->isWidgetType() ) { QWidget * w = (QWidget *) o; QWhatsThisPrivate::Item * i = 0; while( w && !i ) { i = dict->find( w ); if ( !i ) w = w->parentWidget(); } QPtrDictIterator<Button> it( *(wt->buttons) ); Button * b; while( (b=it.current()) != 0 ) { ++it; b->setOn( FALSE ); } if ( i ) { state = Displaying; say( w, i->s ); } else { state = FinalPress; } QApplication::restoreOverrideCursor(); return TRUE; } else if ( e->type() == Event_MouseButtonPress || e->type() == Event_MouseMove ) { return TRUE; } else if (e->type() == Event_Accel || e->type() == Event_KeyPress ) { QPtrDictIterator<Button> it( *(wt->buttons) ); Button * b; while( (b=it.current()) != 0 ) { ++it; b->setOn( FALSE ); } QApplication::restoreOverrideCursor(); state = Inactive; qApp->removeEventFilter( this ); } break; case Inactive: if ( e->type() == Event_Accel && ((QKeyEvent *)e)->key() == Key_F1 && !o->parent() && o->isWidgetType() && ((QKeyEvent *)e)->state() == ShiftButton ) { QWidget * w = ((QWidget *)o)->focusWidget(); QWhatsThisPrivate::Item * i = 0; if ( w && (i=dict->find( w )) != 0 && i->s ) { say( w, i->s ); state = Displaying; qApp->installEventFilter( this ); ((QKeyEvent *)e)->accept(); return TRUE; } } break; } return FALSE; }
void AlternatesListWidget::OnActivateItem(unsigned index) { details_button->Click(); }
bool SetFocus() override { if (allow_navigation) goto_button.SetFocus(); return true; }
void Dialog::SpellInfo(const std::string &header, const std::string &message, const Spell & spell, bool ok_button) { Display & display = Display::Get(); const int system = Settings::Get().ExtGameEvilInterface() ? ICN::SYSTEME : ICN::SYSTEM; // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); TextBox box1(header, Font::YELLOW_BIG, BOXAREA_WIDTH); TextBox box2(message, Font::BIG, BOXAREA_WIDTH); Text text(spell.GetName(), Font::SMALL); const Sprite & sprite = AGG::GetICN(ICN::SPELLS, spell.IndexSprite()); const int spacer = Settings::Get().QVGA() ? 5 : 10; FrameBox box(box1.h() + spacer + box2.h() + spacer + sprite.h() + 2 + text.h(), ok_button); Rect pos = box.GetArea(); if(header.size()) box1.Blit(pos); pos.y += box1.h() + spacer; if(message.size()) box2.Blit(pos); pos.y += box2.h() + spacer; // blit sprite pos.x = box.GetArea().x + (pos.w - sprite.w()) / 2; sprite.Blit(pos.x, pos.y); // small text pos.x = box.GetArea().x + (pos.w - text.w()) / 2; pos.y = pos.y + sprite.h() + 2; text.Blit(pos); LocalEvent & le = LocalEvent::Get(); Button* button = NULL; Point pt; if(ok_button) { pt.x = box.GetArea().x + (box.GetArea().w - AGG::GetICN(system, 1).w()) / 2; pt.y = box.GetArea().y + box.GetArea().h - AGG::GetICN(system, 1).h(); button = new Button(pt.x, pt.y, system, 1, 2); } if(button) (*button).Draw(); cursor.Show(); display.Flip(); // message loop while(le.HandleEvents()) { if(!ok_button && !le.MousePressRight()) break; if(button) le.MousePressLeft(*button) ? button->PressDraw() : button->ReleaseDraw(); if(button && le.MouseClickLeft(*button)){ break; } if(HotKeyCloseWindow){ break; } } cursor.Hide(); if(button) delete button; }
void WaypointDetailsWidget::UpdateZoomControls() { magnify_button.SetEnabled(zoom < 5); shrink_button.SetEnabled(zoom > 0); }
void CharacterDisplay::requestFocus() { mButton->requestFocus(); }
ScriptCreateDialog::ScriptCreateDialog() { /* SNAP DIALOG */ VBoxContainer *vb = memnew( VBoxContainer ); add_child(vb); set_child_rect(vb); class_name = memnew( LineEdit ); VBoxContainer *vb2 = memnew( VBoxContainer ); vb2->add_child(class_name); class_name->connect("text_changed", this,"_class_name_changed"); error_label = memnew(Label); error_label->set_text("valid chars: a-z A-Z 0-9 _"); error_label->set_align(Label::ALIGN_CENTER); vb2->add_child(error_label); vb->add_margin_child(TTR("Class Name:"),vb2); parent_name = memnew( LineEdit ); vb->add_margin_child(TTR("Inherits:"),parent_name); parent_name->connect("text_changed", this,"_class_name_changed"); language_menu = memnew( OptionButton ); vb->add_margin_child(TTR("Language"),language_menu); for(int i=0;i<ScriptServer::get_language_count();i++) { language_menu->add_item(ScriptServer::get_language(i)->get_name()); } editor_settings = EditorSettings::get_singleton(); String last_selected_language = editor_settings->get_last_selected_language(); if (last_selected_language != "") for (int i = 0; i < language_menu->get_item_count(); i++) if (language_menu->get_item_text(i) == last_selected_language) { language_menu->select(i); break; } else language_menu->select(0); language_menu->connect("item_selected",this,"_lang_changed"); //parent_name->set_text(); vb2 = memnew( VBoxContainer ); path_vb = memnew( VBoxContainer ); vb2->add_child(path_vb); HBoxContainer *hbc = memnew( HBoxContainer ); file_path = memnew( LineEdit ); file_path->connect("text_changed",this,"_path_changed"); hbc->add_child(file_path); file_path->set_h_size_flags(SIZE_EXPAND_FILL); Button *b = memnew( Button ); b->set_text(" .. "); b->connect("pressed",this,"_browse_path"); hbc->add_child(b); path_vb->add_child(hbc); path_error_label = memnew( Label ); path_vb->add_child( path_error_label ); path_error_label->set_text(TTR("Error!")); path_error_label->set_align(Label::ALIGN_CENTER); internal = memnew( CheckButton ); internal->set_text(TTR("Built-In Script")); vb2->add_child(internal); internal->connect("pressed",this,"_built_in_pressed"); vb->add_margin_child(TTR("Path:"),vb2); set_size(Size2(200,150)); set_hide_on_ok(false); set_title(TTR("Create Node Script")); file_browse = memnew( EditorFileDialog ); file_browse->connect("file_selected",this,"_file_selected"); add_child(file_browse); get_ok()->set_text(TTR("Create")); alert = memnew( AcceptDialog ); add_child(alert); _lang_changed(0); }
void CharacterDisplay::setActive(bool active) { mButton->setEnabled(active); mDelete->setEnabled(active); }
bool LayerButtonInGame::init() { if (!UILayer::init()) return false; this->setAnchorPoint(ccp(0, 0)); this->setPosition(ccp(0, 0)); // UILayer *layerWidget = UILayer::create(); // layerWidget->setAnchorPoint(ccp(0, 0)); // layerWidget->setPosition(ccp(0, 0)); // this->addChild(layerWidget); // Button style 2 int widButton2 = 52; // int heiButton2 = 50; int dis = 10; Button *btnBack = createButtonWith_Style_Position(1, ccp(dis, dis)); Button *btnSetting = createButtonWith_Style_Position(2, ccp(dis * 2 + widButton2, dis)); Button *btnChat = createButtonWith_Style_Position(3, ccp(dis * 3 + widButton2 * 2, dis)); Button *btnCoin = createButtonWith_Style_Position(4, ccp(dis * 4 + widButton2 * 3, dis)); btnBack->setTag(101); btnSetting->setTag(102); btnChat->setTag(103); btnCoin->setTag(104); btnBack->addTouchEventListener(this, toucheventselector(LayerButtonInGame::eventTouchBtnBack)); btnSetting->addTouchEventListener(this, toucheventselector(LayerButtonInGame::eventTouchBtnSetting)); btnChat->addTouchEventListener(this, toucheventselector(LayerButtonInGame::eventTouchBtnChat)); btnCoin->addTouchEventListener(this, toucheventselector(LayerButtonInGame::eventTouchBtnCoin)); this->addWidget(btnBack); this->addWidget(btnSetting); this->addWidget(btnChat); this->addWidget(btnCoin); //Save game ID gameID = GameServer::getSingleton().getSmartFox()->LastJoinedRoom()->GroupId(); return true; }
void VisualShaderEditor::_update_graph() { if (updating) return; if (visual_shader.is_null()) return; graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE); VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); graph->clear_connections(); //erase all nodes for (int i = 0; i < graph->get_child_count(); i++) { if (Object::cast_to<GraphNode>(graph->get_child(i))) { memdelete(graph->get_child(i)); i--; } } static const Color type_color[3] = { Color::html("#61daf4"), Color::html("#d67dee"), Color::html("#f6a86e") }; List<VisualShader::Connection> connections; visual_shader->get_node_connections(type, &connections); Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1); Vector<int> nodes = visual_shader->get_node_list(type); for (int n_i = 0; n_i < nodes.size(); n_i++) { Vector2 position = visual_shader->get_node_position(type, nodes[n_i]); Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]); GraphNode *node = memnew(GraphNode); graph->add_child(node); /*if (!vsnode->is_connected("changed", this, "_node_changed")) { vsnode->connect("changed", this, "_node_changed", varray(vsnode->get_instance_id()), CONNECT_DEFERRED); }*/ node->set_offset(position); node->set_title(vsnode->get_caption()); node->set_name(itos(nodes[n_i])); if (nodes[n_i] >= 2) { node->set_show_close_button(true); node->connect("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED); } node->connect("dragged", this, "_node_dragged", varray(nodes[n_i])); Control *custom_editor = NULL; int port_offset = 0; Ref<VisualShaderNodeUniform> uniform = vsnode; if (uniform.is_valid()) { LineEdit *uniform_name = memnew(LineEdit); uniform_name->set_text(uniform->get_uniform_name()); node->add_child(uniform_name); uniform_name->connect("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i])); uniform_name->connect("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i])); if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") { //shortcut VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0); node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]); continue; } port_offset++; } for (int i = 0; i < plugins.size(); i++) { custom_editor = plugins.write[i]->create_editor(vsnode); if (custom_editor) { break; } } if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) { //will be embedded in first port } else if (custom_editor) { port_offset++; node->add_child(custom_editor); custom_editor = NULL; } for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) { if (vsnode->is_port_separator(i)) { node->add_child(memnew(HSeparator)); port_offset++; } bool valid_left = i < vsnode->get_input_port_count(); VisualShaderNode::PortType port_left = VisualShaderNode::PORT_TYPE_SCALAR; bool port_left_used = false; String name_left; if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().to_node == nodes[n_i] && E->get().to_port == i) { port_left_used = true; } } } bool valid_right = i < vsnode->get_output_port_count(); VisualShaderNode::PortType port_right = VisualShaderNode::PORT_TYPE_SCALAR; String name_right; if (valid_right) { name_right = vsnode->get_output_port_name(i); port_right = vsnode->get_output_port_type(i); } HBoxContainer *hb = memnew(HBoxContainer); Variant default_value; if (valid_left && !port_left_used) { default_value = vsnode->get_input_port_default_value(i); } if (default_value.get_type() != Variant::NIL) { // only a label Button *button = memnew(Button); hb->add_child(button); button->connect("pressed", this, "_edit_port_default_input", varray(button, nodes[n_i], i)); switch (default_value.get_type()) { case Variant::COLOR: { button->set_custom_minimum_size(Size2(30, 0) * EDSCALE); button->connect("draw", this, "_draw_color_over_button", varray(button, default_value)); } break; case Variant::INT: case Variant::REAL: { button->set_text(String::num(default_value, 4)); } break; case Variant::VECTOR3: { Vector3 v = default_value; button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3)); } break; default: {} } } if (i == 0 && custom_editor) { hb->add_child(custom_editor); custom_editor->set_h_size_flags(SIZE_EXPAND_FILL); } else { if (valid_left) { Label *label = memnew(Label); label->set_text(name_left); label->add_style_override("normal", label_style); //more compact hb->add_child(label); } hb->add_spacer(); if (valid_right) { Label *label = memnew(Label); label->set_text(name_right); label->set_align(Label::ALIGN_RIGHT); label->add_style_override("normal", label_style); //more compact hb->add_child(label); } } if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); preview->set_normal_texture(get_icon("GuiVisibilityHidden", "EditorIcons")); preview->set_pressed_texture(get_icon("GuiVisibilityVisible", "EditorIcons")); preview->set_v_size_flags(SIZE_SHRINK_CENTER); if (vsnode->get_output_port_for_preview() == i) { preview->set_pressed(true); } preview->connect("pressed", this, "_preview_select_port", varray(nodes[n_i], i), CONNECT_DEFERRED); hb->add_child(preview); } node->add_child(hb); node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]); } if (vsnode->get_output_port_for_preview() >= 0) { VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview); port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview()); port_preview->set_h_size_flags(SIZE_SHRINK_CENTER); node->add_child(port_preview); } String error = vsnode->get_warning(visual_shader->get_mode(), type); if (error != String()) { Label *error_label = memnew(Label); error_label->add_color_override("font_color", get_color("error_color", "Editor")); error_label->set_text(error); node->add_child(error_label); } } for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { int from = E->get().from_node; int from_idx = E->get().from_port; int to = E->get().to_node; int to_idx = E->get().to_port; graph->connect_node(itos(from), from_idx, itos(to), to_idx); } }
void menu_push(){ menu.hide(); kind.show(); }
void drawOptions() { if(deviceStatus == CHIP_VIEW) { stopButton.draw(); gpsButton.draw(); tempButton.draw(); calibrateButton.draw(); } else if(deviceStatus == GPS_VIEW) { stopButton.draw(); chipButton.setPos(0, 80); chipButton.draw(); tempButton.draw(); } else if(deviceStatus == TEMP_VIEW) { stopButton.draw(); chipButton.setPos(0, 160); chipButton.draw(); gpsButton.draw(); } }
void triangle_push(){ kind.hide(); shapes.push_back(new Regular_polygon(Point(inbox_x.get_int(), inbox_y.get_int()), radius, 3)); attach(shapes[shapes.size() - 1]); menu.show(); }
void AnalysisWidget::SetCalcCaption(const TCHAR *caption) { details_button.SetCaption(caption); SetCalcVisibility(!StringIsEmpty(caption)); }