removed background preference, using checkered

This commit is contained in:
Carlo "zED" Caputo 2016-08-07 03:55:09 -03:00
parent 0297063c56
commit f9f7477b04
6 changed files with 26 additions and 18 deletions

View File

@ -261,7 +261,6 @@
<option id="overlay_enabled" type="bool" default="false" />
<option id="overlay_size" type="int" default="5" />
<option id="opacity" type="int" default="255" />
<option id="background" type="app::Color" default="app::Color::fromRgb(180, 180, 180, 220)" />
</section>
<section id="onionskin">
<option id="active" type="bool" default="false" migrate="Onionskin.Enabled" />

View File

@ -11,10 +11,6 @@
<check id="thumb_overlay_enabled" text="Overlay"/>
<label text="Size:" />
<slider min="2" max="10" id="thumb_overlay_size" cell_align="horizontal" width="128" />
<label text="Background:" />
<colorpicker id="thumb_background" expansive="true" cell_hspan="2" />
</grid>
<separator cell_hspan="2" text="Onion Skin:" left="true" horizontal="true" />
<grid columns="2">

View File

@ -33,7 +33,8 @@ namespace app {
DocumentPreferences& docPref = Preferences::instance().document(document);
int opacity = docPref.thumbnails.opacity();
gfx::Color background = color_utils::color_for_ui(docPref.thumbnails.background());
doc::color_t bg1 = color_utils::color_for_image(docPref.bg.color1(), image->pixelFormat());
doc::color_t bg2 = color_utils::color_for_image(docPref.bg.color2(), image->pixelFormat());
gfx::Size image_size = image->size();
@ -51,10 +52,32 @@ namespace app {
}
const doc::Sprite* sprite = document->sprite();
// TODO doc::Image::createCopy() from pre-rendered checkered background
base::UniquePtr<doc::Image> thumb_img(doc::Image::create(
image->pixelFormat(), thumb_size.w, thumb_size.h));
clear_image(thumb_img.get(), background);
double alpha = opacity / 255.0;
uint8_t bg_r[] = { rgba_getr(bg1), rgba_getr(bg2) };
uint8_t bg_g[] = { rgba_getg(bg1), rgba_getg(bg2) };
uint8_t bg_b[] = { rgba_getb(bg1), rgba_getb(bg2) };
uint8_t bg_a[] = { rgba_geta(bg1), rgba_geta(bg2) };
doc::color_t bg[] = {
rgba(bg_r[0], bg_g[0], bg_b[0], (int)(bg_a[0] * alpha)),
rgba(bg_r[1], bg_g[1], bg_b[1], (int)(bg_a[1] * alpha))
};
int block_size = MID(4, thumb_size.w/8, 16);
for (int dst_y = 0; dst_y < thumb_size.h; dst_y++) {
for (int dst_x = 0; dst_x < thumb_size.w; dst_x++) {
thumb_img->putPixel(dst_x, dst_y,
bg[
((dst_x / block_size) % 2) ^
((dst_y / block_size) % 2)
]
);
}
}
base::UniquePtr<doc::Image> scale_img;
const doc::Image* source = image;

View File

@ -63,7 +63,6 @@ ConfigureTimelinePopup::ConfigureTimelinePopup()
m_box->infront()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onPositionChange, this));
m_box->thumbOpacity()->Change.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbOpacityChange, this));
m_box->thumbBackground()->Change.connect(&ConfigureTimelinePopup::onThumbBackgroundChange, this);
m_box->thumbEnabled()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbEnabledChange, this));
m_box->thumbOverlayEnabled()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbOverlayEnabledChange, this));
m_box->thumbOverlaySize()->Change.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbOverlaySizeChange, this));
@ -116,7 +115,6 @@ void ConfigureTimelinePopup::updateWidgetsFromCurrentSettings()
}
m_box->thumbOpacity()->setValue(docPref.thumbnails.opacity());
m_box->thumbBackground()->setColor(docPref.thumbnails.background());
m_box->thumbEnabled()->setSelected(docPref.thumbnails.enabled());
m_box->thumbOverlayEnabled()->setSelected(docPref.thumbnails.overlayEnabled());
m_box->thumbOverlaySize()->setValue(docPref.thumbnails.overlaySize());
@ -196,11 +194,6 @@ void ConfigureTimelinePopup::onThumbOpacityChange()
docPref().thumbnails.opacity(m_box->thumbOpacity()->getValue());
}
void ConfigureTimelinePopup::onThumbBackgroundChange(const app::Color& color)
{
docPref().thumbnails.background(color);
}
void ConfigureTimelinePopup::onThumbEnabledChange()
{
docPref().thumbnails.enabled(m_box->thumbEnabled()->isSelected());

View File

@ -42,7 +42,6 @@ namespace app {
void onPositionChange();
void onThumbOpacityChange();
void onThumbBackgroundChange(const app::Color& color);
void onThumbEnabledChange();
void onThumbOverlayEnabledChange();
void onThumbOverlaySizeChange();

View File

@ -1638,11 +1638,9 @@ void Timeline::drawCelOverlay(ui::Graphics* g)
she::Surface* overlay_surf = thumb::get_cel_thumbnail(cel, overlay_size, cel_image_on_overlay);
gfx::Color background = color_utils::color_for_ui(docPref().thumbnails.background());
gfx::Color border = color_utils::blackandwhite_neg(background);
g->drawRgbaSurface(overlay_surf,
m_thumbnailsOverlayInner.x, m_thumbnailsOverlayInner.y);
g->drawRect(border, m_thumbnailsOverlayOuter);
g->drawRect(gfx::rgba(0,0,0,255), m_thumbnailsOverlayOuter);
overlay_surf->dispose();
}