From 8963ef3e6d0ede6a3e22687642bbc39c24f21dad Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 8 Jul 2009 10:41:59 -0600 Subject: Make SkillEntries update their width --- src/gui/skilldialog.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/gui/skilldialog.cpp') diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index a0b8f569..d9e2c5bb 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -56,11 +56,13 @@ struct SkillInfo SkillEntry *display; }; -class SkillEntry : public Container +class SkillEntry : public Container, gcn::WidgetListener { public: SkillEntry(struct SkillInfo *info); + void widgetResized(const gcn::Event &event); + void update(); private: @@ -110,7 +112,7 @@ void SkillDialog::adjustTabSize() { gcn::Widget *content = mTabs->getCurrentWidget(); if (content) { - int width = mTabs->getWidth() - 2 * content->getFrameSize(); + int width = mTabs->getWidth() - 2 * content->getFrameSize() - 2 * mTabs->getFrameSize(); int height = mTabs->getContainerHeight() - 2 * content->getFrameSize(); content->setSize(width, height); content->setVisible(true); @@ -217,20 +219,14 @@ SkillEntry::SkillEntry(struct SkillInfo *info) : mInfo(info), mProgress(new ProgressBar(0.0f, 200, 20, gcn::Color(150, 150, 150))), mLevelLabel(new Label("999")) { + setFrameSize(1); setOpaque(false); + addWidgetListener(this); + if (!info->icon.empty()) mIcon = new Icon(info->icon); - /*LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - if (mIcon) - place(0, 0, mIcon, 1, 2); - place(1, 0, mNameLabel, 3); - place(4, 0, mLevelLabel); - place(1, 1, mProgress, 4);*/ - if (mIcon) { mIcon->setPosition(1, 0); @@ -249,6 +245,14 @@ SkillEntry::SkillEntry(struct SkillInfo *info) : mInfo(info), update(); } +void SkillEntry::widgetResized(const gcn::Event &event) +{ + gcn::Rectangle size = getChildrenArea(); + + mLevelLabel->setPosition(size.width - mLevelLabel->getWidth(), 0); + mProgress->setWidth(size.width - 35); +} + void SkillEntry::update() { int baseLevel = player_node->getAttributeBase(mInfo->id); -- cgit v1.2.3-60-g2f50