コード例 #1
0
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;
}
コード例 #2
0
/*************************************************************************
    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);
}
コード例 #3
0
ファイル: intro.cpp プロジェクト: Angtrim/Cascades-Samples
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;
}
コード例 #4
0
CustomDialogAlarm::CustomDialogAlarm(QObject * parent) :
        QObject(parent), mVisible(false)
{
    bool connectResult;
    Q_UNUSED(connectResult);

    mCustomDialog = new Dialog();

    Container *contentContainer = new Container();
    contentContainer->setLayout(new DockLayout());

    // The dialog Container does not automatically fill the entire screen like a Page does, so in order
    // for it to be possible to center the dialog on screen, the width and height must be set.
    contentContainer->setPreferredSize(768, 1280);

    // The background is set to semi-transparent to indicate that it is not possible to interact
    // with the screen behind the dialog.
    contentContainer->setBackground(Color::fromARGB(0x88000000));

    // Dialog Container
    Container *dialogContainer = new Container();
    dialogContainer->setLayout(new DockLayout());
    dialogContainer->setHorizontalAlignment(HorizontalAlignment::Center);
    dialogContainer->setVerticalAlignment(VerticalAlignment::Center);
    dialogContainer->setMaxHeight(397);

    // Dialog background image
    ImageView *dialogBack = ImageView::create(
            "asset:///images/customdialog/customdialog_alarm.png");

    // Dialog content Container
    Container *dialogContent = Container::create().top(5).bottom(23).left(23);
    dialogContent->setHorizontalAlignment(HorizontalAlignment::Fill);
    dialogContent->setVerticalAlignment(VerticalAlignment::Fill);

    // Title label for dialog
    Label *dialogTitle = new Label();
    dialogTitle->setText("FIRE ALARM!");
    dialogTitle->textStyle()->setBase(SystemDefaults::TextStyles::titleText());
    dialogTitle->textStyle()->setColor(Color::fromARGB(0xfffafafa));
    dialogTitle->setLayoutProperties(StackLayoutProperties::create().spaceQuota(1));
    dialogTitle->setHorizontalAlignment(HorizontalAlignment::Center);

    // Text label for dialog
    Label *dialogText = new Label();
    dialogText->setText("BEEP! BEEP! BEEP!");
    dialogText->textStyle()->setBase(SystemDefaults::TextStyles::titleText());
    dialogText->setLayoutProperties(StackLayoutProperties::create().spaceQuota(2.5));

    // Toggle button for alarm
    ToggleButton *toggleAlarm = new ToggleButton();
    toggleAlarm->setLayoutProperties(StackLayoutProperties::create().spaceQuota(1));
    toggleAlarm->setHorizontalAlignment(HorizontalAlignment::Center);

    // Connect to signals
    connectResult = connect(toggleAlarm, SIGNAL(checkedChanged(bool)), this, SLOT(onAlarmSwitch(bool)));
    Q_ASSERT(connectResult);

    connectResult = connect(this, SIGNAL(visibleChanged(bool)), toggleAlarm, SLOT(setChecked(bool)));
    Q_ASSERT(connectResult);

    // Add components to the appropriate Containers
    dialogContent->add(dialogTitle);
    dialogContent->add(dialogText);
    dialogContent->add(toggleAlarm);

    dialogContainer->add(dialogBack);
    dialogContainer->add(dialogContent);
    contentContainer->add(dialogContainer);

    mCustomDialog->setContent(contentContainer);
}