Skip to content

Commit 0459ee8

Browse files
committed
Nicer editable area for multiple selection
Instead of just hiding parts of the UI and disabling the editor section, hide its content completely and show an explanatory placeholder to point the user to the Edit menu for bulk editing.
1 parent 5948215 commit 0459ee8

File tree

7 files changed

+65
-26
lines changed

7 files changed

+65
-26
lines changed

Poedit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
B2BF84C4170849D00030AA22 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2BF84BB170846940030AA22 /* Carbon.framework */; };
177177
B2C21633251906CC002B144A /* recent_files.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C21632251906CC002B144A /* recent_files.cpp */; };
178178
B2C62E191AA8A29000901D63 /* http_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C62E181AA8A29000901D63 /* http_client.cpp */; };
179+
B2C78B202E29621600A60EFE /* EmptyMultiSelectionTemplate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B2C78B1F2E29621600A60EFE /* EmptyMultiSelectionTemplate@2x.png */; };
180+
B2C78B212E29621600A60EFE /* EmptyMultiSelectionTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = B2C78B1E2E29621600A60EFE /* EmptyMultiSelectionTemplate.png */; };
179181
B2CAC13B2BBEE95900707D8D /* libicucore.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B2CAC13A2BBEE95900707D8D /* libicucore.tbd */; };
180182
B2CAC13C2BBEE96300707D8D /* libicucore.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B2CAC13A2BBEE95900707D8D /* libicucore.tbd */; };
181183
B2CE2FEF1A94EBF50020A620 /* crowdin_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2CE2FED1A94EBF50020A620 /* crowdin_client.cpp */; };
@@ -599,6 +601,8 @@
599601
B2C62E181AA8A29000901D63 /* http_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_client.cpp; sourceTree = "<group>"; };
600602
B2C67BBF19B0DE7200691FA4 /* eu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = eu; path = eu.lproj/MoveApplication.strings; sourceTree = "<group>"; };
601603
B2C67BC019B0DE7C00691FA4 /* gl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = gl; path = gl.lproj/MoveApplication.strings; sourceTree = "<group>"; };
604+
B2C78B1E2E29621600A60EFE /* EmptyMultiSelectionTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EmptyMultiSelectionTemplate.png; sourceTree = "<group>"; };
605+
B2C78B1F2E29621600A60EFE /* EmptyMultiSelectionTemplate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "EmptyMultiSelectionTemplate@2x.png"; sourceTree = "<group>"; };
602606
B2CAC13A2BBEE95900707D8D /* libicucore.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.tbd; path = usr/lib/libicucore.tbd; sourceTree = SDKROOT; };
603607
B2CDAA1B1A61866300261248 /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = bg.lproj/InfoPlist.strings; sourceTree = "<group>"; };
604608
B2CDAA1C1A61866300261248 /* bg */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bg; path = bg.lproj/MoveApplication.strings; sourceTree = "<group>"; };
@@ -1156,6 +1160,8 @@
11561160
B26E2C8B25A245BC008D6DF1 /* CloseButtonTemplate@2x.png */,
11571161
B290F9E22166543800741842 /* DownvoteTemplate.png */,
11581162
B290F9E12166543800741842 /* DownvoteTemplate@2x.png */,
1163+
B2C78B1E2E29621600A60EFE /* EmptyMultiSelectionTemplate.png */,
1164+
B2C78B1F2E29621600A60EFE /* EmptyMultiSelectionTemplate@2x.png */,
11591165
B2E836E21709ED2A00F31559 /* poedit-status-cat-mid.png */,
11601166
B2E836E31709ED2A00F31559 /* poedit-status-cat-no.png */,
11611167
B2E836E41709ED2A00F31559 /* poedit-status-cat-ok.png */,
@@ -1443,6 +1449,8 @@
14431449
B290F9E42166543800741842 /* DownvoteTemplate.png in Resources */,
14441450
B29AE89017103992008D1F8A /* comment.xrc in Resources */,
14451451
B26E2C8F25A245BD008D6DF1 /* CloseButtonTemplate@2x.png in Resources */,
1452+
B2C78B202E29621600A60EFE /* EmptyMultiSelectionTemplate@2x.png in Resources */,
1453+
B2C78B212E29621600A60EFE /* EmptyMultiSelectionTemplate.png in Resources */,
14461454
B2A012B321BEE4C5008051FD /* SuggestionTMTemplate@2x.png in Resources */,
14471455
B20F31D0216654DA005B7037 /* StatusWarningBlack.png in Resources */,
14481456
B20F31CC216654D2005B7037 /* StatusErrorBlack@2x.png in Resources */,
363 Bytes
Loading
579 Bytes
Loading
649 Bytes
Loading

