X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Flayer_solidcolor.cpp;h=0b520adcf7ed824926acd5c815c5c40804b18c71;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=ca895c9d9d55ab3492335378a765f8cff2d68624;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/layer_solidcolor.cpp b/synfig-core/trunk/src/synfig/layer_solidcolor.cpp index ca895c9..0b520ad 100644 --- a/synfig-core/trunk/src/synfig/layer_solidcolor.cpp +++ b/synfig-core/trunk/src/synfig/layer_solidcolor.cpp @@ -1,20 +1,22 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file layer_solidcolor.cpp -** \brief Template Header +** \brief Implementation of the "Solid Color" layer ** -** $Id: layer_solidcolor.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -44,16 +46,16 @@ using namespace etl; using namespace std; -using namespace sinfg; +using namespace synfig; /* === G L O B A L S ======================================================= */ -SINFG_LAYER_INIT(Layer_SolidColor); -SINFG_LAYER_SET_NAME(Layer_SolidColor,"SolidColor"); -SINFG_LAYER_SET_LOCAL_NAME(Layer_SolidColor,_("Solid Color")); -SINFG_LAYER_SET_CATEGORY(Layer_SolidColor,_("Geometry")); -SINFG_LAYER_SET_VERSION(Layer_SolidColor,"0.1"); -SINFG_LAYER_SET_CVS_ID(Layer_SolidColor,"$Id: layer_solidcolor.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $"); +SYNFIG_LAYER_INIT(Layer_SolidColor); +SYNFIG_LAYER_SET_NAME(Layer_SolidColor,"SolidColor"); // todo: use solid_color +SYNFIG_LAYER_SET_LOCAL_NAME(Layer_SolidColor,N_("Solid Color")); +SYNFIG_LAYER_SET_CATEGORY(Layer_SolidColor,N_("Geometry")); +SYNFIG_LAYER_SET_VERSION(Layer_SolidColor,"0.1"); +SYNFIG_LAYER_SET_CVS_ID(Layer_SolidColor,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -66,12 +68,14 @@ Layer_SolidColor::Layer_SolidColor(): color(Color::black()) { } - + bool Layer_SolidColor::set_param(const String & param, const ValueBase &value) { - IMPORT(color); - + IMPORT_PLUS(color, { if (color.get_a() == 0) { if (converted_blend_) { + set_blend_method(Color::BLEND_ALPHA_OVER); + color.set_a(1); } else transparent_color_ = true; } }); + return Layer_Composite::set_param(param,value); } @@ -82,33 +86,33 @@ Layer_SolidColor::get_param(const String ¶m)const EXPORT_NAME(); EXPORT_VERSION(); - - return Layer_Composite::get_param(param); + + return Layer_Composite::get_param(param); } Layer::Vocab Layer_SolidColor::get_param_vocab()const { Layer::Vocab ret(Layer_Composite::get_param_vocab()); - + ret.push_back(ParamDesc("color") .set_local_name(_("Color")) ); - + return ret; } -sinfg::Layer::Handle -Layer_SolidColor::hit_check(sinfg::Context context, const sinfg::Point &point)const +synfig::Layer::Handle +Layer_SolidColor::hit_check(synfig::Context context, const synfig::Point &point)const { if(get_blend_method()==Color::BLEND_STRAIGHT && get_amount()>=0.5) return const_cast(this); else if(get_blend_method()==Color::BLEND_COMPOSITE && get_amount()*color.get_a()>=0.5) return const_cast(this); - + Layer::Handle layer(context.hit_check(point)); - + return layer?layer:const_cast(this); } @@ -120,7 +124,7 @@ Layer_SolidColor::get_color(Context context, const Point &pos)const else return Color::blend(color,context.get_color(pos),get_amount(),get_blend_method()); } - + bool Layer_SolidColor::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const { @@ -129,7 +133,7 @@ Layer_SolidColor::accelerated_render(Context context,Surface *surface,int qualit // Mark our progress as starting if(cb && !cb->amount_complete(0,1000)) return false; - + surface->set_wh(renddesc.get_w(),renddesc.get_h()); surface->fill(color);