Skip to content

Commit

Permalink
Fixed X-Mirror not reactivating and toolbar appearance
Browse files Browse the repository at this point in the history
Using the three tools Collapse Vertex, Flip Edge and Split Edge wouldn't revert to the previous X-Mirror state when going back to a regular brush.
  • Loading branch information
ousnius committed Apr 19, 2020
1 parent 57bac3f commit 69a1ce9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
49 changes: 28 additions & 21 deletions src/program/OutfitStudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2379,18 +2379,17 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
wxMenuBar* menuBar = GetMenuBar();
wxToolBar* toolBar = GetToolBar();

if (glView->GetActiveBrush()) {
int brushType = glView->GetActiveBrush()->Type();
if (brushType == TBT_WEIGHT || brushType == TBT_COLOR || brushType == TBT_ALPHA) {
glView->SetXMirror(previousMirror);
menuBar->Check(XRCID("btnXMirror"), previousMirror);
}
ToolID activeTool = glView->GetActiveTool();
if (activeTool >= ToolID::WeightBrush && activeTool <= ToolID::SplitEdge) {
glView->SetXMirror(previousMirror);
menuBar->Check(XRCID("btnXMirror"), previousMirror);
toolBar->ToggleTool(XRCID("btnXMirror"), previousMirror);
}

if (tool == ToolID::Select) {
glView->SetEditMode(false);
glView->SetBrushMode(false);
glView->SetActiveBrush(ToolID::Select);
glView->SetActiveTool(ToolID::Select);
menuBar->Check(XRCID("btnSelect"), true);
toolBar->ToggleTool(XRCID("btnSelect"), true);

Expand Down Expand Up @@ -2425,7 +2424,7 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
return;
}

glView->SetActiveBrush(tool);
glView->SetActiveTool(tool);
glView->SetCursorType(GLSurface::BrushCursor);

if (tool == ToolID::MaskBrush) {
Expand Down Expand Up @@ -2454,13 +2453,15 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);
}
else if (tool == ToolID::ColorBrush) {
menuBar->Check(XRCID("btnColorBrush"), true);
toolBar->ToggleTool(XRCID("btnColorBrush"), true);
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);

wxButton* btnSwapBrush = (wxButton*)FindWindowById(XRCID("btnSwapBrush"), colorSettings);
btnSwapBrush->SetLabel(_("Edit Alpha"));
Expand All @@ -2471,6 +2472,7 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);

wxButton* btnSwapBrush = (wxButton*)FindWindowById(XRCID("btnSwapBrush"), colorSettings);
btnSwapBrush->SetLabel(_("Edit Color"));
Expand All @@ -2481,6 +2483,7 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);
ToggleBrushPane(true);
glView->SetEditMode();
glView->SetBrushMode(false);
Expand All @@ -2493,6 +2496,7 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);
ToggleBrushPane(true);
glView->SetEditMode();
glView->SetBrushMode(false);
Expand All @@ -2505,6 +2509,7 @@ void OutfitStudioFrame::SelectTool(ToolID tool) {
previousMirror = glView->GetXMirror();
glView->SetXMirror(false);
menuBar->Check(XRCID("btnXMirror"), false);
toolBar->ToggleTool(XRCID("btnXMirror"), false);
ToggleBrushPane(true);
glView->SetEditMode();
glView->SetBrushMode(false);
Expand All @@ -2531,12 +2536,9 @@ bool OutfitStudioFrame::NotifyStrokeStarting() {
if (!activeItem)
return false;

auto activeBrush = glView->GetActiveBrush();
if (activeBrush) {
int brushType = activeBrush->Type();
if (brushType == TBT_MASK || brushType == TBT_WEIGHT || brushType == TBT_COLOR || brushType == TBT_ALPHA)
return true;
}
ToolID activeTool = glView->GetActiveTool();
if (activeTool == ToolID::MaskBrush || activeTool == ToolID::WeightBrush || activeTool == ToolID::ColorBrush || activeTool == ToolID::AlphaBrush)
return true;

if (bEditSlider && project->SliderValue(activeSlider) == 0.0) {
int response = wxMessageBox(_("You are trying to edit a slider's morph with that slider set to zero. Do you wish to set the slider to one now?"),
Expand Down Expand Up @@ -5464,6 +5466,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("btnSplitEdgeTool"), true);
GetMenuBar()->Enable(XRCID("deleteVerts"), true);

GetToolBar()->ToggleTool(XRCID("btnXMirror"), previousMirror);
GetToolBar()->ToggleTool(XRCID("btnInflateBrush"), true);
GetToolBar()->EnableTool(XRCID("btnWeightBrush"), false);
GetToolBar()->EnableTool(XRCID("btnColorBrush"), false);
Expand Down Expand Up @@ -5506,6 +5509,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("btnSplitEdgeTool"), true);
GetMenuBar()->Enable(XRCID("deleteVerts"), true);

GetToolBar()->ToggleTool(XRCID("btnXMirror"), previousMirror);
GetToolBar()->ToggleTool(XRCID("btnInflateBrush"), true);
GetToolBar()->EnableTool(XRCID("btnWeightBrush"), false);
GetToolBar()->EnableTool(XRCID("btnColorBrush"), false);
Expand Down Expand Up @@ -5608,6 +5612,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("deleteVerts"), false);

GetToolBar()->ToggleTool(XRCID("btnWeightBrush"), true);
GetToolBar()->ToggleTool(XRCID("btnXMirror"), false);
GetToolBar()->EnableTool(XRCID("btnWeightBrush"), true);
GetToolBar()->EnableTool(XRCID("btnColorBrush"), false);
GetToolBar()->EnableTool(XRCID("btnAlphaBrush"), false);
Expand Down Expand Up @@ -5672,6 +5677,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("deleteVerts"), false);

