/* Personalize class */ PersonalizePageComponent::PersonalizePageComponent(): background("lab_back","Background"), icons("lab_icons","Icons management"), opt_back("opt_back",""), opt_name("opt_name", "Name:"), opt_img("opt_img", "Icon path:"), opt_shell("opt_shell", "Command:"), add_btn("Add"), apply("Apply"), choose_back("back_box"), edit_back("back_field"), edit_name("name"), edit_icn("icn"), edit_shell("shell"), config(assetConfigFile("config.json")), json(JSON::parse(config)), success("suc", "Success !") { bgColor = Colour(0xffd23c6d); bgImage = createImageFromFile(assetFile("settingsBackground.png")); Font big_font(Font::getDefaultMonospacedFontName(), 25.f, 0); background.setFont(big_font); icons.setFont(big_font); Font small_font(Font::getDefaultMonospacedFontName(), 17.5f, 0); opt_back.setFont(small_font); opt_name.setFont(small_font); opt_img.setFont(small_font); opt_shell.setFont(small_font); success.setFont(big_font); addAndMakeVisible(background); addAndMakeVisible(icons); addAndMakeVisible(add_btn); addAndMakeVisible(apply); addAndMakeVisible(success); apply.addListener(this); add_btn.addListener(this); /* ComboBox */ choose_back.addItem("Default",1); choose_back.addItem("Color",2); choose_back.addItem("Image",3); choose_back.setSelectedId(1); choose_back.addListener(this); addAndMakeVisible(choose_back); ////////////// /* + */ edit_back.setColour(TextEditor::ColourIds::textColourId, Colour::greyLevel(0.f)); addAndMakeVisible(edit_back); addAndMakeVisible(opt_back); addAndMakeVisible(opt_name); addAndMakeVisible(opt_img); addAndMakeVisible(opt_shell); addAndMakeVisible(edit_name); addAndMakeVisible(edit_icn); addAndMakeVisible(edit_shell); showAddComponents(false); success.setVisible(false); // create back button backButton = createImageButton("Back", createImageFromFile(assetFile("backIcon.png"))); backButton->addListener(this); backButton->setAlwaysOnTop(true); addAndMakeVisible(backButton); }
AppListComponent::AppListComponent() : grid(new Grid(3, 2)), nextPageBtn(createImageButton("NextAppsPage", ImageFileFormat::loadFrom(assetFile("pageDownIcon.png")))), prevPageBtn(createImageButton("PrevAppsPage", ImageFileFormat::loadFrom(assetFile("pageUpIcon.png")))) { addChildComponent(nextPageBtn); addChildComponent(prevPageBtn); nextPageBtn->addListener(this); prevPageBtn->addListener(this); addAndMakeVisible(grid); }
SettingsPageBluetoothComponent::SettingsPageBluetoothComponent() { pageStack = new PageStackComponent(); addAndMakeVisible(pageStack); // create device list "page" deviceListPage = new Grid(1, 4); for (auto btDevice : getBluetoothStatus().devices) { auto item = new BluetoothDeviceListItem(btDevice, &icons); item->addListener(this); deviceListItems.add(item); deviceListPage->addItem(item); } //btIcon = new ImageComponent("BT Icon"); //btIcon->setImage( // ImageFileFormat::loadFrom(BinaryData::bluetoothIcon_png, BinaryData::bluetoothIcon_pngSize)); //addAndMakeVisible(btIcon); // create back button backButton = createImageButton( "Back", createImageFromFile(assetFile("backIcon.png"))); backButton->addListener(this); backButton->setAlwaysOnTop(true); addAndMakeVisible(backButton); // create device connection "page" connectionPage = new Component("Connection Page"); connectionLabel = new Label("Connected", "Connection Label"); connectionLabel->setJustificationType(juce::Justification::centred); connectionLabel->setFont(26); connectionPage->addAndMakeVisible(connectionLabel); connectionButton = new TextButton("Connection Button"); connectionButton->setButtonText("Connect"); connectionButton->addListener(this); connectionPage->addAndMakeVisible(connectionButton); //icons.checkIcon = Drawable::createFromImageData(BinaryData::check_png, BinaryData::check_pngSize); icons.arrowIcon = Drawable::createFromImageFile(assetFile("backIcon.png")); auto xf = AffineTransform::identity.rotated(M_PI); icons.arrowIcon->setTransform(xf); }
void PokeLaunchApplication::initialise(const String &commandLine) { StringArray args; args.addTokens(commandLine, true); if (args.contains("--help")) { std::cerr << "arguments:" << std::endl; std::cerr << " --help: Print usage help" << std::endl; std::cerr << " --fakewifi: Use fake WifiStatus" << std::endl; quit(); } auto configFile = assetFile("config.json"); if (!configFile.exists()) { std::cerr << "Missing config file: " << configFile.getFullPathName() << std::endl; quit(); } auto configJson = JSON::parse(configFile); if (!configJson) { std::cerr << "Could not parse config file: " << configFile.getFullPathName() << std::endl; quit(); } // open sound handle if(!sound()) DBG("Sound failed to initialize"); // Populate with dummy data { if (args.contains("--fakewifi")) wifiStatus = &wifiStatusJson; else wifiStatus = &wifiStatusNM; wifiStatus->initializeStatus(); auto deviceListFile = assetFile("bluetooth.json"); bluetoothStatus.populateFromJson(JSON::parse(deviceListFile)); } mainWindow = new MainWindow(getApplicationName(), configJson); }
LibraryPageComponent::LibraryPageComponent() : AppListComponent(), backButton(createImageButton("Back", createImageFromFile(assetFile("nextIcon.png")))) { bgColor = Colour(PokeLookAndFeel::chipPurple); backButton->addListener(this); backButton->setAlwaysOnTop(true); addAndMakeVisible(backButton); }
hkUint32 hkvFbxAsset::getFbxHash() const { hkRefPtr<hkvAssetTrackedFile> assetFile(getFile()); if (assetFile == NULL) { return 0; } hkUint32 assetHash = assetFile->getStoredHash(); return assetHash + (hkUint32)getFbxTarget(); }
DrawableButton *AppListComponent::createAndOwnIcon(const String &name, const String &iconPath, const String &shell) { auto image = createImageFromFile(assetFile(iconPath)); auto drawable = new DrawableImage(); drawable->setImage(image); // FIXME: is this OwnedArray for the drawables actually necessary? // won't the AppIconButton correctly own the drawable? // Further we don't actually use this list anywhere. iconDrawableImages.add(drawable); auto button = new AppIconButton(name, shell, drawable); addAndOwnIcon(name, button); return button; }
WifiCategoryItemComponent::WifiCategoryItemComponent() : SettingsCategoryItemComponent("wifi"), spinner(new WifiSpinner("SettingsWifiSpinner")) { iconDrawable = Drawable::createFromImageFile(assetFile("wifiIcon.png")); icon->setImages(iconDrawable); bool isEnabled = getWifiStatus().isEnabled(); toggle->setToggleState(isEnabled, NotificationType::dontSendNotification); button->setEnabled(isEnabled); addChildComponent(spinner); updateButtonText(); }
Grid::Grid(int numCols, int numRows) : numCols(numCols), numRows(numRows), selection(new DrawableImage()), selectindex(0) { page = new GridPage(numCols, numRows); pages.add(page); /* We need to put this line here to have the selection * under the icons and not over */ addAndMakeVisible(selection); selection->setVisible(false); addAndMakeVisible(page); //Selection square Image image = createImageFromFile(assetFile("llselection.png")); selection->setImage(image); selection->setName("Select"); // mildly convoluted way of finding proportion of available height to give each row, // accounting for spacer rows which are relatively heighted based on this measure. // First measures row proportion without spacers. rowProp = (1.0f/numRows); // Then find an appropriate relative spacer proportion. rowSpacerProp = rowProp / 8.; // Reduce ideal row proportion by room taken up by spacers. double rowAmountWithoutSpacers = 1.0 - (rowSpacerProp * (numRows - 1)); rowProp = (rowAmountWithoutSpacers / numRows); // columns lack spacers and are trivial to proportion. colProp = (1.0f/numCols); int layoutIdx = 0; for (int i = 0; i < numRows; i++) { rowLayout.setItemLayout(layoutIdx, -rowProp/4, -rowProp, -rowProp); layoutIdx++; // set size preference for spacer if there are rows left in the loop if ((i+1) < numRows) { rowLayout.setItemLayout(layoutIdx, -rowSpacerProp, -rowSpacerProp, -rowSpacerProp); layoutIdx++; } } for (int i = 0; i < numCols; i++) { colLayout.setItemLayout(i, -colProp/4, -colProp, -colProp); } }
hkaSkeleton* gkRigManager::loadRig( const TCHAR* name ) { // check if we had one RigMap::iterator it = m_mapRigs.find(name); if (it != m_mapRigs.end()) { return it->second; } CHAR szPath[MAX_PATH] = ""; #ifdef UNICODE WideCharToMultiByte(CP_ACP, 0, name, -1, szPath, MAX_PATH, NULL, NULL); #else _tcscpy_s( szPath, MAX_PATH, name ); #endif hkStringBuf assetFile(szPath); hkAssetManagementUtil::getFilePath(assetFile); hkRootLevelContainer* container = getAnimationPtr()->getGlobalLoader()->load( szPath ); HK_ASSERT2(0x27343437, container != HK_NULL , "Could not load asset"); if (!container) { return false; } hkaAnimationContainer* ac = reinterpret_cast<hkaAnimationContainer*>( container->findObjectByType( hkaAnimationContainerClass.getName() )); HK_ASSERT2(0x27343435, ac && (ac->m_skeletons.getSize() > 0), "No skeleton loaded"); hkaSkeleton* skeleton = ac->m_skeletons[0]; m_mapRigs.insert(RigMap::value_type(name, skeleton)); return skeleton; }
SettingsPageComponent::SettingsPageComponent(LauncherComponent* lc) { bgColor = Colour(0xffd23c6d); bgImage = createImageFromFile(assetFile("settingsBackground.png")); mainPage = new Component(); addAndMakeVisible(mainPage); mainPage->toBack(); ChildProcess child{}; /* Adding the personalize button */ advancedPage = new AdvancedSettingsPage(lc); advanced = new TextButton("Advanced Settings"); advanced->addListener(this); addAndMakeVisible(advanced); brightness = 8; #if JUCE_LINUX // Get initial brightness value if(child.start("cat /sys/class/backlight/backlight/brightness")) { String result{child.readAllProcessOutput()}; brightness = result.getIntValue(); }; #endif volume = 90; #if JUCE_LINUX // Get initial volume value StringArray cmd{ "amixer","sget","Power Amplifier" }; if(child.start(cmd)) { const String result (child.readAllProcessOutput()); int resultIndex = result.indexOf("[")+1; child.waitForProcessToFinish (5 * 1000); char buff[4]; for (int i = 0; i<4; i++) { char c = result[resultIndex+i]; if( c >= '0' && c <= '9' ) { buff[i]=c; } else { buff[i]=(char)0; } } String newVol = String(buff); volume = newVol.getIntValue(); } #endif ScopedPointer<Drawable> brightLo = Drawable::createFromImageFile(assetFile("brightnessIconLo.png")); ScopedPointer<Drawable> brightHi = Drawable::createFromImageFile(assetFile("brightnessIconHi.png")); screenBrightnessSlider = ScopedPointer<IconSliderComponent>(new IconSliderComponent(*brightLo, *brightHi)); screenBrightnessSlider->addListener(this); screenBrightnessSlider->slider->setValue(1+(brightness-0.09)*10); ScopedPointer<Drawable> volLo = Drawable::createFromImageFile(assetFile("volumeIconLo.png")); ScopedPointer<Drawable> volHi = Drawable::createFromImageFile(assetFile("volumeIconHi.png")); volumeSlider = ScopedPointer<IconSliderComponent>(new IconSliderComponent(*volLo, *volHi)); volumeSlider->addListener(this); volumeSlider->slider->setValue(volume); // create back button backButton = createImageButton( "Back", createImageFromFile(assetFile("backIcon.png"))); backButton->addListener(this); backButton->setAlwaysOnTop(true); addAndMakeVisible(backButton); wifiCategoryItem = new WifiCategoryItemComponent(); wifiCategoryItem->button->addListener(this); addAndMakeVisible(wifiCategoryItem); getWifiStatus().addListener(wifiCategoryItem); addAndMakeVisible(screenBrightnessSlider); addAndMakeVisible(volumeSlider); wifiPage = new SettingsPageWifiComponent(); }
BluetoothCategoryItemComponent::BluetoothCategoryItemComponent() : SettingsCategoryItemComponent("bluetooth") { iconDrawable = Drawable::createFromImageFile(assetFile("bluetoothIcon.png")); icon->setImages(iconDrawable); updateButtonText(); }
PowerPageComponent::PowerPageComponent() { bgColor = Colours::black; bgImage = createImageFromFile(assetFile("powerMenuBackground.png")); mainPage = new Component(); addAndMakeVisible(mainPage); mainPage->toBack(); ChildProcess child{}; felPage = new PowerFelPageComponent(); // create back button backButton = createImageButton( "Back", createImageFromFile(assetFile("nextIcon.png"))); backButton->addListener(this); backButton->setAlwaysOnTop(true); addAndMakeVisible(backButton); powerOffButton = new TextButton("Power OFF"); powerOffButton->setButtonText("Shutdown"); powerOffButton->addListener(this); addAndMakeVisible(powerOffButton); rebootButton = new TextButton("Reboot"); rebootButton->setButtonText("Reboot"); rebootButton->addListener(this); addAndMakeVisible(rebootButton); sleepButton = new TextButton("Sleep"); sleepButton->setButtonText("Sleep"); sleepButton->addListener(this); addAndMakeVisible(sleepButton); felButton = new TextButton("Fel"); felButton->setButtonText("Flash Software"); felButton->addListener(this); addAndMakeVisible(felButton); powerSpinnerTimer.powerComponent = this; Array<String> spinnerImgPaths{"wait0.png","wait1.png","wait2.png","wait3.png","wait4.png","wait5.png","wait6.png","wait7.png"}; for(auto& path : spinnerImgPaths) { auto image = createImageFromFile(assetFile(path)); launchSpinnerImages.add(image); } powerSpinner = new ImageComponent(); powerSpinner->setImage(launchSpinnerImages[0]); addChildComponent(powerSpinner); buildName = "Build: "; auto releaseFileName = absoluteFileFromPath( "/etc/os-release" ); File releaseFile( releaseFileName ); if (releaseFile.exists()) { auto fileStr = releaseFile.loadFileAsString(); auto lines = split(fileStr, "\n"); if (lines.size() < 9) DBG(__func__ << ": No release information in /etc/os-release"); else { auto releaseKv = split(lines[8],"="); std::vector<String> releaseV(releaseKv.begin()+1,releaseKv.end()); for (const auto& val : releaseV) { // WIP: misses the removed equals buildName += val; } DBG(buildName); } } #if JUCE_MAC buildName = "Build: MacOsX Dev Build"; #endif buildNameLabel = new Label("Build Name"); buildNameLabel->setText(buildName, NotificationType::dontSendNotification); buildNameLabel-> setFont(16); buildNameLabel->setJustificationType(Justification::centred); addAndMakeVisible(buildNameLabel); //Create rev Text String rev_string = std::to_string(rev_number); rev = new Label("rev", ("v0.0."+rev_string)); addAndMakeVisible(rev); rev->setAlwaysOnTop(true); rev->setFont(Font(20.f)); //Update button updateButton = new TextButton("Update"); updateButton->setButtonText("Check for updates"); updateButton->setAlwaysOnTop(true); updateButton->addListener(this); addAndMakeVisible(updateButton); updateButton->setVisible(false); //Update window updateWindow = new AlertWindow("Checking for updates", "Downloading informations, please wait...", AlertWindow::AlertIconType::NoIcon); addAndMakeVisible(updateWindow, 10); updateWindow->setAlwaysOnTop(true); updateWindow->setVisible(false); }