mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 13:20:28 +00:00
Add a checkbox tick to the selected preset palette (fix #1327)
This commit is contained in:
parent
4c2a283bd7
commit
9b1f0bf33c
@ -10,14 +10,19 @@
|
||||
|
||||
#include "app/ui/palettes_listbox.h"
|
||||
|
||||
#include "app/document.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "app/res/palette_resource.h"
|
||||
#include "app/res/palettes_loader_delegate.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/icon_button.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/launcher.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "she/surface.h"
|
||||
#include "ui/graphics.h"
|
||||
#include "ui/listitem.h"
|
||||
@ -128,9 +133,22 @@ void PalettesListBox::onResourceChange(Resource* resource)
|
||||
PalChange(palette);
|
||||
}
|
||||
|
||||
void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Resource* resource)
|
||||
void PalettesListBox::onPaintResource(Graphics* g, gfx::Rect& bounds, Resource* resource)
|
||||
{
|
||||
doc::Palette* palette = static_cast<PaletteResource*>(resource)->palette();
|
||||
auto tick = SkinTheme::instance()->parts.checkSelected()->bitmap(0);
|
||||
|
||||
// Draw tick (to say "this palette matches the active sprite
|
||||
// palette").
|
||||
auto view = UIContext::instance()->activeView();
|
||||
if (view && view->document()) {
|
||||
auto docPal = view->document()->sprite()->palette(view->editor()->frame());
|
||||
if (docPal && *docPal == *palette)
|
||||
g->drawRgbaSurface(tick, bounds.x, bounds.y+bounds.h/2-tick->height()/2);
|
||||
}
|
||||
|
||||
bounds.x += tick->width();
|
||||
bounds.w -= tick->width();
|
||||
|
||||
gfx::Rect box(
|
||||
bounds.x, bounds.y+bounds.h-6*guiscale(),
|
||||
|
@ -28,7 +28,7 @@ namespace app {
|
||||
protected:
|
||||
virtual ResourceListItem* onCreateResourceItem(Resource* resource) override;
|
||||
virtual void onResourceChange(Resource* resource) override;
|
||||
virtual void onPaintResource(ui::Graphics* g, const gfx::Rect& bounds, Resource* resource) override;
|
||||
virtual void onPaintResource(ui::Graphics* g, gfx::Rect& bounds, Resource* resource) override;
|
||||
virtual void onResourceSizeHint(Resource* resource, gfx::Size& size) override;
|
||||
|
||||
ui::TooltipManager m_tooltips;
|
||||
|
@ -67,7 +67,7 @@ void ResourceListItem::onPaint(PaintEvent& ev)
|
||||
|
||||
g->drawString(text(), fgcolor, gfx::ColorNone,
|
||||
gfx::Point(
|
||||
bounds.x + guiscale()*2,
|
||||
bounds.x + 2*guiscale(),
|
||||
bounds.y + bounds.h/2 - g->measureUIString(text()).h/2));
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ Resource* ResourcesListBox::selectedResource()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ResourcesListBox::paintResource(Graphics* g, const gfx::Rect& bounds, Resource* resource)
|
||||
void ResourcesListBox::paintResource(Graphics* g, gfx::Rect& bounds, Resource* resource)
|
||||
{
|
||||
onPaintResource(g, bounds, resource);
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ class ResourceListItem : public ui::ListItem {
|
||||
|
||||
// abstract
|
||||
virtual void onResourceChange(Resource* resource) = 0;
|
||||
virtual void onPaintResource(ui::Graphics* g, const gfx::Rect& bounds, Resource* resource) = 0;
|
||||
virtual void onPaintResource(ui::Graphics* g, gfx::Rect& bounds, Resource* resource) = 0;
|
||||
virtual void onResourceSizeHint(Resource* resource, gfx::Size& size) = 0;
|
||||
|
||||
private:
|
||||
void paintResource(ui::Graphics* g, const gfx::Rect& bounds, Resource* resource);
|
||||
void paintResource(ui::Graphics* g, gfx::Rect& bounds, Resource* resource);
|
||||
gfx::Size resourceSizeHint(Resource* resource);
|
||||
|
||||
void onTick();
|
||||
|
Loading…
x
Reference in New Issue
Block a user