~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to Tools/SkinEditor/SeparatorListControl.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Albert Semenov
4
 
        @date           08/2010
5
 
*/
6
 
#include "Precompiled.h"
7
 
#include "SeparatorListControl.h"
8
 
#include "SkinManager.h"
9
 
#include "Binary.h"
10
 
#include "Localise.h"
11
 
 
12
 
namespace tools
13
 
{
14
 
 
15
 
        enum SeparatorPreset
16
 
        {
17
 
                SeparatorPresetScale = Binary<0>::value,
18
 
                SeparatorPreset9Slice = Binary<1111>::value,
19
 
                SeparatorPreset3SliceHorScale = Binary<1100>::value,
20
 
                SeparatorPreset3SliceVertScale = Binary<11>::value
21
 
        };
22
 
 
23
 
        SeparatorListControl::SeparatorListControl(MyGUI::Widget* _parent) :
24
 
                wraps::BaseLayout("SeparatorListControl.layout", _parent),
25
 
                mList(nullptr),
26
 
                mPresets(nullptr)
27
 
        {
28
 
                mTypeName = MyGUI::utility::toString((size_t)this);
29
 
 
30
 
                assignWidget(mList, "List");
31
 
                assignWidget(mPresets, "Presets");
32
 
 
33
 
                fillPresets();
34
 
 
35
 
                mList->eventListChangePosition += MyGUI::newDelegate(this, &SeparatorListControl::notifyChangePosition);
36
 
                mPresets->eventComboChangePosition += MyGUI::newDelegate(this, &SeparatorListControl::notifyComboChangePosition);
37
 
 
38
 
                initialiseAdvisor();
39
 
        }
40
 
 
41
 
        SeparatorListControl::~SeparatorListControl()
42
 
        {
43
 
                shutdownAdvisor();
44
 
 
45
 
                mPresets->eventComboChangePosition -= MyGUI::newDelegate(this, &SeparatorListControl::notifyComboChangePosition);
46
 
                mList->eventListChangePosition -= MyGUI::newDelegate(this, &SeparatorListControl::notifyChangePosition);
47
 
        }
48
 
 
49
 
        void SeparatorListControl::notifyChangePosition(MyGUI::ListBox* _sender, size_t _index)
50
 
        {
51
 
                if (getCurrentSkin() != nullptr)
52
 
                {
53
 
                        SeparatorItem* item = nullptr;
54
 
 
55
 
                        if (_index != MyGUI::ITEM_NONE)
56
 
                                item = *mList->getItemDataAt<SeparatorItem*>(_index);
57
 
 
58
 
                        getCurrentSkin()->getSeparators().setItemSelected(item);
59
 
                }
60
 
        }
61
 
 
62
 
        void SeparatorListControl::updateSeparatorProperty(Property* _sender, const MyGUI::UString& _owner)
63
 
        {
64
 
                if (_sender->getName() == "Visible")
65
 
                        updateList();
66
 
 
67
 
                if (_owner != mTypeName)
68
 
                        updatePreset();
69
 
        }
70
 
 
71
 
        void SeparatorListControl::updateSeparatorProperties()
72
 
        {
73
 
                updateList();
74
 
        }
75
 
 
76
 
        void SeparatorListControl::updateSkinProperties()
77
 
        {
78
 
                updatePreset();
79
 
        }
80
 
 
81
 
        void SeparatorListControl::updateList()
82
 
        {
83
 
                if (getCurrentSkin() != nullptr)
84
 
                {
85
 
                        SeparatorItem* selectedItem = getCurrentSkin()->getSeparators().getItemSelected();
86
 
                        size_t selectedIndex = MyGUI::ITEM_NONE;
87
 
 
88
 
                        size_t index = 0;
89
 
                        ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
90
 
                        while (separators.next())
91
 
                        {
92
 
                                SeparatorItem* item = separators.current();
93
 
 
94
 
                                MyGUI::UString name;
95
 
                                if (item->getPropertySet()->getPropertyValue("Visible") != "True")
96
 
                                        name = replaceTags("ColourDisabled") + item->getName();
97
 
                                else
98
 
                                        name = item->getName();
99
 
 
100
 
                                if (index < mList->getItemCount())
101
 
                                {
102
 
                                        mList->setItemNameAt(index, name);
103
 
                                        mList->setItemDataAt(index, item);
104
 
                                }
105
 
                                else
106
 
                                {
107
 
                                        mList->addItem(name, item);
108
 
                                }
109
 
 
110
 
                                if (item == selectedItem)
111
 
                                        selectedIndex = index;
112
 
 
113
 
                                index ++;
114
 
                        }
115
 
 
116
 
                        while (index < mList->getItemCount())
117
 
                                mList->removeItemAt(mList->getItemCount() - 1);
118
 
 
119
 
                        mList->setIndexSelected(selectedIndex);
120
 
                }
121
 
        }
122
 
 
123
 
        void SeparatorListControl::fillPresets()
124
 
        {
125
 
                mPresets->removeAllItems();
126
 
                mPresets->addItem(replaceTags("PresetRegionOneScale"), SeparatorPresetScale);
127
 
                mPresets->addItem(replaceTags("PresetRegion9Grid"), SeparatorPreset9Slice);
128
 
                mPresets->addItem(replaceTags("PresetRegion3Hor"), SeparatorPreset3SliceHorScale);
129
 
                mPresets->addItem(replaceTags("PresetRegion3Vert"), SeparatorPreset3SliceVertScale);
130
 
 
131
 
                mPresets->beginToItemFirst();
132
 
        }
133
 
 
134
 
        void SeparatorListControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
135
 
        {
136
 
                if (getCurrentSkin() == nullptr)
137
 
                        return;
138
 
 
139
 
                if (_index == MyGUI::ITEM_NONE)
140
 
                        return;
141
 
 
142
 
                SeparatorPreset preset = *_sender->getItemDataAt<SeparatorPreset>(_index);
143
 
 
144
 
                size_t index = 0;
145
 
                ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
146
 
                while (separators.next())
147
 
                {
148
 
                        SeparatorItem* item = separators.current();
149
 
                        MyGUI::UString value = ((preset & (1 << index)) != 0) ? "True" : "False";
150
 
                        item->getPropertySet()->setPropertyValue("Visible", value, mTypeName);
151
 
 
152
 
                        ++index;
153
 
                }
154
 
 
155
 
                // для обновления пропертей
156
 
                getCurrentSkin()->getSeparators().setItemSelected(nullptr);
157
 
 
158
 
                updateList();
159
 
        }
160
 
 
161
 
        void SeparatorListControl::updatePreset()
162
 
        {
163
 
                mPresets->setEnabled(getCurrentSkin() != nullptr);
164
 
 
165
 
                if (getCurrentSkin() != nullptr)
166
 
                {
167
 
                        int currentPreset = 0;
168
 
                        int bitIndex = 0;
169
 
 
170
 
                        ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
171
 
                        while (separators.next())
172
 
                        {
173
 
                                SeparatorItem* item = separators.current();
174
 
                                bool visible = item->getPropertySet()->getPropertyValue("Visible") == "True";
175
 
                                if (visible)
176
 
                                        currentPreset |= (1 << bitIndex);
177
 
 
178
 
                                ++ bitIndex;
179
 
                        }
180
 
 
181
 
                        size_t indexSelected = MyGUI::ITEM_NONE;
182
 
 
183
 
                        size_t count = mPresets->getItemCount();
184
 
                        for (size_t index = 0; index < count; ++index)
185
 
                        {
186
 
                                SeparatorPreset preset = *mPresets->getItemDataAt<SeparatorPreset>(index);
187
 
                                if (preset == currentPreset)
188
 
                                {
189
 
                                        indexSelected = index;
190
 
                                        break;
191
 
                                }
192
 
                        }
193
 
 
194
 
                        mPresets->setIndexSelected(indexSelected);
195
 
 
196
 
                        mPresets->setEnabled(true);
197
 
                }
198
 
                else
199
 
                {
200
 
                        mPresets->setEnabled(false);
201
 
                }
202
 
        }
203
 
 
204
 
} // namespace tools
 