artwork/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dist_uiicons_DATA = \
3636
CrowdinLogoDark.png \
3737
LocalazyLogo.png \
3838
DownvoteTemplate.png \
39+
EmptyMultiSelectionTemplate.png \
3940
ExtractorsGNUgettext.png \
4041
ItemCommentTemplate.png \
4142
SuggestionErrorTemplate.png \

src/editing_area.cpp

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -433,29 +433,38 @@ EditingArea::EditingArea(wxWindow *parent, PoeditListCtrl *associatedList, Mode
433433
m_labelPlural->SetFont(m_labelPlural->GetFont().Bold());
434434
m_textOrigPlural = new SourceTextCtrl(this, wxID_ANY);
435435

436-
auto *sizer = new wxBoxSizer(wxVERTICAL);
437-
SetSizer(sizer);
436+
auto *rootSizer = new wxBoxSizer(wxVERTICAL);
437+
SetSizer(rootSizer);
438438

439439
#if defined(__WXMSW__)
440-
sizer->AddSpacer(PX(4) - 4); // account for fixed 4px sash above
440+
rootSizer->AddSpacer(PX(4) - 4); // account for fixed 4px sash above
441441
#elif defined(__WXOSX__)
442-
sizer->AddSpacer(PX(2));
442+
rootSizer->AddSpacer(PX(2));
443443
#endif
444-
sizer->Add(sourceLineSizer, wxSizerFlags().Expand().Border(wxLEFT, PX(5)));
445-
sizer->AddSpacer(PX(6));
444+
445+
m_controlsSizer = new wxBoxSizer(wxVERTICAL);
446+
447+
m_controlsSizer->Add(sourceLineSizer, wxSizerFlags().Expand().Border(wxLEFT, PX(5)));
448+
m_controlsSizer->AddSpacer(PX(6));
446449

447450
auto origTextSizer = new wxBoxSizer(wxVERTICAL);
448451
origTextSizer->AddSpacer(PX(4));
449452
origTextSizer->Add(m_labelSingular, wxSizerFlags().Border(wxLEFT, PX(5)));
450453
origTextSizer->Add(m_textOrig, wxSizerFlags(1).Expand());
451454
origTextSizer->Add(m_labelPlural, wxSizerFlags().Border(wxLEFT, PX(5)));
452455
origTextSizer->Add(m_textOrigPlural, wxSizerFlags(1).Expand());
453-
sizer->Add(origTextSizer, wxSizerFlags(1).Expand());
456+
m_controlsSizer->Add(origTextSizer, wxSizerFlags(1).Expand());
454457

455458
if (mode == POT)
456-
CreateTemplateControls(sizer);
459+
CreateTemplateControls(m_controlsSizer);
457460
else
458-
CreateEditControls(sizer);
461+
CreateEditControls(m_controlsSizer);
462+
463+
m_placeholderSizer = CreatePlaceholderControls();
464+
465+
rootSizer->Add(m_controlsSizer, wxSizerFlags(1).Expand());
466+
rootSizer->Add(m_placeholderSizer, wxSizerFlags(1).Expand());
467+
rootSizer->Hide(m_placeholderSizer);
459468

460469
SetupTextCtrlSizes();
461470

@@ -468,6 +477,7 @@ EditingArea::EditingArea(wxWindow *parent, PoeditListCtrl *associatedList, Mode
468477
#endif
469478
m_labelSingular->SetForegroundColour(ColorScheme::Get(Color::SecondaryLabel));
470479
m_labelPlural->SetForegroundColour(ColorScheme::Get(Color::SecondaryLabel));
480+
m_labelPlaceholder->SetForegroundColour(ColorScheme::Get(Color::SecondaryLabel));
471481
});
472482
}
473483

@@ -596,6 +606,25 @@ void EditingArea::CreateTemplateControls(wxBoxSizer *panelSizer)
596606
}
597607

598608

