Skip to content

Commit ebd60fe

Browse files
committed
Add some comments and misc organization
1 parent 8de86ac commit ebd60fe

File tree

9 files changed

+121
-102
lines changed

9 files changed

+121
-102
lines changed

Assets/smallfont.bmp

-46.9 KB
Binary file not shown.

Editor/GUIEditorApp.cpp

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -140,80 +140,6 @@ namespace RTEGUI {
140140
m_RootControl = rootBox;
141141
}
142142

143-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
144-
145-
void GUIEditorApp::UpdateGridSize(GUIEvent &editorEvent) {
146-
std::string newValue = dynamic_cast<GUITextBox *>(editorEvent.GetControl())->GetText();
147-
if (newValue.empty()) { newValue = "1"; }
148-
149-
bool validEntry = true;
150-
for (const char &stringChar : newValue) {
151-
if (!std::isdigit(stringChar)) {
152-
validEntry = false;
153-
break;
154-
}
155-
}
156-
m_GridSize = validEntry ? std::clamp(std::stoi(newValue), 0, 255) : m_GridSize;
157-
dynamic_cast<GUITextBox *>(editorEvent.GetControl())->SetText(std::to_string(m_GridSize));
158-
159-
m_EditorBase->SetFocus();
160-
}
161-
162-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
163-
164-
void GUIEditorApp::UpdatePropertyPage(GUIEvent &editorEvent) {
165-
if (editorEvent.GetMsg() == GUIPropertyPage::Enter) {
166-
// Update the focused control properties
167-
GUIControl *control = m_SelectionInfo.Control;
168-
if (control) { control->ApplyProperties(m_PropertyPage->GetPropertyValues()); }
169-
m_UnsavedChanges = true;
170-
m_EditorBase->SetFocus();
171-
}
172-
if (editorEvent.GetMsg() == GUIPropertyPage::Changed) {
173-
// The properties are dirty and need to be updated
174-
m_UnsavedChanges = true;
175-
}
176-
}
177-
178-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
179-
180-
void GUIEditorApp::UpdateControlProperties(GUIControl *control, bool setUnsavedChanges) {
181-
control->StoreProperties();
182-
183-
GUIProperties properties;
184-
properties.Update(control->GetProperties(), true);
185-
control->GetPanel()->BuildProperties(&properties);
186-
m_PropertyPage->SetPropertyValues(&properties);
187-
188-
if (setUnsavedChanges) { m_UnsavedChanges = true; }
189-
}
190-
191-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
192-
193-
void GUIEditorApp::UpdateCollectionBoxList() {
194-
const GUIListPanel::Item *item = m_CollectionBoxList->GetSelected();
195-
196-
if (item) {
197-
// Try to find the box of that name, and select it
198-
GUIControl *boxControl = m_ControlManager->GetControl(item->m_Name.substr(item->m_Name.find_first_not_of('\t'), std::string::npos));
199-
if (boxControl) {
200-
m_SelectionInfo.GrabbedControl = false;
201-
m_SelectionInfo.GrabbedHandle = false;
202-
m_SelectionInfo.Control = boxControl;
203-
204-
PopulateCollectionBoxChildrenList(dynamic_cast<GUICollectionBox *>(boxControl));
205-
}
206-
} else {
207-
// Deselection if clicked on no list item
208-
m_SelectionInfo.GrabbedControl = false;
209-
m_SelectionInfo.GrabbedHandle = false;
210-
m_SelectionInfo.Control = nullptr;
211-
212-
m_ControlsInActiveCollectionBoxList->ClearList();
213-
}
214-
m_EditorBase->SetFocus();
215-
}
216-
217143
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
218144