1
/*!
 
2
        @file
 
3
        @author         Albert Semenov
 
4
        @date           07/2012
 
5
*/
 
6
 
 
7
#include "Precompiled.h"
 
8
#include "SeparatorListControl.h"
 
9
#include "FactoryManager.h"
 
10
#include "CommandManager.h"
 
11
#include "DialogManager.h"
 
12
#include "MessageBoxManager.h"
 
13
#include "DataManager.h"
 
14
#include "ActionManager.h"
 
15
#include "ActionCreateData.h"
 
16
#include "ActionCloneData.h"
 
17
#include "ActionDestroyData.h"
 
18
#include "ActionRenameData.h"
 
19
#include "ActionChangePositionData.h"
 
20
#include "PropertyUtility.h"
 
21
#include "DataUtility.h"
 
22
 
 
23
namespace tools
 
24
{
 
25
 
 
26
        FACTORY_ITEM_ATTRIBUTE(SeparatorListControl)
 
27
 
 
28
        SeparatorListControl::SeparatorListControl() :
 
29
                mListBoxControl(nullptr)
 
30
        {
 
31
        }
 
32
 
 
33
        SeparatorListControl::~SeparatorListControl()
 
34
        {
 
35
        }
 
36
 
 
37
        void SeparatorListControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
38
        {
 
39
                Control::OnInitialise(_parent, _place, _layoutName);
 
40
 
 
41
                mListBoxControl = findControl<ListBoxDataControl>();
 
42
 
 
43
                if (mListBoxControl != nullptr)
 
44
                {
 
45
                        mListBoxControl->setEnableChangePosition(false);
 
46
                        mListBoxControl->setReplaceColourName("ColourDisabled");
 
47
 
 
48
                        mListBoxControl->addPropertyNameEnabled("Visible");
 
49
 
 
50
                        mListBoxControl->setDataInfo("Skin", "Separator", "Name");
 
51
                }
 
52
        }
 
53
 
 
54
}