string choice dialog allow forcing 1 column
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "dialogxml/widgets/field.hpp"
|
#include "dialogxml/widgets/field.hpp"
|
||||||
#include "dialogxml/dialogs/strdlog.hpp"
|
#include "dialogxml/dialogs/strdlog.hpp"
|
||||||
#include "fileio/resmgr/res_dialog.hpp"
|
#include "fileio/resmgr/res_dialog.hpp"
|
||||||
@@ -23,14 +25,20 @@
|
|||||||
|
|
||||||
const sf::Color HILITE_COLOUR = Colours::LIGHT_GREEN;
|
const sf::Color HILITE_COLOUR = Colours::LIGHT_GREEN;
|
||||||
|
|
||||||
cStringChoice::cStringChoice(cDialog* parent, bool editable)
|
cStringChoice::cStringChoice(cDialog* parent, bool editable, bool force_single_column)
|
||||||
: editable(editable)
|
: editable(editable)
|
||||||
, per_page(editable ? 20 : 40)
|
, per_page((editable || force_single_column) ? 20 : 40)
|
||||||
, dlg(*ResMgr::dialogs.get(editable ? "choose-edit-string" : "choose-string"), parent)
|
, dlg(*ResMgr::dialogs.get(editable ? "choose-edit-string" : "choose-string"), parent)
|
||||||
{}
|
{
|
||||||
|
if(force_single_column){
|
||||||
|
for(int i = per_page + 1; i <= per_page * 2; ++i){
|
||||||
|
dlg[fmt::format("led{}", i)].hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cStringChoice::cStringChoice(const std::vector<std::string>& strs, std::string title, cDialog* parent, bool editable)
|
cStringChoice::cStringChoice(const std::vector<std::string>& strs, std::string title, cDialog* parent, bool editable, bool force_single_column)
|
||||||
: cStringChoice(parent, editable)
|
: cStringChoice(parent, editable, force_single_column)
|
||||||
{
|
{
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
strings = strs;
|
strings = strs;
|
||||||
|
@@ -41,13 +41,13 @@ class cStringChoice {
|
|||||||
bool search_open = false;
|
bool search_open = false;
|
||||||
cLedGroup* leds;
|
cLedGroup* leds;
|
||||||
std::function<void(cStringChoice&,int)> select_handler;
|
std::function<void(cStringChoice&,int)> select_handler;
|
||||||
cStringChoice(cDialog* parent, bool editable = false);
|
cStringChoice(cDialog* parent, bool editable = false, bool force_single_column = false);
|
||||||
public:
|
public:
|
||||||
/// Initializes a dialog from a list of strings.
|
/// Initializes a dialog from a list of strings.
|
||||||
/// @param strs A list of all strings in the dialog.
|
/// @param strs A list of all strings in the dialog.
|
||||||
/// @param title The title to show in the dialog.
|
/// @param title The title to show in the dialog.
|
||||||
/// @param parent Optionally, a parent dialog.
|
/// @param parent Optionally, a parent dialog.
|
||||||
explicit cStringChoice(const std::vector<std::string>& strs, std::string title, cDialog* parent = nullptr, bool editable = false);
|
explicit cStringChoice(const std::vector<std::string>& strs, std::string title, cDialog* parent = nullptr, bool editable = false, bool force_single_column = false);
|
||||||
/// Initializes a dialog from an iterator pair.
|
/// Initializes a dialog from an iterator pair.
|
||||||
/// @param begin An iterator to the first string in the dialog.
|
/// @param begin An iterator to the first string in the dialog.
|
||||||
/// @param end An iterator to one past the last string in the dialog.
|
/// @param end An iterator to one past the last string in the dialog.
|
||||||
|
Reference in New Issue
Block a user