GetToolBar()->ToggleTool(XRCID("btnColorBrush"), true);
GetToolBar()->ToggleTool(XRCID("btnXMirror"), false);
GetToolBar()->EnableTool(XRCID("btnColorBrush"), true);
GetToolBar()->EnableTool(XRCID("btnAlphaBrush"), true);
GetToolBar()->EnableTool(XRCID("btnWeightBrush"), false);
Expand Down Expand Up @@ -5753,6 +5759,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("deleteVerts"), false);

GetToolBar()->ToggleTool(XRCID("btnMaskBrush"), true);
GetToolBar()->ToggleTool(XRCID("btnXMirror"), false);
GetToolBar()->ToggleTool(XRCID("btnBrushCollision"), false);
GetToolBar()->EnableTool(XRCID("btnSelect"), false);
GetToolBar()->EnableTool(XRCID("btnTransform"), false);
Expand Down Expand Up @@ -5828,6 +5835,7 @@ void OutfitStudioFrame::OnTabButtonClick(wxCommandEvent& event) {
GetMenuBar()->Enable(XRCID("deleteVerts"), false);

GetToolBar()->ToggleTool(XRCID("btnMaskBrush"), true);
GetToolBar()->ToggleTool(XRCID("btnXMirror"), false);
GetToolBar()->ToggleTool(XRCID("btnBrushCollision"), false);
GetToolBar()->EnableTool(XRCID("btnSelect"), false);
GetToolBar()->EnableTool(XRCID("btnTransform"), false);
Expand Down Expand Up @@ -5887,12 +5895,11 @@ void OutfitStudioFrame::OnBrushColorChanged(wxColourPickerEvent& event) {
}

void OutfitStudioFrame::OnSwapBrush(wxCommandEvent& WXUNUSED(event)) {
if (glView->GetActiveBrush()) {
if (glView->GetActiveBrush()->Type() == TBT_COLOR)
SelectTool(ToolID::AlphaBrush);
else if (glView->GetActiveBrush()->Type() == TBT_ALPHA)
SelectTool(ToolID::ColorBrush);
}
ToolID activeTool = glView->GetActiveTool();
if (activeTool == ToolID::ColorBrush)
SelectTool(ToolID::AlphaBrush);
else if (activeTool == ToolID::AlphaBrush)
SelectTool(ToolID::ColorBrush);
}

void OutfitStudioFrame::HighlightSlider(const std::string& name) {
Expand Down Expand Up @@ -8963,7 +8970,7 @@ void wxGLPanel::SetSelectedShape(const std::string& shapeName) {
gls.SetSelectedMesh(shapeName);
}

void wxGLPanel::SetActiveBrush(ToolID brushID) {
void wxGLPanel::SetActiveTool(ToolID brushID) {
activeTool = brushID;

switch (brushID) {
Expand Down
21 changes: 12 additions & 9 deletions src/program/OutfitStudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ struct ConformOptions {
enum class ToolID {
Any = -1,
Select = 0,
MaskBrush = 1,
InflateBrush = 2,
DeflateBrush = 3,
MoveBrush = 4,
SmoothBrush = 5,
WeightBrush = 6,
ColorBrush = 7,
AlphaBrush = 8,
MaskBrush,
InflateBrush,
DeflateBrush,
MoveBrush,
SmoothBrush,
WeightBrush,
ColorBrush,
AlphaBrush,
CollapseVertex,
FlipEdge,
SplitEdge,
Expand Down Expand Up @@ -182,7 +182,10 @@ class wxGLPanel : public wxGLCanvas {
return &undoHistory;
}

void SetActiveBrush(ToolID brushID);
void SetActiveTool(ToolID brushID);
ToolID GetActiveTool() {
return activeTool;
}
TweakBrush* GetActiveBrush() {
return activeBrush;
}
Expand Down

0 comments on commit 69a1ce9

Please sign in to comment.