コード例 #1
0
ファイル: Chatbox.cpp プロジェクト: Sypanite/GUI-Framework
Chatbox::Chatbox(const std::string& id, Vector2& position, float width) : GUIImage(id, "demo/images/chatbox/CHAT_BACK.tga") {
	setLocalTranslation(position);
	resize(width, 200);
	setDraggable(true);

	p_messageArea = new ScrollPane(id + "_scroll", Vector2(10, 38), Vector2(width - 20, 190));
	p_messageArea->setBackground("demo/images/chatbox/CHAT_FORE.tga");

	p_inputField = new TextField(id + "_input", Vector2(10, 10), width - 20);
	p_inputField->setCharacterLimit(32);
	p_inputField->setBackground("demo/images/chatbox/CHAT_FIELD.tga");
	p_inputField->setForegroundColour(ColourRGBA(ColourRGBA::WHITE));

	setPassFocusElement(p_messageArea);

	for (int i = 0; i != bufferSize; i++) {
		entryLabels.push_back(new Label("", "", 9, Vector2(4, (i + 1) * 10))); // We don't care about their IDs
		p_messageArea->attachChild(entryLabels[i]);
	}

	p_messageArea->floor();

	attachChild(p_messageArea);
	attachChild(p_inputField);
}
コード例 #2
0
ファイル: Spaceship.cpp プロジェクト: MaximilianAlgehed/Game
//Initializ the spaceship
Spaceship::Spaceship(Type type, ResourceHolder<sf::Texture, Textures::ID>& textureHolder, SceneNode * foreground, unsigned int team) :
    type(type), //The type, to define the behavior
    sprite(textureHolder.get(spaceshipData[type].textureID)), //Initilize the sprite
    deltaV(spaceshipData[type].deltaV), //Initialize the deltaV
    maxV(spaceshipData[type].maxV), //Initialize the maxV
    foregroundLayer(foreground), //Initialize the foregorund pointer
    hp(spaceshipData[type].hp), //Initialize the hitpoints
    trajectory(new Trajectory()),
    id(maxId++)
{
    //attach the trajectory in the scene graph
    attachChild(trajectory);

    //Set the category
    category = Command::Spaceship;

    //Center the origin
    sf::FloatRect bounds = sprite.getLocalBounds();
    sprite.setOrigin(bounds.width/2.f, bounds.height/2.f);

    //Get the ID
    setTeam(team);

    //Add the weapons
    for(Weapon::WeaponPrototype prototype : spaceshipData[type].weapons)
    {
        Weapon * weapon = new Weapon(prototype.type, foreground, textureHolder);
        weapon->setRotation(prototype.rotation);
        weapon->setPosition(prototype.position);
        weapon->setTeam(team);
        attachChild(weapon);
    }
}
コード例 #3
0
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type)
, mFireCommand()
, mMissileCommand()
, mFireCountdown(sf::Time::Zero)
, mIsFiring(false)
, mIsLaunchingMissile(false)
, mShowExplosion(true)
, mSpawnedPickup(false)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.get(Textures::Explosion))
, mFireRateLevel(1)
, mSpreadLevel(1)
, mMissileAmmo(2)
, mDropPickupCommand()
, mTravelledDistance(0.f)
, mDirectionIndex(0)
, mMissileDisplay(nullptr)
{
	mExplosion.setFrameSize(sf::Vector2i(256, 256));
	mExplosion.setNumFrames(16);
	mExplosion.setDuration(sf::seconds(1));

	centerOrigin(mSprite);
	centerOrigin(mExplosion);

	mFireCommand.category = Category::SceneAirLayer;
	mFireCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createBullets(node, textures);
	};

	mMissileCommand.category = Category::SceneAirLayer;
	mMissileCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
	};

	mDropPickupCommand.category = Category::SceneAirLayer;
	mDropPickupCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
	{
		createPickup(node, textures);
	};

	std::unique_ptr<TextNode> healthDisplay(new TextNode(fonts, ""));
	mHealthDisplay = healthDisplay.get();
	attachChild(std::move(healthDisplay));

	if (getCategory() == Category::PlayerAircraft)
	{
		std::unique_ptr<TextNode> missileDisplay(new TextNode(fonts, ""));
		missileDisplay->setPosition(0, 70);
		mMissileDisplay = missileDisplay.get();
		attachChild(std::move(missileDisplay));
	}

	updateTexts();
}
コード例 #4
0
ScenarioLoiteringTrajectory::ScenarioLoiteringTrajectory() :
    m_environment(NULL),
    m_simulationParameters(NULL),
    m_optimizationParameters(NULL),
    m_trajectoryPropagation(NULL)
{
    m_environment = new ScenarioEnvironment();
    attachChild(m_environment);
    m_simulationParameters = new ScenarioSimulationParameters(0);
    attachChild(m_simulationParameters);
    m_trajectoryPropagation = new ScenarioTrajectoryPropagation();
    attachChild(m_trajectoryPropagation);
}
コード例 #5
0
ファイル: HistoryDialog.cpp プロジェクト: eggtart93/LuckyDraw
HistoryDialog::HistoryDialog(const std::string& info,
                             const fw::State::Context& context)
