Container *AnimationRecipe::setUpControllerContainer() { bool connectResult; Q_UNUSED(connectResult); // The controllerContainer is the bottom part of the animation recipe. // It is where the descriptive text and a toggle button for triggering the // animations are kept. ImagePaint paint(QUrl("asset:///images/background.png"), RepeatPattern::XY); Container *controllerContainer = Container::create().layout(new DockLayout()) .horizontal(HorizontalAlignment::Fill).background(paint) .top(UiValues::instance()->intValue(UiValues::UI_PADDING_STANDARD)) .bottom(UiValues::instance()->intValue(UiValues::UI_PADDING_STANDARD)) .left(UiValues::instance()->intValue(UiValues::UI_PADDING_STANDARD)) .right(UiValues::instance()->intValue(UiValues::UI_PADDING_STANDARD)); // Set up the a Label with a descriptive text. Label *actionLabel = new Label(); actionLabel->setText("More Eggs"); actionLabel->textStyle()->setBase(SystemDefaults::TextStyles::titleText()); // Set up the ToggleButton and connect to its onChanged signal. In // the slot function onToggleChanged, we trigger the animations. ToggleButton *toggle = new ToggleButton(); toggle->setHorizontalAlignment(HorizontalAlignment::Right); connectResult = connect(toggle, SIGNAL(checkedChanged(bool)), this, SLOT(onToggleChanged(bool))); Q_ASSERT(connectResult); controllerContainer->add(actionLabel); controllerContainer->add(toggle); return controllerContainer; }
//----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- TooltipsDemo::TooltipsDemo(Panel *parent, const char *name) : DemoPage(parent, name) { ToggleButton *pButton = new ToggleButton (this, "RadioDesc5", ""); pButton->GetTooltip()->SetTooltipFormatToSingleLine(); LoadControlSettings("Demo/SampleToolTips.res"); }
//============================================================================== void JuceticeLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) { const int tickWidth = jmin (20, button.getHeight() - 4); drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), isMouseOverButton, isButtonDown); g.setColour (button.findColour (ToggleButton::textColourId)); g.setFont (jmin (15.0f, button.getHeight() * 0.6f)); if (! button.isEnabled()) g.setOpacity (0.5f); const int textX = tickWidth + 5; g.drawFittedText (button.getButtonText(), textX, 4, button.getWidth() - textX - 2, button.getHeight() - 8, Justification::centredLeft, 10); }
InstrumentListComponent::InstrumentListComponent (Sequencer* sequencer_) : Component ("InstrumentListComponent"), sequencer (sequencer_), lastPattern (nullptr), lastActiveInstrument (nullptr) { Pattern* pattern = sequencer->getPattern(); lastPattern = pattern; int numInstruments = pattern->getNumInstruments(); for (int i = 0; i < numInstruments; i++) { Instrument* instrument = pattern->getInstrumentAt (i); InstrumentComponent* instrumentComponent = new InstrumentComponent (instrument); addAndMakeVisible (instrumentComponent); instrumentComponents.add (instrumentComponent); } for (int i = 0; i < numInstruments; i++) { ToggleButton* btn = new ToggleButton ((String)i); btn->setRadioGroupId (kRadioGroupId); btn->setColour (ToggleButton::textColourId, Colours::white); addAndMakeVisible (btn); btn->addListener (this); activeButtons.add (btn); } startTimer (100); }
void ToggleButton::ProcessToggleGroup() { if ( m_next && m_next != this ) { // One and only one button can be down. ToggleButton* firstDown = 0; ToggleButton* candidate = 0; if ( this->Down() ) firstDown = this; for( ToggleButton* it = this->m_next; it != this; it = it->m_next ) { if ( firstDown ) it->PriSetUp(); else if ( it->Down() && it->Visible() && it->Enabled() ) firstDown = it; else it->PriSetUp(); if ( !firstDown && it->Visible() && it->Enabled() ) candidate = it; } if ( !firstDown && Visible() && Enabled() ) this->PriSetDown(); else if ( candidate ) candidate->PriSetDown(); else this->PriSetDown(); } }
void SelectableList::addListItem(std::string item) { // TODO Do not add item that already exists. int x{m_xCoordinate + 5}; int y = m_yCoordinate + m_height - (5 + 30 * (1 + m_buttons.size())); int width{m_width - 10}; int height{30}; auto func = [&](int id) { ToggleButton* button = getButtonWithId(id); if (button->isToggled()) { // If there already is a button toggled, untoggle it. if (m_currentlyToggled) m_currentlyToggled->toggle(); m_currentlyToggled = button; } else { // No button is toggled. m_currentlyToggled = nullptr; } }; ToggleButton button = ToggleButton( ++idCounter, x, y, width, height, m_graphicsManager, func, item, m_layer); m_buttons.push_back(std::move(button)); }
bool MyApp::OnInit() { ToggleButton * tb = new ToggleButton(wxT("ToggleButton测试")) ; tb->Centre(); tb->Show(true); return true; }
void vis_settings_panel_impl::set_light(bool on) { CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext(); CEGUI::Window* root = context.getRootWindow(); if (root->isChild(setting_dlg + "/Settings/chkLights")) { ToggleButton* button = static_cast<ToggleButton*>(root->getChild(setting_dlg + "/Settings/chkLights")); return button->setSelected(on); } }
void NTLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown){ float fontSize = jmin (15.0f, button.getHeight() * 0.75f); const int tickWidth = fontSize * 1.6f; drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), isMouseOverButton, isButtonDown); g.setColour (button.findColour (ToggleButton::textColourId)); g.setFont (fontSize); if (! button.isEnabled()) g.setOpacity (0.5f); const int textX = (int) tickWidth + 10; g.drawFittedText (button.getButtonText(), textX, 0, button.getWidth() - textX - 2, button.getHeight(), Justification::centredLeft, 10); }
void onCapture() { if (m_start.isSelected()) { m_start.setText(L"Start"); m_start.setSelected(false); } else { m_webcam.setDriver(m_driver.getSelectedItem()); } m_webcam.capture(); }
void onToggleDisabled(Event& ev) { bool state = !m_disableButton.isSelected(); m_button.setEnabled(state); m_toggleButton.setEnabled(state); m_checkBox.setEnabled(state); m_radioButton1.setEnabled(state); m_radioButton2.setEnabled(state); m_radioButton3.setEnabled(state); m_radioButton4.setEnabled(state); }
ToggleButton* InfoWidget::createToggleButton(Widget* p_pMatrix, ElementType p_eType, QString p_rRefChannel) { ToggleButton *tb = new ToggleButton(NULL, "intro-open.svg", "intro-close.svg", "intro-close.svg", "intro-open.svg", QSize(INFO_WIDTH, SEPARATOR_HEIGHT), false); TbWrapp *wrapp = new TbWrapp(p_pMatrix, tb, p_eType, p_rRefChannel); if (!m_rToggleButtons.contains(p_eType)) { m_rToggleButtons.insert(p_eType, new QMap<QString, TbWrapp*>); } m_rToggleButtons[p_eType]->insert(p_rRefChannel, wrapp); tb->setToolTip(m_pMatrix->getDisplayFunction(IN, "", p_eType, p_rRefChannel, true)); tb->setValue(m_pMatrix->isVisible(p_eType, p_rRefChannel)); return tb; }
void ProgressManagerPrivate::init() { readSettings(); m_statusBarWidgetContainer = new StatusBarWidget; m_statusBarWidget = new QWidget; QHBoxLayout *layout = new QHBoxLayout(m_statusBarWidget); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); m_statusBarWidget->setLayout(layout); m_summaryProgressWidget = new QWidget(m_statusBarWidget); m_summaryProgressWidget->setVisible(!m_progressViewPinned); m_summaryProgressWidget->setGraphicsEffect(m_opacityEffect); m_summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget); m_summaryProgressLayout->setContentsMargins(0, 0, 0, 2); m_summaryProgressLayout->setSpacing(0); m_summaryProgressWidget->setLayout(m_summaryProgressLayout); m_summaryProgressBar = new ProgressBar(m_summaryProgressWidget); m_summaryProgressBar->setMinimumWidth(70); m_summaryProgressBar->setTitleVisible(false); m_summaryProgressBar->setSeparatorVisible(false); m_summaryProgressBar->setCancelEnabled(false); m_summaryProgressLayout->addWidget(m_summaryProgressBar); layout->addWidget(m_summaryProgressWidget); ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget); layout->addWidget(toggleButton); m_statusBarWidgetContainer->setWidget(m_statusBarWidget); m_statusBarWidgetContainer->setPosition(StatusBarWidget::RightCorner); ExtensionSystem::PluginManager::addObject(m_statusBarWidgetContainer); m_statusBarWidget->installEventFilter(this); QAction *toggleProgressView = new QAction(tr("Toggle Progress Details"), this); toggleProgressView->setCheckable(true); toggleProgressView->setChecked(m_progressViewPinned); // we have to set an transparent icon to prevent the tool button to show text QPixmap p(1, 1); p.fill(Qt::transparent); toggleProgressView->setIcon(QIcon(p)); Command *cmd = ActionManager::registerAction(toggleProgressView, "QtCreator.ToggleProgressDetails"); cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost() ? tr("Ctrl+Shift+0") : tr("Alt+Shift+0"))); connect(toggleProgressView, &QAction::toggled, this, &ProgressManagerPrivate::progressDetailsToggled); toggleButton->setDefaultAction(cmd->action()); m_progressView->setVisible(m_progressViewPinned); initInternal(); }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... void imaphone_component::color_radios_clear(ToggleButton* exclude=nullptr) { if (exclude != nullptr) { exclude->setToggleState(true, NotificationType::dontSendNotification); } for (std::vector<ToggleButton*>::iterator it = color_radios->begin(); it != color_radios->end(); ++it) { ToggleButton* current = (*it); if (current == exclude) { continue; } else { current->setToggleState(false, NotificationType::dontSendNotification); } } }
void ToggleButtonBase::execSyncV( FieldContainer &oFrom, ConstFieldMaskArg whichField, AspectOffsetStore &oOffsets, ConstFieldMaskArg syncMode, const UInt32 uiSyncInfo) { ToggleButton *pThis = static_cast<ToggleButton *>(this); pThis->execSync(static_cast<ToggleButton *>(&oFrom), whichField, oOffsets, syncMode, uiSyncInfo); }
void onStart() { if (m_start.isSelected()) { m_start.setText(L"Stop"); m_webcam.setDriver(m_driver.getSelectedItem()); m_webcam.startPreview(); m_webcam.setPreviewRate(m_rate.getValue()); } else { m_start.setText(L"Start"); m_webcam.stopPreview(); } }
void ToggleButton::RemoveFromToggleGroup() { if ( m_next ) { ToggleButton* other = m_next; // unlink m_prev->m_next = m_next; m_next->m_prev = m_prev; // clean up the group just left. if ( other != this ) { other->ProcessToggleGroup(); } m_next = m_prev = this; } }
Container *Intro::setUpExampleUI() { // A small example UI, illustrating some of the core controls. // The UI is arranged using a Container with a stack layout. Container *exampleUI = new Container(); StackLayout *exampleUILayout = new StackLayout(); exampleUI->setLayout(exampleUILayout); // A TextArea with text input functionality TextArea *exampleTextArea = new TextArea(); exampleTextArea->textStyle()->setBase(SystemDefaults::TextStyles::bodyText()); exampleTextArea->setHorizontalAlignment(HorizontalAlignment::Fill); // An example of a Slider Slider *exampleSlider = new Slider(); exampleSlider->setValue(0.5f); exampleSlider->setHorizontalAlignment(HorizontalAlignment::Left); exampleSlider->setVerticalAlignment(VerticalAlignment::Bottom); // A ToggleButton ToggleButton *exampleToggle = new ToggleButton(); exampleToggle->setHorizontalAlignment(HorizontalAlignment::Right); // A regular Button Button *exampleButton = new Button(); exampleButton->setText("Button"); // Container for the buttons Container *buttonContainer = new Container(); DockLayout *buttonContainerLayout = new DockLayout(); buttonContainer->setLayout(buttonContainerLayout); buttonContainer->setHorizontalAlignment(HorizontalAlignment::Fill); // Adding the buttons to the container. buttonContainer->add(exampleToggle); buttonContainer->add(exampleButton); // Add the Controls to the Container, the layouting is done using // layout properties and margins of each control (see code above). exampleUI->add(exampleTextArea); exampleUI->add(exampleSlider); exampleUI->add(buttonContainer); return exampleUI; }
void updatePreviewBoxText() { Font* f = fonts [listBox->getSelectedRow()]; if (f != 0) { Font font (*f); font.setHeight ((float) sizeSlider->getValue()); font.setBold (boldButton->getToggleState()); font.setItalic (italicButton->getToggleState()); font.setExtraKerningFactor ((float) kerningSlider->getValue()); font.setHorizontalScale ((float) horizontalScaleSlider->getValue()); textBox->applyFontToAllText (font); } }
void UILayer::initButtons( void ) { //정지 팝업띄우는 버튼 Button* stop = Button::buttonWithFrameImageFile("stop.png", "stop.png"); stop->setPosition(DTool::getCenter(this) + Vec2(264, 456)); stop->addAction([this]() { PopupStop* popupStop = PopupStop::create("", "popup_stop.png"); popupStop->showPopup(this); }, TOUCH_DOWN); addChild(stop); //하트버튼 ToggleButton* heart = ToggleButton::buttonWithFrameImageFile("btn_heart_on.png", "btn_heart_off.png"); heart->setPosition(DTool::getCenter(this) + Vec2(254, 180)); addChild(heart); }
void ProjucerLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) { ignoreUnused (isMouseOverButton, isButtonDown); if (! button.isEnabled()) g.setOpacity (0.5f); bool isTextEmpty = button.getButtonText().isEmpty(); bool isPropertyComponentChild = (dynamic_cast<BooleanPropertyComponent*> (button.getParentComponent()) != nullptr); auto bounds = button.getLocalBounds(); auto sideLength = isPropertyComponentChild ? 25 : bounds.getHeight(); auto rectBounds = isTextEmpty ? bounds : bounds.removeFromLeft (jmin (sideLength, bounds.getWidth() / 3)); rectBounds = rectBounds.withSizeKeepingCentre (sideLength, sideLength).reduced (4); g.setColour (button.findColour (ToggleButton::tickDisabledColourId)); g.drawRoundedRectangle (rectBounds.toFloat(), 2.0f, 1.0f); if (button.getToggleState()) { g.setColour (button.findColour (ToggleButton::tickColourId)); const auto tick = getTickShape (0.75f); g.fillPath (tick, tick.getTransformToScaleToFit (rectBounds.reduced (2).toFloat(), false)); } if (! isTextEmpty) { bounds.removeFromLeft (5); const auto fontSize = jmin (15.0f, button.getHeight() * 0.75f); g.setFont (fontSize); g.setColour (isPropertyComponentChild ? findColour (widgetTextColourId) : button.findColour (ToggleButton::textColourId)); g.drawFittedText (button.getButtonText(), bounds, Justification::centredLeft, 2); } }
void TextLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) { if (button.getToggleState()) g.setColour(Colour(0xffffc400)); else g.setColour(Colour(0xff313131)); g.fillRect(button.getLocalBounds()); g.setColour(Colour(0xff565656)); g.drawRect(button.getLocalBounds()); if (isButtonDown) { g.setColour(Colour(0x11000000)); g.fillRect(button.getLocalBounds()); } else if (isMouseOverButton) { g.setColour(Colour(0x11ffffff)); g.fillRect(button.getLocalBounds()); } }
void resized() { // lay out the list box and vertical divider.. Component* vcomps[] = { listBox, verticalDividerBar, 0 }; verticalLayout.layOutComponents (vcomps, 3, 4, 4, getWidth() - 8, getHeight() - 8, false, // lay out side-by-side true); // resize the components' heights as well as widths // now lay out the text box and the controls below it.. int x = verticalLayout.getItemCurrentPosition (2) + 4; textBox->setBounds (x, 0, getWidth() - x, getHeight() - 110); x += 70; sizeSlider->setBounds (x, getHeight() - 106, getWidth() - x, 22); kerningSlider->setBounds (x, getHeight() - 82, getWidth() - x, 22); horizontalScaleSlider->setBounds (x, getHeight() - 58, getWidth() - x, 22); boldButton->setBounds (x, getHeight() - 34, (getWidth() - x) / 2, 22); italicButton->setBounds (x + (getWidth() - x) / 2, getHeight() - 34, (getWidth() - x) / 2, 22); }
void TicTacToeLogic::CellChecked(BaseComponent* sender, const RoutedEventArgs& e) { ToggleButton* btn = NsStaticCast<ToggleButton*>(sender); Cell& cell = *Boxing::Unbox<Cell*>(NsStaticCast<Boxing::BoxedValue*>(btn->GetTag())); MarkCell(cell); NsString winPlay; if (HasWon(winPlay)) { WinGame(winPlay); } else if (HasTied()) { TieGame(); } else { SwitchPlayer(); } }
void ParticleScene::DoTick( U32 deltaTime ) { for( int i=0; i<buttonArr.Size(); ++i ) { ToggleButton* toggle = buttonArr[i]->ToToggleButton(); if ( toggle && toggle->Down() ) { Vector3F pos = { SIZE/2, 0.01f, SIZE/2 }; Vector3F normal = { 0, 1, 0 }; //Vector3F dir = { 1, 0, 0 }; ParticleDef* def = &particleDefArr[i]; if ( def->spread == ParticleDef::SPREAD_POINT ) { engine->particleSystem->EmitPD( *def, pos, normal, deltaTime ); } else { Rectangle3F r; r.Set( pos.x-0.5f, pos.y, pos.z-0.5f, pos.x+0.5f, pos.y, pos.z+0.5f ); engine->particleSystem->EmitPD( *def, r, normal, deltaTime ); } } } }
void buttonClicked (Button* button) override { if (button == &nativeButton) { getLookAndFeel().setUsingNativeAlertWindows (nativeButton.getToggleState()); return; } for (int i = windowButtons.size(); --i >= 0;) if (button == windowButtons.getUnchecked (i)) return showWindow (*button, static_cast<DialogType> (i)); }
EngineParameterComponent::EngineParameterComponent(EngineParameter ¶m) : Component(param.name), type(param.type), parameter(param) { if (param.type == EngineParameter::BOOL) { ToggleButton* but = new ToggleButton(); but->setToggleState(param.boolParam.value,dontSendNotification); but->setBounds(120,0,20,20); addAndMakeVisible(but); control = but; } else { Label* lab = new Label(); lab->setFont(Font("Small Text",10,Font::plain)); switch (param.type) { case EngineParameter::INT: lab->setText(String(param.intParam.value),dontSendNotification); lab->setBounds(120,0,50,20); break; case EngineParameter::FLOAT: lab->setText(String(param.floatParam.value),dontSendNotification); lab->setBounds(120,0,50,20); break; case EngineParameter::STR: lab->setText(String(param.strParam.value),dontSendNotification); lab->setBounds(120,0,150,20); } lab->setEditable(true); lab->setColour(Label::ColourIds::backgroundColourId,Colours::lightgrey); lab->setColour(Label::ColourIds::outlineColourId,Colours::black); lab->addListener(this); addAndMakeVisible(lab); control = lab; } }
void refreshPreviewBoxFont() { const bool bold = boldToggle.getToggleState(); const bool italic = italicToggle.getToggleState(); const bool useStyle = ! (bold || italic); Font font (fonts [listBox.getSelectedRow()]); font = font.withPointHeight ((float) heightSlider.getValue()) .withExtraKerningFactor ((float) kerningSlider.getValue()) .withHorizontalScale ((float) scaleSlider.getValue()); if (bold) font = font.boldened(); if (italic) font = font.italicised(); updateStylesList (font); styleBox.setEnabled (useStyle); if (useStyle) font = font.withTypefaceStyle (styleBox.getText()); demoTextBox.applyFontToAllText (font); }
/************************************************************************* Creates a checkbox to let the user choose to display randomised or real FPS value *************************************************************************/ void CustomShapesDrawingSample::createCheckboxShowRealFPS() { WindowManager& winMgr = WindowManager::getSingleton(); // We create a button and subscribe to its click events ToggleButton* checkboxShowRealFPS = static_cast<CEGUI::ToggleButton*>(winMgr.createWindow("WindowsLook/Checkbox")); checkboxShowRealFPS->setSize(CEGUI::USize(cegui_reldim(0.25f), cegui_reldim(0.035f))); checkboxShowRealFPS->setHorizontalAlignment(HA_CENTRE); checkboxShowRealFPS->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.13f))); checkboxShowRealFPS->setText("Show randomly generated FPS values"); checkboxShowRealFPS->subscribeEvent(ToggleButton::EventSelectStateChanged, Event::Subscriber(&CustomShapesDrawingSample::handleToggleButtonShowRandomisedFpsSelectionChanged, this)); checkboxShowRealFPS->setSelected(true); d_root->addChild(checkboxShowRealFPS); }
void ToggleButtonStyle::draw() { ToggleButton *w = static_cast<ToggleButton*>(getWidget()); Rect rect(Position(), w->getSize()); TextPosition tpos(rect, getTextHAlign(), getTextVAlign(), getTextHSpacing(), getTextVSpacing()); Color bg = getBGColor(); if(w->isPressing() || w->isPressed()) { bg += vec4(0.4f, 0.4f, 0.4f, 0.0f); } else if(w->isHovered()) { bg += vec4(0.2f, 0.2f, 0.2f, 0.0f); } iuiGetRenderer()->drawRect(rect, bg); iuiGetRenderer()->drawOutlineRect(rect, getBorderColor()); iuiGetRenderer()->drawFont(tpos, getFontColor(), w->getText().c_str(), w->getText().size()); }