609+
wxBoxSizer* EditingArea::CreatePlaceholderControls()
610+
{
611+
auto sizer = new wxBoxSizer(wxVERTICAL);
612+
613+
sizer->AddStretchSpacer();
614+
sizer->Add(new wxStaticBitmap(this, wxID_ANY, wxArtProvider::GetBitmap("EmptyMultiSelectionTemplate")),
615+
wxSizerFlags().Center().Border(wxBOTTOM, PX(10)));
616+
m_labelPlaceholder = new wxStaticText(this, wxID_ANY, _("Use the Edit menu to perform bulk actions on selected strings."));
617+
sizer->Add(m_labelPlaceholder, wxSizerFlags().Expand());
618+
sizer->AddStretchSpacer();
619+
620+
auto outerSizer = new wxBoxSizer(wxHORIZONTAL);
621+
outerSizer->AddStretchSpacer(1);
622+
outerSizer->Add(sizer, wxSizerFlags(1).Expand().Border(wxALL, PX(10)));
623+
outerSizer->AddStretchSpacer(1);
624+
return outerSizer;
625+
}
626+
627+
599628
void EditingArea::SetupTextCtrlSizes()
600629
{
601630
int minh = m_textOrig->GetCharHeight();
@@ -623,6 +652,10 @@ void EditingArea::OnPaint(wxPaintEvent&)
623652
width += 1; // correct for half-pixel undrawn part on the right side
624653
#endif
625654

655+
// In case of multiple selection, we don't want to draw the source/trans sections backgrounds
656+
if (!m_isSingleSelection)
657+
return;
658+
626659
const int paddingTop = MACOS_OR_OTHER(dc.GetContentScaleFactor() > 1.0 ? PX(5) : PX(6), PX(6));
627660
const int paddingBottom = PX(5);
628661

@@ -857,11 +890,10 @@ void EditingArea::SetSingleSelectionMode()
857890
return;
858891
m_isSingleSelection = true;
859892

860-
if (m_fuzzy)
861-
m_fuzzy->Show(m_fuzzyToggleNeeded);
862-
m_charCounter->Show();
863-
864-
Enable();
893+
GetSizer()->Show(m_placeholderSizer, false);
894+
GetSizer()->Show(m_controlsSizer, true);
895+
Layout();
896+
Refresh();
865897
}
866898

867899

@@ -871,21 +903,14 @@ void EditingArea::SetMultipleSelectionMode()
871903
return;
872904
m_isSingleSelection = false;
873905

874-
// TODO: Show better UI
875-
876-
if (m_fuzzy)
877-
m_fuzzy->Hide();
878-
m_charCounter->Hide();
879-
ShowPluralFormUI(false);
880-
ShowPart(m_tagIdOrContext, false);
881-
ShowPart(m_tagFormat, false);
882-
ShowPart(m_tagPretranslated, false);
883-
ShowPart(m_issueLine, false);
884-
885906
m_textOrig->Clear();
886907
if (m_textTrans)
887908
m_textTrans->Clear();
888-
Disable();
909+
910+
GetSizer()->Show(m_controlsSizer, false);
911+
GetSizer()->Show(m_placeholderSizer, true);
912+
Layout();
913+
Refresh();
889914
}
890915

891916

src/editing_area.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class EditingArea : public wxPanel
122122

123123
void CreateEditControls(wxBoxSizer *sizer);
124124
void CreateTemplateControls(wxBoxSizer *sizer);
125+
wxBoxSizer *CreatePlaceholderControls();
126+
125127
void SetupTextCtrlSizes();
126128

127129
void ShowPluralFormUI(bool show);
@@ -142,6 +144,8 @@ class EditingArea : public wxPanel
142144

143145
bool m_dontAutoclearFuzzyStatus;
144146

147+
wxBoxSizer *m_controlsSizer, *m_placeholderSizer;
148+
145149
SourceTextCtrl *m_textOrig, *m_textOrigPlural;
146150

147151
SwitchButton *m_fuzzy;
@@ -152,6 +156,7 @@ class EditingArea : public wxPanel
152156
wxBookCtrlBase *m_pluralNotebook;
153157
wxStaticText *m_labelSingular, *m_labelPlural;
154158
wxStaticText *m_labelSource, *m_labelTrans;
159+
wxStaticText *m_labelPlaceholder;
155160

156161
TagLabel *m_tagIdOrContext;
157162
TagLabel *m_tagFormat;

0 commit comments

Comments
 (0)