mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Conversion to new ScriptableImage complete, this affected quite a bit, including the evil thumbnail thread;
Added StyleListener, so style changes are only propagated to interested viewers. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@329 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -32,11 +32,13 @@ wxSize CardViewer::DoGetBestSize() const {
|
||||
}
|
||||
|
||||
void CardViewer::redraw(const ValueViewer& v) {
|
||||
if (drawing) return;
|
||||
up_to_date = false;
|
||||
RefreshRect(getRotation().tr(v.boundingBox()), false);
|
||||
}
|
||||
|
||||
void CardViewer::onChange() {
|
||||
if (drawing) return;
|
||||
up_to_date = false;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class CardViewer : public wxControl, public DataViewer {
|
||||
shared_ptr<DC> overdrawDC();
|
||||
|
||||
/// Invalidate and redraw (the area of) a single value viewer
|
||||
void redraw(const ValueViewer&);
|
||||
virtual void redraw(const ValueViewer&);
|
||||
|
||||
/// The rotation to use
|
||||
virtual Rotation getRotation() const;
|
||||
|
||||
@@ -111,7 +111,6 @@ void ThumbnailThread::request(const ThumbnailRequestP& request) {
|
||||
if (request_names.find(request) != request_names.end()) {
|
||||
return;
|
||||
}
|
||||
request_names.insert(request);
|
||||
// Is the image in the cache?
|
||||
String filename = image_cache_dir() + safe_filename(request->cache_name) + _(".png");
|
||||
wxFileName fn(filename);
|
||||
@@ -124,6 +123,7 @@ void ThumbnailThread::request(const ThumbnailRequestP& request) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
request_names.insert(request);
|
||||
// request generation
|
||||
{
|
||||
wxMutexLocker lock(mutex);
|
||||
|
||||
@@ -40,10 +40,9 @@ ChoiceThumbnailRequest::ChoiceThumbnailRequest(ValueViewer* cve, int id, bool fr
|
||||
|
||||
Image ChoiceThumbnailRequest::generate() {
|
||||
ChoiceValueEditor& cve = *(ChoiceValueEditor*)owner;
|
||||
Context& ctx = cve.getSet().getContextForThumbnails(stylesheet);
|
||||
String name = cannocial_name_form(cve.field().choices->choiceName(id));
|
||||
ScriptableImage& img = cve.style().choice_images[name];
|
||||
return img.generate(ctx, *stylesheet, 16, 16, ASPECT_BORDER, true)->image;
|
||||
return img.generate(GeneratedImage::Options(16,16, stylesheet.get(), &cve.getSet(), ASPECT_BORDER, true), false);
|
||||
}
|
||||
|
||||
void ChoiceThumbnailRequest::store(const Image& img) {
|
||||
@@ -79,6 +78,7 @@ void ChoiceThumbnailRequest::store(const Image& img) {
|
||||
} else {
|
||||
il->Replace(id, img);
|
||||
}
|
||||
cve.style().thumbnails_status[id] = THUMB_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,18 +157,15 @@ void DropDownChoiceListBase::generateThumbnailImages() {
|
||||
}
|
||||
int image_count = style().thumbnails->GetImageCount();
|
||||
int end = group->lastId();
|
||||
Context& ctx = cve.viewer.getContext();
|
||||
style().thumbnails_status.resize(end, THUMB_NOT_MADE);
|
||||
for (int i = 0 ; i < end ; ++i) {
|
||||
String name = cannocial_name_form(group->choiceName(i));
|
||||
ScriptableImage& img = style().choice_images[name];
|
||||
bool up_to_date = img.upToDate(ctx, style().thumbnail_age);
|
||||
if (i >= image_count || !up_to_date) {
|
||||
// TODO : handle the case where image i was previously skipped
|
||||
ThumbnailStatus status = style().thumbnails_status[i];
|
||||
if (i >= image_count || status != THUMB_OK) {
|
||||
// request this thumbnail
|
||||
thumbnail_thread.request( new_shared3<ChoiceThumbnailRequest>(&cve, i, up_to_date && !style().invalidated_images) );
|
||||
thumbnail_thread.request( new_shared3<ChoiceThumbnailRequest>(&cve, i, status == THUMB_NOT_MADE) );
|
||||
}
|
||||
}
|
||||
style().thumbnail_age.update();
|
||||
}
|
||||
|
||||
void DropDownChoiceListBase::onIdle(wxIdleEvent& ev) {
|
||||
|
||||
@@ -441,7 +441,8 @@ void TextValueEditor::showCaret() {
|
||||
// it is not 0 for empty text, because TextRenderer handles that case
|
||||
if (cursor.height == 0) {
|
||||
if (style().always_symbol && style().symbol_font.valid()) {
|
||||
RealSize s = style().symbol_font.font->defaultSymbolSize(viewer.getContext(), rot.trS(style().symbol_font.size));
|
||||
style().symbol_font.font->update(viewer.getContext());
|
||||
RealSize s = style().symbol_font.font->defaultSymbolSize(rot.trS(style().symbol_font.size));
|
||||
cursor.height = s.height;
|
||||
} else {
|
||||
cursor.height = v.heightOfLastLine();
|
||||
|
||||
Reference in New Issue
Block a user