219145
void GUIEditorApp::SelectActiveControlInList() const {
@@ -479,6 +405,80 @@ namespace RTEGUI {
479405
return controlType;
480406
}
481407

408+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
409+
410+
void GUIEditorApp::UpdateCollectionBoxList() {
411+
const GUIListPanel::Item *item = m_CollectionBoxList->GetSelected();
412+
413+
if (item) {
414+
// Try to find the box of that name, and select it
415+
GUIControl *boxControl = m_ControlManager->GetControl(item->m_Name.substr(item->m_Name.find_first_not_of('\t'), std::string::npos));
416+
if (boxControl) {
417+
m_SelectionInfo.GrabbedControl = false;
418+
m_SelectionInfo.GrabbedHandle = false;
419+
m_SelectionInfo.Control = boxControl;
420+
421+
PopulateCollectionBoxChildrenList(dynamic_cast<GUICollectionBox *>(boxControl));
422+
}
423+
} else {
424+
// Deselection if clicked on no list item
425+
m_SelectionInfo.GrabbedControl = false;
426+
m_SelectionInfo.GrabbedHandle = false;
427+
m_SelectionInfo.Control = nullptr;
428+
429+
m_ControlsInActiveCollectionBoxList->ClearList();
430+
}
431+
m_EditorBase->SetFocus();
432+
}
433+
434+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
435+
436+
void GUIEditorApp::UpdateGridSize(GUIEvent &editorEvent) {
437+
std::string newValue = dynamic_cast<GUITextBox *>(editorEvent.GetControl())->GetText();
438+
if (newValue.empty()) { newValue = "1"; }
439+
440+
bool validEntry = true;
441+
for (const char &stringChar : newValue) {
442+
if (!std::isdigit(stringChar)) {
443+
validEntry = false;
444+
break;
445+
}
446+
}
447+
m_GridSize = validEntry ? std::clamp(std::stoi(newValue), 0, 255) : m_GridSize;
448+
dynamic_cast<GUITextBox *>(editorEvent.GetControl())->SetText(std::to_string(m_GridSize));
449+
450+
m_EditorBase->SetFocus();
451+
}
452+
453+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
454+
455+
void GUIEditorApp::UpdateControlProperties(GUIControl *control, bool setUnsavedChanges) {
456+
control->StoreProperties();
457+
458+
GUIProperties properties;
459+
properties.Update(control->GetProperties(), true);
460+
control->GetPanel()->BuildProperties(&properties);
461+
m_PropertyPage->SetPropertyValues(&properties);
462+
463+
if (setUnsavedChanges) { m_UnsavedChanges = true; }
464+
}
465+
466+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
467+
468+
void GUIEditorApp::UpdatePropertyPage(GUIEvent &editorEvent) {
469+
if (editorEvent.GetMsg() == GUIPropertyPage::Enter) {
470+
// Update the focused control properties
471+
GUIControl *control = m_SelectionInfo.Control;
472+
if (control) { control->ApplyProperties(m_PropertyPage->GetPropertyValues()); }
473+
m_UnsavedChanges = true;
474+
m_EditorBase->SetFocus();
475+
}
476+
if (editorEvent.GetMsg() == GUIPropertyPage::Changed) {
477+
// The properties are dirty and need to be updated
478+
m_UnsavedChanges = true;
479+
}
480+
}
481+
482482
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
483483

484484
bool GUIEditorApp::Update() {

Editor/GUIEditorApp.h

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ namespace RTEGUI {
148148
void CreateEditorLayout();
149149
#pragma endregion
150150

151-
/// <summary>
152-
/// Updates the list of Active top level ControlBoxs found in the editor.
153-
/// </summary>
154-
void UpdateCollectionBoxList();
155-
156151
/// <summary>
157152
///
158153
/// </summary>
@@ -221,36 +216,45 @@ namespace RTEGUI {
221216
/// <returns></returns>
222217
int ProcessSnapCoord(int position) const;
223218

219+
#pragma region GUI Element Creation
224220
/// <summary>
225-
///
221+
/// Create a new GUI element in the workspace.
226222
/// </summary>
227-
void UpdatePropertyPage(GUIEvent &editorEvent);
223+
/// <param name="editorEvent">The editor event (button press) to create the element from.</param>
224+
void AddNewControl(GUIEvent &editorEvent);
228225

229226
/// <summary>
230-
///
227+
/// Generates a name for a new GUI element based on the element type.
231228
/// </summary>
232-
/// <param name="control"></param>
233-
void UpdateControlProperties(GUIControl *control, bool setUnsavedChanges = true);
229+
/// <param name="strControlType">Control Type.</param>
230+
/// <returns></returns>
231+
std::string GenerateControlName(std::string controlType) const;
232+
#pragma endregion
234233

234+
#pragma region Updates
235235
/// <summary>
236-
///
236+
/// Updates the list of active top and sub level CollectionBoxes found in the workspace.
237+
/// </summary>
238+
void UpdateCollectionBoxList();
239+
240+
/// <summary>
241+
/// Updates the snap grid size.
237242
/// </summary>
238-
/// <param name="editorEvent"></param>
243+
/// <param name="editorEvent">The editor event to get update info from.</param>
239244
void UpdateGridSize(GUIEvent &editorEvent);
240245

241-
#pragma region GUI Element Creation
242246
/// <summary>
243-
/// Create a new GUI element in the workspace.
247+
/// Updates the properties of an element in the workspace.
244248
/// </summary>
245-
/// <param name="editorEvent">The editor event (button press) to create the element from.</param>
246-
void AddNewControl(GUIEvent &editorEvent);
249+
/// <param name="control">The element to update properties for.</param>
250+
/// <param name="setUnsavedChanges">Whether the editor should ask to save changes before quitting.</param>
251+
void UpdateControlProperties(GUIControl *control, bool setUnsavedChanges = true);
247252

248253
/// <summary>
249-
/// Generates a name for a new GUI element based on the element type.
254+
/// Updates the property page in the left column with all the properties of the currently selected element.
250255
/// </summary>
251-
/// <param name="strControlType">Control Type.</param>
252-
/// <returns></returns>
253-
std::string GenerateControlName(std::string controlType) const;
256+
/// <param name="editorEvent">The editor event to get update info from.</param>
257+
void UpdatePropertyPage(GUIEvent &editorEvent);
254258
#pragma endregion
255259

256260
#pragma region Input Handling
@@ -287,12 +291,27 @@ namespace RTEGUI {
287291

288292
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
289293

294+
#pragma region Allegro Callback Handling
290295
/// <summary>
291-
/// Callback functions for handling events in Allegro.
296+
/// Window title bar quit button handling.
292297
/// </summary>
293298
static void QuitHandler() { g_GUIEditor.OnQuitButton(); }
299+
300+
/// <summary>
301+
/// Window resize handling.
302+
/// </summary>
303+
/// <param name="resizeInfo"></param>
294304
static void ResizeHandler(RESIZE_DISPLAY_EVENT *resizeInfo) { g_GUIEditor.OnWindowResize(resizeInfo); }
305+
306+
/// <summary>
307+
/// Window lose focus handling. Used to fix key buffer not clearing when the main window loses focus, making keys pressed before the focus loss "stuck" between updates.
308+
/// </summary>
295309
static void SwitchOutHandler() { remove_keyboard(); }
310+
311+
/// <summary>
312+
/// Window gain focus handling. Used to fix key buffer not clearing when the main window loses focus, making keys pressed before the focus loss "stuck" between updates.
313+
/// </summary>
296314
static void SwitchInHandler() { install_keyboard(); }
315+
#pragma endregion
297316
}
298317
#endif

GUI/GUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct GUIRect { long left; long top; long right; long bottom; };
1818
inline void SetRect(GUIRect *rect, int left, int top, int right, int bottom) { rect->left = left; rect->top = top; rect->right = right; rect->bottom = bottom; }
1919
#pragma endregion
2020

21-
#include "Interface.h"
21+
#include "GUIInterface.h"
2222
#include "GUIProperties.h"
2323
#include "GUIInput.h"
2424
#include "GUIFont.h"
File renamed without changes.

GUI/GUIListPanel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// Inclusions of header files
1616

1717
#include "GUIScrollPanel.h"
18-
#include "Interface.h"
18+
#include "GUIInterface.h"
1919

2020

2121
namespace RTE

GUI/Wrappers/AllegroBitmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
// www.shplorb.com/~jackal
1212

13-
#include "Interface.h"
13+
#include "GUIInterface.h"
1414
#include "ContentFile.h"
1515
#include "allegro.h"
1616
#include "winalleg.h"

GUIEditor.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
<ClInclude Include="GUI\GUIEvent.h" />
178178
<ClInclude Include="GUI\GUIFont.h" />
179179
<ClInclude Include="GUI\GUIInput.h" />
180+
<ClInclude Include="GUI\GUIInterface.h" />
180181
<ClInclude Include="GUI\GUILabel.h" />
181182
<ClInclude Include="GUI\GUIListBox.h" />
182183
<ClInclude Include="GUI\GUIListPanel.h" />
@@ -197,7 +198,6 @@
197198
<ClInclude Include="GUI\Wrappers\AllegroBitmap.h" />
198199
<ClInclude Include="GUI\Wrappers\AllegroInput.h" />
199200
<ClInclude Include="GUI\Wrappers\AllegroScreen.h" />
200-
<ClInclude Include="GUI\Wrappers\Interface.h" />
201201
<ClInclude Include="Resources\resource.h" />
202202
<ClInclude Include="System\ContentFile.h" />
203203
<ClInclude Include="System\Reader.h" />

GUIEditor.vcxproj.filters

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@
260260
<ClInclude Include="System\Singleton.h">
261261
<Filter>System</Filter>
262262
</ClInclude>
263-
<ClInclude Include="GUI\Wrappers\Interface.h">
264-
<Filter>GUI\Wrappers</Filter>
265-
</ClInclude>
266263
<ClInclude Include="Editor\GUIEditorUtil.h">
267264
<Filter>Editor</Filter>
268265
</ClInclude>
266+
<ClInclude Include="GUI\GUIInterface.h">
267+
<Filter>GUI</Filter>
268+
</ClInclude>
269269
</ItemGroup>
270270
<ItemGroup>
271271
<ResourceCompile Include="Resources\Resource.rc">

0 commit comments

Comments
 (0)