Add staticbox padding style in Atlas

GTK static box doesn't have padding, so add a style variable to allow
adding a custom padding.

Replace implicit padding with explicit padding where needed.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser
2026-06-18 21:10:27 +02:00
parent d23f9e1da3
commit 310c4bf028
6 changed files with 63 additions and 40 deletions
@@ -21,6 +21,7 @@
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
#include "tools/atlas/GameInterface/Messages.h"
#include "tools/atlas/GameInterface/Shareable.h"
@@ -64,21 +65,22 @@ CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarCo
wxStaticBoxSizer* commonSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Common settings"));
m_MainSizer->Add(commonSizer, wxSizerFlags().Expand());
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
gridSizer->AddGrowableCol(1);
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(1, 5, 5);
gridSizer->AddGrowableCol(0);
gridSizer->Add(Tooltipped(m_DrawPath = new wxCheckBox(commonSizer->GetStaticBox(), ID_PathsDrawing, _("Draw all paths")),
_("Display every cinematic path added to the map")));
commonSizer->Add(gridSizer, wxSizerFlags().Expand());
commonSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
// Paths list panel
wxStaticBoxSizer* pathsBoxSizer = new wxStaticBoxSizer(wxVERTICAL, commonSizer->GetStaticBox(), _T("Paths"));
wxStaticBox* pathsBox = pathsBoxSizer->GetStaticBox();
commonSizer->Add(pathsBoxSizer, wxSizerFlags().Proportion(1).Expand().Border(wxALL, 5));
gridSizer->Add(pathsBoxSizer, wxSizerFlags().Proportion(1).Expand());
wxFlexGridSizer* pathsSizer = new wxFlexGridSizer(1, 5, 5);
pathsSizer->AddGrowableCol(0);
pathsBoxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, 5));
pathsBoxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
pathsSizer->Add(m_PathList = new wxListBox(pathsBox, ID_PathsList, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT), wxSizerFlags().Proportion(1).Expand());
commonSizer->AddSpacer(3);
@@ -24,6 +24,7 @@
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/LightControl.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
#include "tools/atlas/GameInterface/Messages.h"
#include "tools/atlas/GameInterface/Shareable.h"
@@ -71,7 +72,7 @@ public:
SetSizer(m_Sizer);
m_Slider = new wxSlider(m_Sizer->GetStaticBox(), -1, 0, 0, range);
m_Sizer->Add(m_Slider, wxSizerFlags().Expand().Border(wxALL, 5));
m_Sizer->Add(m_Slider, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
}
void OnSettingsChange(const AtlasMessage::sEnvironmentSettings& WXUNUSED(env))
@@ -118,7 +119,7 @@ public:
m_Combo = new wxComboBox(
m_Sizer->GetStaticBox(), -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxArrayString(), wxCB_READONLY),
m_Sizer->Add(m_Combo, wxSizerFlags().Expand().Border(wxALL, 5));
m_Sizer->Add(m_Combo, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
}
void SetChoices(const std::vector<std::wstring>& choices)
@@ -173,7 +174,7 @@ public:
SetSizer(m_Sizer);
m_Button = new wxButton(m_Sizer->GetStaticBox(), -1);
m_Sizer->Add(m_Button, wxSizerFlags().Expand().Border(wxALL, 5));
m_Sizer->Add(m_Button, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
}
void OnSettingsChange(const AtlasMessage::sEnvironmentSettings& WXUNUSED(env))
@@ -242,7 +243,7 @@ EnvironmentSidebar::EnvironmentSidebar(
m_MainSizer->Add(waterBoxSizer, wxSizerFlags().Expand());
wxFlexGridSizer* waterSizer = new wxFlexGridSizer(1, 10, 10);
waterSizer->AddGrowableCol(0);
waterBoxSizer->Add(waterSizer, wxSizerFlags().Expand().Border(wxALL, 5));
waterBoxSizer->Add(waterSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
waterSizer->Add(new wxButton(
waterBox, ID_RecomputeWaterData, _("Reset Water Data")), wxSizerFlags().Expand());
@@ -273,7 +274,7 @@ EnvironmentSidebar::EnvironmentSidebar(
m_MainSizer->Add(sunBoxSizer, wxSizerFlags().Expand());
wxFlexGridSizer* sunSizer = new wxFlexGridSizer(1, 10, 10);
sunSizer->AddGrowableCol(0);
sunBoxSizer->Add(sunSizer, wxSizerFlags().Expand().Border(wxALL, 5));
sunBoxSizer->Add(sunSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
sunSizer->Add(new VariableSliderBox(
sunBox, _("Sun rotation"), g_EnvironmentSettings.sunrotation, -std::numbers::pi_v<float>, std::numbers::pi_v<float>), wxSizerFlags().Expand());
@@ -301,7 +302,7 @@ EnvironmentSidebar::EnvironmentSidebar(
m_MainSizer->Add(postProcBoxSizer, wxSizerFlags().Expand());
wxFlexGridSizer* postProcSizer = new wxFlexGridSizer(1, 10, 10);
postProcSizer->AddGrowableCol(0);
postProcBoxSizer->Add(postProcSizer, wxSizerFlags().Expand().Border(wxALL, 5));
postProcBoxSizer->Add(postProcSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
postProcSizer->Add(m_PostEffectList = new VariableListBox(
postProcBox, _("Post Effect"), g_EnvironmentSettings.posteffect), wxSizerFlags().Expand());
@@ -25,6 +25,7 @@
#include "tools/atlas/AtlasUI/General/Observable.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
#include "tools/atlas/GameInterface/MessagePasser.h"
#include "tools/atlas/GameInterface/Messages.h"
@@ -184,7 +185,7 @@ void MapSettingsControl::CreateWidgets()
wxFlexGridSizer* grid = new wxFlexGridSizer(1, 5, 5);
grid->AddGrowableCol(0);
topSizer->Add(grid, wxSizerFlags().Border(wxALL, 5).Expand());
topSizer->Add(grid, wxSizerFlags().Border(wxALL, Atlas::Style::STATICBOX_PADDING).Expand());
/////////////////////////////////////////////////////////////////////////
// Map settings
@@ -232,7 +233,7 @@ void MapSettingsControl::CreateWidgets()
CREATE_CHECKBOX(victoryConditionSizer->GetStaticBox(), vcGridSizer, title, "Select " + title + " victory condition.", index);
}
victoryConditionSizer->Add(vcGridSizer, wxSizerFlags().Border(wxALL, 5));
victoryConditionSizer->Add(vcGridSizer, wxSizerFlags().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
grid->Add(victoryConditionSizer, wxSizerFlags().Expand());
//sizer->AddSpacer(5);
@@ -245,7 +246,7 @@ void MapSettingsControl::CreateWidgets()
CREATE_CHECKBOX(keywordsBox, kwGridSizer, "New", "If checked, the map will appear in the list of new maps", ID_MapKW_New);
CREATE_CHECKBOX(keywordsBox, kwGridSizer, "Trigger", "If checked, the map will appear in the list of maps with trigger scripts", ID_MapKW_Trigger);
keywordsSizer->Add(kwGridSizer, wxSizerFlags().Border(wxALL, 5));
keywordsSizer->Add(kwGridSizer, wxSizerFlags().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
grid->Add(keywordsSizer, wxSizerFlags().Expand());
}
@@ -488,7 +489,7 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
wxFlexGridSizer* grid = new wxFlexGridSizer(1, 10, 10);
grid->AddGrowableCol(0);
topSizer->Add(grid, wxSizerFlags().Border(wxALL, 5).Expand());
topSizer->Add(grid, wxSizerFlags().Border(wxALL, Atlas::Style::STATICBOX_PADDING).Expand());
m_MainSizer->Add(topSizer, wxSizerFlags().Expand());
@@ -532,7 +533,7 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
/////////////////////////////////////////////////////////////////////////
// Misc tools
wxStaticBoxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Misc tools"));
sizer->Add(new wxButton(sizer->GetStaticBox(), ID_ResizeMap, _("Resize/Recenter map")), wxSizerFlags().Expand().Border(wxALL, 5));
sizer->Add(new wxButton(sizer->GetStaticBox(), ID_ResizeMap, _("Resize/Recenter map")), wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
}
@@ -555,7 +556,7 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
_("Pause the simulation")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(topBox, ID_SimReset, _("Reset"), wxDefaultPosition, wxSize(48, -1)),
_("Reset the editor to initial state")), wxSizerFlags().Expand());
topSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, 5));
topSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
UpdateSimButtons();
}
}
@@ -24,6 +24,7 @@
#include "tools/atlas/AtlasUI/General/Observable.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
#include "tools/atlas/GameInterface/MessagePasser.h"
#include "tools/atlas/GameInterface/Messages.h"
@@ -143,7 +144,8 @@ public:
Freeze();
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
wxFlexGridSizer* sizer = new wxFlexGridSizer(1, 10, 10);
sizer->AddGrowableCol(0);
SetSizer(sizer);
{
@@ -179,8 +181,8 @@ public:
_("Select AI")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT));
m_Controls.ai = aiChoice;
playerInfoSizer->Add(gridSizer, wxSizerFlags(1).Expand().Border(wxALL, 5));
sizer->Add(playerInfoSizer, wxSizerFlags().Expand().Border(wxTOP, 5));
playerInfoSizer->Add(gridSizer, wxSizerFlags(1).Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
sizer->Add(playerInfoSizer, wxSizerFlags().Expand());
}
{
@@ -225,8 +227,8 @@ public:
_("Population limit for this player")), wxSizerFlags().Expand());
m_Controls.pop = popCtrl;
resourceSizer->Add(gridSizer, wxSizerFlags(1).Expand().Border(wxALL, 5));
sizer->Add(resourceSizer, wxSizerFlags().Expand().Border(wxTOP, 10));
resourceSizer->Add(gridSizer, wxSizerFlags(1).Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
sizer->Add(resourceSizer, wxSizerFlags().Expand());
}
{
/////////////////////////////////////////////////////////////////////////
@@ -245,12 +247,12 @@ public:
teamCtrl->Append(_T("4"));
boxSizer->Add(teamCtrl);
m_Controls.team = teamCtrl;
diplomacySizer->Add(boxSizer, wxSizerFlags().Expand().Border(wxALL, 5));
diplomacySizer->Add(boxSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
// TODO: possibly have advanced panel where each player's diplomacy can be set?
// Advanced panel
sizer->Add(diplomacySizer, wxSizerFlags().Expand().Border(wxTOP, 10));
sizer->Add(diplomacySizer, wxSizerFlags().Expand());
}
{
@@ -269,9 +271,9 @@ public:
cameraClear->Enable(false);
gridSizer->Add(Tooltipped(cameraClear,
_("Clear player camera")), wxSizerFlags().Expand());
cameraSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, 5));
cameraSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
sizer->Add(cameraSizer, wxSizerFlags().Expand().Border(wxTOP, 10));
sizer->Add(cameraSizer, wxSizerFlags().Expand());
}
Layout();
@@ -592,16 +594,29 @@ PlayerSettingsControl::PlayerSettingsControl(wxWindow* parent, ScenarioEditor& s
wxStaticBox* topBox = topSizer->GetStaticBox();
SetSizer(topSizer);
wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
boxSizer->Add(new wxStaticText(topBox, wxID_ANY, _("Num players")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
boxSizer->AddSpacer(10);
wxSpinCtrl* numPlayersSpin = new wxSpinCtrl(topBox, ID_NumPlayers, wxEmptyString, wxDefaultPosition, wxSize(40, -1));
numPlayersSpin->SetValue(MAX_NUM_PLAYERS);
numPlayersSpin->SetRange(1, MAX_NUM_PLAYERS);
boxSizer->Add(numPlayersSpin);
topSizer->Add(boxSizer, wxSizerFlags().Expand().Proportion(0).Border(wxALL, 5));
m_Players = new PlayerNotebook(topBox);
topSizer->Add(m_Players, wxSizerFlags().Expand().Proportion(1).Border(wxALL, 5));
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(1, 10, 10);
gridSizer->AddGrowableCol(0);
topSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
{
wxBoxSizer* boxSizer = new wxBoxSizer(wxHORIZONTAL);
boxSizer->Add(new wxStaticText(topBox, wxID_ANY, _("Num players")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
boxSizer->AddSpacer(10);
wxSpinCtrl* numPlayersSpin = new wxSpinCtrl(topBox, ID_NumPlayers, wxEmptyString, wxDefaultPosition, wxSize(40, -1));
numPlayersSpin->SetValue(MAX_NUM_PLAYERS);
numPlayersSpin->SetRange(1, MAX_NUM_PLAYERS);
boxSizer->Add(numPlayersSpin);
gridSizer->Add(boxSizer);
}
{
m_Players = new PlayerNotebook(topBox);
gridSizer->Add(m_Players, wxSizerFlags().Expand());
}
m_InGUIUpdate = false;
}
@@ -23,6 +23,7 @@
#include "tools/atlas/AtlasUI/General/Observable.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Brushes.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/MiscState.h"
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
@@ -235,7 +236,7 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
_("Brush with left mouse button to smooth terrain,\nright mouse button to roughen it")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), sizer->GetStaticBox(), _("Flatten"), _T("FlattenElevation"), wxSize(48, -1)),
_("Brush with left mouse button to flatten terrain")), wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, 5));
sizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
}
@@ -250,7 +251,7 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
_("Replace all of a terrain texture with a new one")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), sizer->GetStaticBox(), _("Fill"), _T("FillTerrain"), wxSize(48, -1)),
_T("Bucket fill a patch of terrain texture with a new one")), wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, 5));
sizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
}
@@ -260,7 +261,7 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
wxStaticBoxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Brush"));
m_TexturePreview = new TexturePreviewPanel(sizer->GetStaticBox());
sizer->Add(m_TexturePreview, wxSizerFlags(1).Expand().Border(wxALL, 5));
sizer->Add(m_TexturePreview, wxSizerFlags(1).Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
g_Brush_Elevation.CreateUI(sizer->GetStaticBox(), sizer);
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
@@ -274,7 +275,7 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
wxFlexGridSizer* visSizer = new wxFlexGridSizer(2, 5, 5);
visSizer->AddGrowableCol(1);
sizer->Add(visSizer, wxSizerFlags().Expand().Border(wxALL, 5));
sizer->Add(visSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
wxArrayString defaultChoices;
defaultChoices.Add(_("(none)"));
@@ -27,14 +27,17 @@ namespace Atlas::Style
constexpr int BOTTOMBAR_DEFAULT_SIZE = 200;
constexpr int SIDEBAR_DEFAULT_SIZE = 285;
constexpr int SIDEBAR_MAINLAOYOUT_VGAP = 10;
constexpr int STATICBOX_PADDING = 5;
#elif defined(__WXOSX__) || defined(__WXMAC__)
constexpr int BOTTOMBAR_DEFAULT_SIZE = 210;
constexpr int SIDEBAR_DEFAULT_SIZE = 285;
constexpr int SIDEBAR_MAINLAOYOUT_VGAP = 5;
constexpr int STATICBOX_PADDING = 0;
#else // __MSW__
constexpr int BOTTOMBAR_DEFAULT_SIZE = 180;
constexpr int SIDEBAR_DEFAULT_SIZE = 235;
constexpr int SIDEBAR_MAINLAOYOUT_VGAP = 5;
constexpr int STATICBOX_PADDING = 0;
#endif
} // namespace Atlas::Style