: mWin(*(context.window)),
  mFrame(sf::Vector2f(DIALOG_WIDTH, DIALOG_HEIGHT)),
  mTitle(L"选中名单", context.fonts->get(Fonts::Chinese), DIALOG_TITLE_SIZE),
  mContent(info, context.fonts->get(Fonts::Chinese), DIALOG_TEXT_SIZE),
  mTopIndex(0),
  mBotIndex(0),
  p_mArrowUp(nullptr),
  p_mArrowDown(nullptr),
  mIsDisplay(false)
{
    mDisplayPos.x = .5f * context.window->getView().getSize().x;
    mDisplayPos.y = mFrame.getGlobalBounds().height * .5f + 20.f;
    mBeginPos.x = mDisplayPos.x;
    mBeginPos.y = -.5f * mFrame.getGlobalBounds().height;

    setPosition(mBeginPos);

    SimpleButton::Ptr arrow_up(new SimpleButton(14));
    SimpleButton::Ptr arrow_down(new SimpleButton(14));
    p_mArrowUp = arrow_up.get();
    p_mArrowDown = arrow_down.get();
    attachChild(std::move(arrow_up));
    attachChild(std::move(arrow_down));

    p_mArrowDown->setCallback([this]()
    {
        strScrollDown();
    });

    p_mArrowUp->setCallback([this]()
    {
        strScrollUp();
    });

    mFrame.setFillColor(DIALOG_BG_COLOR);
    mTitle.setColor(DIALOG_TITLE_COLOR);
    mContent.setColor(DIALOG_TEXT_COLOR);
    p_mArrowUp->setButtonColor(DIALOG_TITLE_COLOR);
    p_mArrowDown->setButtonColor(DIALOG_TITLE_COLOR);

    p_mArrowDown->setRotation(180.f);
    p_mArrowDown->setButtonSize(16.f, 26.f);
    p_mArrowUp->setButtonSize(16.f, 26.f);

    maxNoLines = getMaxNoLineToShow();
    pack();
}
コード例 #6
0
ファイル: Aircraft.cpp プロジェクト: kevin5396/Hellfire
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type), mSprite(textures.get(Table[mType].texture), Table[mType].textRect),mHealthDisplay(nullptr)
, mTravelledDistance(0.f), mDirectionIndex(0), mIsFiring(false), mFireCountdown(sf::Time::Zero)
, mFireRateLevel(1), mFireCommand(), mSpreadLevel(1), mIsMarkedForRemoval(false)
, mMissileCommand(), mIsLaunchMissile(false), mMissileAmmo(2), mDropPickupCommand()
{
    if (!isAllied())
        mFireRateLevel = 0;
    centerOrigin(mSprite);
    
    std::unique_ptr<TextNode>   healthDisplay(new TextNode(fonts, ""));
    mHealthDisplay = healthDisplay.get();
    
    attachChild(std::move(healthDisplay));
    
    mFireCommand.category = Category::Scene;
    mFireCommand.action = [this, &textures](SceneNode& node, sf::Time)
    {
        createBullet(node, textures);
    };
    mMissileCommand.category = Category::Scene;
    mMissileCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
    {
        createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
    };
    
    mDropPickupCommand.category = Category::Scene;
    mDropPickupCommand.action   = [this, &textures] (SceneNode& node, sf::Time)
    {
        createPickup(node, textures);
    };
}
コード例 #7
0
bool SettingsDialog::initDialog() {
	// set this to IDH_STARTPAGE so that clicking in an empty space of the dialog generates a WM_HELP message with no error; then SettingsDialog::handleHelp will convert IDH_STARTPAGE to the current page's help id
	setHelpId(IDH_STARTPAGE);

	WinUtil::setHelpIds(this, helpItems);

	setText(T_("Settings"));

	attachChild(pageTree, IDC_SETTINGS_PAGES);
	pageTree->onSelectionChanged(std::tr1::bind(&SettingsDialog::handleSelectionChanged, this));

	{
		ButtonPtr button = attachChild<Button>(IDOK);
		button->setText(T_("OK"));
		button->onClicked(std::tr1::bind(&SettingsDialog::handleOKClicked, this));

		button = attachChild<Button>(IDCANCEL);
		button->setText(T_("Cancel"));
		button->onClicked(std::tr1::bind(&SettingsDialog::endDialog, this, IDCANCEL));

		button = attachChild<Button>(IDHELP);
		button->setText(T_("Help"));
		button->onClicked(std::tr1::bind(&SettingsDialog::handleHelp, this, handle(), IDH_STARTPAGE));
	}

	addPage(T_("Personal information"), new GeneralPage(this));

	addPage(T_("Connection settings"), new NetworkPage(this));

	{
		HTREEITEM item = addPage(T_("Downloads"), new DownloadPage(this));
		addPage(T_("Favorites"), new FavoriteDirsPage(this), item);
		addPage(T_("Queue"), new QueuePage(this), item);
	}

	addPage(T_("Sharing"), new UploadPage(this));

	{
		HTREEITEM item = addPage(T_("Appearance"), new AppearancePage(this));
		addPage(T_("Colors and sounds"), new Appearance2Page(this), item);
		addPage(T_("Tabs"), new TabsPage(this), item);
		addPage(T_("Windows"), new WindowsPage(this), item);
	}

	{
		HTREEITEM item = addPage(T_("Advanced"), new AdvancedPage(this));
		addPage(T_("Logs"), new LogPage(this), item);
		addPage(T_("Experts only"), new Advanced3Page(this), item);
		addPage(T_("User Commands"), new UCPage(this), item);
		addPage(T_("Security Certificates"), new CertificatesPage(this), item);
	}

	addPage(TSTRING(SETTINGS_APPEARANCE_PAGE), new FdmAppearancePage(this));
	addPage(TSTRING(SETTINGS_BANDWIDTH), new BandwidthLimitPage(this));
	addPage(TSTRING(SETTINGS_SPAM), new FdmSpamPage(this));

	updateTitle();

	return false;
}
コード例 #8
0
ファイル: DemoState.cpp プロジェクト: Sypanite/GUI-Framework
void DemoState::createRGBAWindow() {
	detachChild("rgbaWindow");

	windowRGBA = new Window("rgbaWindow", Vector2(), Vector2(270, 200), "images/WINDOW.tga");
	windowRGBA->attachChild(new Label("RGBALabel", "RGBA Colour", 10, ColourRGBA(ColourRGBA::WHITE), Vector2(10, 90)));

	rSlider = new Slider("rSlider", Vector2(20, 125), 230, HORIZONTAL);
	rSlider->setColour(ColourRGBA::RED);

	gSlider = new Slider("gSlider", Vector2(20, 90), 230, HORIZONTAL);
	gSlider->setColour(ColourRGBA::GREEN);

	bSlider = new Slider("bSlider", Vector2(20, 55), 230, HORIZONTAL);
	bSlider->setColour(ColourRGBA::BLUE);

	aSlider = new Slider("aSlider", Vector2(20, 20), 230, HORIZONTAL);
	aSlider->setColour(ColourRGBA(1, 1, 1, 0.5f));

	windowRGBA->attachChild(rSlider);
	windowRGBA->attachChild(gSlider);
	windowRGBA->attachChild(bSlider);
	windowRGBA->attachChild(aSlider);

	attachChild(windowRGBA);
}
コード例 #9
0
ファイル: DemoState.cpp プロジェクト: Sypanite/GUI-Framework
void DemoState::buttonPressed(Button& button) {
	if (button == "resetEffects") {
		generalEffect->setSelected("None");
		onHoverEffect->setSelected("None");
		onHoverOffEffect->setSelected("None");
		image->setVisible(true);
	}
	if (button == "demoAnim") {
		createAnimationWindow();
	}
	if (button == "demoEffects") {
		createEffectsWindow();
	}
	if (button == "demoRGBA") {
		createRGBAWindow();
	}
	if (button == "demoChatbox") {
		detachChild("chatbox");
		demoChatbox = new Chatbox("chatbox", Vector2(-17, -363), 520);
		attachChild(demoChatbox);

		demoChatbox->pushMessage("HAL-9000", "Hello.");
	}
	if (button == "demoPlain") {
		createPlainWindow();
	}
}
コード例 #10
0
static void updateTreeAfterInsertion(ContainerNode* parent, Node* child, AttachBehavior attachBehavior)
{
    ASSERT(parent->refCount());
    ASSERT(child->refCount());

    ChildListMutationScope(parent).childAdded(child);

    parent->childrenChanged(false, child->previousSibling(), child->nextSibling(), 1);

    ChildNodeInsertionNotifier(parent).notify(child);

    // FIXME: Attachment should be the first operation in this function, but some code
    // (for example, HTMLFormControlElement's autofocus support) requires this ordering.
    if (parent->attached() && !child->attached() && child->parentNode() == parent) {
        if (attachBehavior == AttachLazily) {
            if (child->isElementNode())
                toElement(child)->lazyAttach();
            else if (child->isTextNode()) {
                child->setAttached(true);
                child->setNeedsStyleRecalc();
            }
        } else
            attachChild(child);
    }

    dispatchChildInsertionEvents(child);
}
コード例 #11
0
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
    NodeVector children;
    getChildNodes(oldParent, children);

    if (oldParent->document().hasMutationObserversOfType(MutationObserver::ChildList)) {
        ChildListMutationScope mutation(oldParent);
        for (unsigned i = 0; i < children.size(); ++i)
            mutation.willRemoveChild(children[i].get());
    }

    // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child,
    // probably inside removeDetachedChildrenInContainer.

    oldParent->removeDetachedChildren();

    for (unsigned i = 0; i < children.size(); ++i) {
        Node* child = children[i].get();
        if (child->attached())
            detachChild(child);
        // FIXME: We need a no mutation event version of adoptNode.
        RefPtr<Node> adoptedChild = document().adoptNode(children[i].release(), ASSERT_NO_EXCEPTION);
        parserAppendChild(adoptedChild.get());
        // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
        // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
        // Can we do better?
        treeScope()->adoptIfNeeded(adoptedChild.get());
        if (attached() && !adoptedChild->attached())
            attachChild(adoptedChild.get());
    }
}
コード例 #12
0
/*** ScenarioPhysicalProperties ***/
ScenarioPhysicalProperties::ScenarioPhysicalProperties() :
    m_physicalcharacteristics(NULL),
    m_geometricalcharacteristics(NULL)
{
    m_physicalcharacteristics = new ScenarioPhysicalCharacteristics();
    attachChild(m_physicalcharacteristics);
}
コード例 #13
0
// Set Text Properties
void ButtonNode::setTextProperties(const std::string& str, const sf::Font& font,
                                   unsigned charSize)
{
    std::unique_ptr<TextNode> text(new TextNode(str, font, charSize));
    mText = text.get();
    attachChild(std::move(text));

    centerOrigin();
}
コード例 #14
0
ファイル: ocranges.cpp プロジェクト: ivandeex/optikus
void
OCRuler::move(double x, double y)
{
	// Temporarily detach the slider and move it appropriately.
	QWidget *child = detachChild();
	OCDataWidget::move(x, y);
	child->move(int(x) + off_x, int(y) + off_y);
	attachChild(child);
}
コード例 #15
0
void ScenarioAerodynamicProperties::setParachuteProperties(ScenarioParachuteProperties* parachuteproperties)
{
    if (parachuteproperties != m_parachuteproperties)
    {
        detachChild(m_parachuteproperties);
        m_parachuteproperties = parachuteproperties;
        attachChild(m_parachuteproperties);
    }
}
コード例 #16
0
void ScenarioPhysicalProperties::setGeometricalCharacteristics(ScenarioGeometricalCharacteristics* geometricalcharacteristics)
{
    if (geometricalcharacteristics != m_geometricalcharacteristics)
    {
        detachChild(m_geometricalcharacteristics);
        m_geometricalcharacteristics = geometricalcharacteristics;
        attachChild(m_geometricalcharacteristics);
    }
}
コード例 #17
0
void
ScenarioLoiteringTrajectory::setTrajectoryPropagation(ScenarioTrajectoryPropagation* trajectoryPropagation)
{
    if (trajectoryPropagation != m_trajectoryPropagation)
    {
        detachChild(m_trajectoryPropagation);
        m_trajectoryPropagation = trajectoryPropagation;
        attachChild(m_trajectoryPropagation);
    }
}
コード例 #18
0
void
ScenarioLoiteringTrajectory::setEnvironment(ScenarioEnvironment* environment)
{
    if (environment != m_environment)
    {
        detachChild(m_environment);
        m_environment = environment;
        attachChild(m_environment);
    }
}
コード例 #19
0
void ScenarioPhysicalProperties::setPhysicalCharacteristics(ScenarioPhysicalCharacteristics* physicalcharacteristics)
{
    Q_ASSERT(physicalcharacteristics != NULL);
    if (physicalcharacteristics != m_physicalcharacteristics)
    {
        detachChild(m_physicalcharacteristics);
        m_physicalcharacteristics = physicalcharacteristics;
        attachChild(m_physicalcharacteristics);
    }
}
コード例 #20
0
void
ScenarioLoiteringTrajectory::setSimulationParameters(ScenarioSimulationParameters* simulationParameters)
{
    if (simulationParameters != m_simulationParameters)
    {
        detachChild(m_simulationParameters);
        m_simulationParameters = simulationParameters;
        attachChild(m_simulationParameters);
    }
}
コード例 #21
0
ファイル: ocranges.cpp プロジェクト: ivandeex/optikus
bool
OCRuler::resize(double w, double h)
{
	// Temporarily detach the slider and resize it appropriately.
	QWidget *child = detachChild();
	OCWidget::resize(w, h);
	updateSize(int(w), int(h));
	attachChild(child);
	updateGeometry();
	return true;
}
コード例 #22
0
ファイル: ComboBox.cpp プロジェクト: Sypanite/GUI-Framework
ComboBox::ComboBox(const std::string& id, Vector2& localTranslation, float width) : GUIElement(id, localTranslation) {
	this->width = width;

	p_buttonContainer = new GUIElement(id + "_container", Vector2(), Vector2(width, 0)); // An empty element to store the buttons
	p_buttonContainer->setVisible(false);

	GUIImage* downIcon = new GUIImage(id + "_down_arrow", "images/scroll/DOWN.tga");
	downIcon->setResponsive(false);

	dropButton = new Button(id + "_drop", Vector2(width, -1), "images/scroll/SCROLL.tga");
	dropButton->assignImages("images/scroll/SCROLL.tga", "images/scroll/SCROLL_HOVER.tga", "images/scroll/SCROLL_PRESSED.tga");
	dropButton->attachChild(downIcon);
	dropButton->setOnPress(press);

	fieldButton = createButton("", 0);
	attachChild(fieldButton);

	attachChild(p_buttonContainer);
	attachChild(dropButton);
}
コード例 #23
0
void ScenarioProperties::setPayloadProperties(ScenarioPayloadProperties* payloadproperties)
{
    Q_ASSERT(payloadproperties != NULL);
    if (payloadproperties != m_payloadproperties)
    {
        detachChild(m_payloadproperties);
        m_payloadproperties = payloadproperties;

        attachChild(m_payloadproperties);
    }
}
コード例 #24
0
void ScenarioProperties::setPropulsionProperties(ScenarioPropulsionProperties* propulsionproperties)
{
    Q_ASSERT(propulsionproperties != NULL);
    if (propulsionproperties != m_propulsionproperties)
    {
        detachChild(m_propulsionproperties);
        m_propulsionproperties = propulsionproperties;

        attachChild(m_propulsionproperties);
    }
}
コード例 #25
0
void ScenarioProperties::setAerodynamicProperties(ScenarioAerodynamicProperties* aerodynamicproperties)
{
    Q_ASSERT(aerodynamicproperties != NULL);
    if (aerodynamicproperties != m_aerodynamicproperties)
    {
        detachChild(m_aerodynamicproperties);
        m_aerodynamicproperties = aerodynamicproperties;

        attachChild(m_aerodynamicproperties);
    }
}
コード例 #26
0
void
ScenarioDesignOverview::setSubsystem(const QString& name,
                                     ScenarioSubsystem* subsystem)
{
    attachChild(subsystem);
    if (m_subsystems.contains(name))
    {
        detachChild(m_subsystems.value(name));
    }
    m_subsystems[name] = subsystem;
}
コード例 #27
0
ファイル: ocranges.cpp プロジェクト: ivandeex/optikus
OCRuler::OCRuler(OQCanvas *c)
	:	OCDataWidget(c),
		vmin(0), vmax(0), vcur(0), vslide(0),
		off_x(0), off_y(0)
{
	setBindLimit(1);
	attachChild(new QSlider(Horizontal, getParent()));
	slider()->setTracking(false);
	connect(slider(), SIGNAL(valueChanged(int)), SLOT(valueChanged(int)));
	connect(slider(), SIGNAL(sliderMoved(int)), SLOT(sliderMoved(int)));
}
コード例 #28
0
void ScenarioProperties::setPhysicalProperties(ScenarioPhysicalProperties* physicalproperties)
{
    Q_ASSERT(physicalproperties != NULL);
    if (physicalproperties != m_physicalproperties)
    {
        detachChild(m_physicalproperties);
        m_physicalproperties = physicalproperties;

        attachChild(m_physicalproperties);
    }    
}
コード例 #29
0
// Set Container Properties
void ButtonNode::setContainerProperties(const sf::Texture& texture,
                                        const sf::IntRect& rect)
{
    std::unique_ptr<SpriteNode> container(rect == sf::IntRect(0, 0, 0, 0)
                                          ? new SpriteNode(texture)
                                          : new SpriteNode(texture, rect));
    mContainer = container.get();
    attachChild(std::move(container));

    centerOrigin();
}
コード例 #30
0
ScenarioProperties::ScenarioProperties() :
    m_physicalproperties(NULL),
    m_aerodynamicproperties(NULL),
    m_propulsionproperties(NULL),
    m_payloadproperties(NULL)
    //m_mainBody(NULL),
    //m_parachute(NULL),
    //m_designOverview(NULL)
{
    m_physicalproperties = new ScenarioPhysicalProperties();
    attachChild(m_physicalproperties);

    m_aerodynamicproperties = new ScenarioAerodynamicProperties();
    attachChild(m_aerodynamicproperties);

    m_propulsionproperties = new ScenarioPropulsionProperties();
    attachChild(m_propulsionproperties);

    m_payloadproperties = new ScenarioPayloadProperties();
    attachChild(m_payloadproperties);
}