mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Themed checkboxes
Slightly larger items in (multiple) choice viewers
This commit is contained in:
@@ -116,7 +116,7 @@ String ChoiceField::Choice::choiceName(int id) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
return _("");
|
||||
return String();
|
||||
}
|
||||
|
||||
String ChoiceField::Choice::choiceNameNice(int id) const {
|
||||
@@ -165,14 +165,9 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field)
|
||||
, choice_images_initialized(false)
|
||||
, combine(COMBINE_NORMAL)
|
||||
, alignment(ALIGN_STRETCH)
|
||||
, thumbnails(nullptr)
|
||||
, content_width(0.0), content_height(0.0)
|
||||
{}
|
||||
|
||||
ChoiceStyle::~ChoiceStyle() {
|
||||
delete thumbnails;
|
||||
}
|
||||
|
||||
void ChoiceStyle::initImage() {
|
||||
if (image.isSet() || choice_images.empty()) return;
|
||||
// for, for example:
|
||||
@@ -234,10 +229,9 @@ void ChoiceStyle::checkContentDependencies(Context& ctx, const Dependency& dep)
|
||||
void ChoiceStyle::invalidate() {
|
||||
// TODO : this is also done in update(), once should be enough
|
||||
// Update choice images and thumbnails
|
||||
int end = field().choices->lastId();
|
||||
thumbnails_status.resize(end, THUMB_NOT_MADE);
|
||||
for (int i = 0 ; i < end ; ++i) {
|
||||
if (thumbnails_status[i] == THUMB_OK) thumbnails_status[i] = THUMB_CHANGED;
|
||||
for (auto& thumbnail : thumbnails) {
|
||||
ChoiceThumbnailLock lock(thumbnail.mutex);
|
||||
if (thumbnail.status == THUMB_OK) thumbnail.status = THUMB_CHANGED;
|
||||
}
|
||||
tellListeners(CHANGE_OTHER);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <script/scriptable.hpp>
|
||||
#include <script/image.hpp>
|
||||
#include <wx/image.h>
|
||||
class wxImageList;
|
||||
#include <mutex>
|
||||
|
||||
// ----------------------------------------------------------------------------- : ChoiceField
|
||||
|
||||
@@ -134,12 +134,30 @@ enum ThumbnailStatus
|
||||
, THUMB_CHANGED // there is an image, but it may need to be updated
|
||||
};
|
||||
|
||||
class ChoiceThumbnail {
|
||||
public:
|
||||
ThumbnailStatus status = THUMB_NOT_MADE;
|
||||
wxBitmap bitmap;
|
||||
std::recursive_mutex mutex;
|
||||
};
|
||||
using ChoiceThumbnailLock = std::lock_guard<std::recursive_mutex>;
|
||||
|
||||
// vector of thumbnails without a copy constructor
|
||||
class ChoiceThumbnails : public std::vector<ChoiceThumbnail> {
|
||||
public:
|
||||
ChoiceThumbnails() {}
|
||||
ChoiceThumbnails(ChoiceThumbnails const&) {} // don't copy
|
||||
inline void resize(size_t n) {
|
||||
// rebuilds the vector in one go, doesn't require move or copy constructor
|
||||
std::vector<ChoiceThumbnail>::operator = (std::vector<ChoiceThumbnail>(n));
|
||||
}
|
||||
};
|
||||
|
||||
/// The Style for a ChoiceField
|
||||
class ChoiceStyle : public Style {
|
||||
public:
|
||||
public:
|
||||
ChoiceStyle(const ChoiceFieldP& field);
|
||||
DECLARE_STYLE_TYPE(Choice);
|
||||
~ChoiceStyle();
|
||||
|
||||
ChoicePopupStyle popup_style; ///< Style of popups/menus
|
||||
ChoiceRenderStyle render_style; ///< Style of rendering
|
||||
@@ -149,8 +167,7 @@ class ChoiceStyle : public Style {
|
||||
bool choice_images_initialized;
|
||||
ImageCombine combine; ///< Combining mode for drawing the images
|
||||
Alignment alignment; ///< Alignment of images
|
||||
wxImageList* thumbnails; ///< Thumbnails for the choices
|
||||
vector<ThumbnailStatus> thumbnails_status; ///< Which thumbnails are up to date?
|
||||
ChoiceThumbnails thumbnails; ///< Thumbnails for the choices
|
||||
// information from image rendering
|
||||
double content_width, content_height; ///< Size of the rendered image/text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user