Skip to content

Commit

Permalink
#5707: Change action description to a list view..
Browse files Browse the repository at this point in the history
Fix an event loop back when loading a map in two-way merge mode.
  • Loading branch information
codereader committed Aug 28, 2021
1 parent 757053e commit fe42f90
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 21 deletions.
18 changes: 9 additions & 9 deletions install/ui/mergecontroldialog.fbp
Expand Up @@ -1088,7 +1088,7 @@
<property name="border">0</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer151</property>
<property name="orient">wxVERTICAL</property>
Expand Down Expand Up @@ -2072,11 +2072,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">6</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="0">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand Down Expand Up @@ -2127,7 +2127,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer271</property>
<property name="orient">wxVERTICAL</property>
Expand Down Expand Up @@ -2193,11 +2193,11 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">12</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer261</property>
<property name="orient">wxVERTICAL</property>
Expand Down Expand Up @@ -2263,11 +2263,11 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<object class="sizeritem" expanded="1">
<property name="border">0</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="0">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand Down
2 changes: 1 addition & 1 deletion install/ui/mergecontroldialog.xrc
Expand Up @@ -475,7 +475,7 @@
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND | wxALL</flag>
<border>5</border>
<border>0</border>
<object class="wxPanel" name="ActionDescriptionPanel">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
Expand Down
57 changes: 46 additions & 11 deletions radiant/ui/merge/MergeControlDialog.cpp
Expand Up @@ -9,6 +9,7 @@
#include "imap.h"
#include "wxutil/PathEntry.h"
#include "wxutil/Bitmap.h"
#include "wxutil/dataview/TreeView.h"
#include "wxutil/dialog/MessageBox.h"
#include "scenelib.h"
#include "string/convert.h"
Expand All @@ -35,6 +36,28 @@ namespace
const std::string RKEY_WINDOW_STATE = RKEY_ROOT + "window";
}

namespace
{

// Column setup for the list store
struct Columns :
public wxutil::TreeModel::ColumnRecord
{
Columns() :
description(add(wxutil::TreeModel::Column::String))
{}

wxutil::TreeModel::Column description;
};

const Columns& COLUMNS()
{
static const Columns _instance;
return _instance;
}

}

MergeControlDialog::MergeControlDialog() :
TransientWindow(_(WINDOW_TITLE), GlobalMainFrame().getWxTopLevelWindow(), true),
_updateNeeded(false),
Expand Down Expand Up @@ -84,6 +107,16 @@ MergeControlDialog::MergeControlDialog() :
threeWayButton->SetBitmap(wxutil::GetLocalBitmap("three_way_merge.png"));
threeWayButton->Bind(wxEVT_TOGGLEBUTTON, &MergeControlDialog::onMergeModeChanged, this);

auto actionDescriptionPanel = findNamedObject<wxPanel>(this, "ActionDescriptionPanel");

// Create the action list view
_descriptionStore = new wxutil::TreeModel(COLUMNS(), true);
auto listView = wxutil::TreeView::CreateWithModel(actionDescriptionPanel, _descriptionStore.get(), wxDV_NO_HEADER | wxDV_SINGLE);
listView->SetMinClientSize(wxSize(-1, 70));
listView->AppendTextColumn("-", COLUMNS().description.getColumnIndex(), wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE);

actionDescriptionPanel->GetSizer()->Add(listView, 0, wxEXPAND | wxBOTTOM, 6);

updateControls();
Bind(wxEVT_IDLE, &MergeControlDialog::onIdle, this);

Expand Down Expand Up @@ -296,7 +329,7 @@ void MergeControlDialog::onFinishMerge(wxCommandEvent& ev)
update();
}

inline void addActionDescription(wxPanel* panel, const scene::INodePtr& candidate)
inline void addActionDescription(const wxutil::TreeModel::Ptr& listStore, const scene::INodePtr& candidate)
{
auto node = std::dynamic_pointer_cast<scene::IMergeActionNode>(candidate);

Expand Down Expand Up @@ -363,10 +396,10 @@ inline void addActionDescription(wxPanel* panel, const scene::INodePtr& candidat
}
}

auto* staticText = new wxStaticText(panel, wxID_ANY, text);
staticText->Wrap(panel->GetSize().x);
staticText->Layout();
panel->GetSizer()->Add(staticText, 0, wxBOTTOM, 6);
auto row = listStore->AddItem();
row[COLUMNS().description] = text;

row.SendItemAdded();
});
}

Expand All @@ -388,15 +421,17 @@ void MergeControlDialog::updateControls()
// Fill in the map names in case the merge operation has already been started by the time the dialog is shown
if (mergeInProgress)
{
if (baseMapPath.empty() && GlobalMapModule().getActiveMergeOperation())
auto mergeOperation = GlobalMapModule().getActiveMergeOperation();

if (baseMapPath.empty() && mergeOperation && mergeOperation->getBasePath() != baseMapPath)
{
baseMapPath = GlobalMapModule().getActiveMergeOperation()->getBasePath();
baseMapPath = mergeOperation->getBasePath();
baseMapPathEntry->setValue(baseMapPath);
}

if (sourceMapPath.empty() && GlobalMapModule().getActiveMergeOperation())
if (sourceMapPath.empty() && mergeOperation && mergeOperation->getSourcePath() != sourceMapPath)
{
sourceMapPath = GlobalMapModule().getActiveMergeOperation()->getSourcePath();
sourceMapPath = mergeOperation->getSourcePath();
sourceMapPathEntry->setValue(sourceMapPath);
}
}
Expand All @@ -423,11 +458,11 @@ void MergeControlDialog::updateControls()
findNamedObject<wxButton>(this, "JumpToNextConflictButton")->Enable(mergeInProgress && _numUnresolvedConflicts > 0);

actionDescriptionPanel->Show(selectedMergeNodes.size() == 1);
actionDescriptionPanel->DestroyChildren();
_descriptionStore->Clear();

if (selectedMergeNodes.size() == 1)
{
addActionDescription(actionDescriptionPanel, selectedMergeNodes.front());
addActionDescription(_descriptionStore, selectedMergeNodes.front());
}

InvalidateBestSize();
Expand Down
3 changes: 3 additions & 0 deletions radiant/ui/merge/MergeControlDialog.h
Expand Up @@ -6,6 +6,7 @@
#include <sigc++/connection.h>
#include "wxutil/window/TransientWindow.h"
#include "wxutil/XmlResourceBasedWidget.h"
#include "wxutil/dataview/TreeModel.h"

namespace ui
{
Expand All @@ -25,6 +26,8 @@ class MergeControlDialog final :
bool _updateNeeded;
std::size_t _numUnresolvedConflicts;

wxutil::TreeModel::Ptr _descriptionStore;

public:
MergeControlDialog();

Expand Down

0 comments on commit fe42f90

Please sign in to comment.