X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_gradient.cpp;h=124658b1ef544ed6586f8ad367be64ddd5ecfb89;hb=c3ad95144d148602f672e95ddda1f18fc35502f8;hp=7759a240ca3ac76a9e114f2bce54b0b6b4fa259d;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_gradient.cpp b/synfig-studio/trunk/src/gtkmm/state_gradient.cpp index 7759a24..124658b 100644 --- a/synfig-studio/trunk/src/gtkmm/state_gradient.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_gradient.cpp @@ -2,19 +2,20 @@ /*! \file state_gradient.cpp ** \brief Template File ** -** $Id: state_gradient.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** 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 */ /* ========================================================================= */ @@ -79,31 +80,31 @@ class studio::StateGradient_Context : public sigc::trackable { etl::handle canvas_view_; CanvasView::IsWorking is_working; - + Duckmatic::Push duckmatic_push; - + synfigapp::Settings& settings; Point point_holder; - + etl::handle point2_duck; void refresh_ducks(); bool prev_workarea_layer_status_; - + Gtk::Table options_table; Gtk::Entry entry_id; Widget_Enum enum_type; Widget_Enum enum_blend; - + public: synfig::String get_id()const { return entry_id.get_text(); } void set_id(const synfig::String& x) { return entry_id.set_text(x); } int get_type()const { return enum_type.get_value(); } void set_type(int x) { return enum_type.set_value(x); } - + int get_blend()const { return enum_blend.get_value(); } void set_blend(int x) { return enum_blend.set_value(x); } @@ -124,16 +125,16 @@ public: etl::handle get_canvas_interface()const{return canvas_view_->canvas_interface();} synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();} WorkArea * get_work_area()const{return canvas_view_->get_work_area();} - + //void on_user_click(synfig::Point point); void load_settings(); void save_settings(); void reset(); void increment_id(); - + void make_gradient(const Point& p1, const Point& p2); bool no_egress_on_selection_change; - Smach::event_result event_layer_selection_changed_handler(const Smach::event& x) + Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(!no_egress_on_selection_change) throw Smach::egress_exception(); @@ -156,7 +157,7 @@ StateGradient::StateGradient(): insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateGradient_Context::event_mouse_click_handler)); insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateGradient_Context::event_mouse_click_handler)); insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateGradient_Context::event_refresh_tool_options)); -} +} StateGradient::~StateGradient() { @@ -164,19 +165,19 @@ StateGradient::~StateGradient() void StateGradient_Context::load_settings() -{ +{ String value; if(settings.get_value("gradient.id",value)) set_id(value); else set_id("Gradient"); - + if(settings.get_value("gradient.type",value)) set_type(atoi(value.c_str())); else set_type(GRADIENT_INTERPOLATION_LINEAR); - + if(settings.get_value("gradient.blend",value)) set_blend(atoi(value.c_str())); else @@ -185,7 +186,7 @@ StateGradient_Context::load_settings() void StateGradient_Context::save_settings() -{ +{ settings.set_value("gradient.id",get_id().c_str()); settings.set_value("gradient.type",strprintf("%d",get_type())); settings.set_value("gradient.blend",strprintf("%d",get_blend())); @@ -203,10 +204,10 @@ StateGradient_Context::increment_id() String id(get_id()); int number=1; int digits=0; - + if(id.empty()) id="Gradient"; - + // If there is a number // already at the end of the // id, then remove it. @@ -214,11 +215,11 @@ StateGradient_Context::increment_id() { // figure out how many digits it is for(digits=0;(int)id.size()-1>=digits && id[id.size()-1-digits]<='9' && id[id.size()-1-digits]>='0';digits++)while(false); - + String str_number; str_number=String(id,id.size()-digits,id.size()); id=String(id,0,id.size()-digits); - + number=atoi(str_number.c_str()); } else @@ -226,15 +227,15 @@ StateGradient_Context::increment_id() number=1; digits=3; } - + number++; - + // Add the number back onto the id { const String format(strprintf("%%0%dd",digits)); id+=strprintf(format.c_str(),number); } - + // Set the ID set_id(id); } @@ -249,7 +250,7 @@ StateGradient_Context::StateGradient_Context(CanvasView* canvas_view): { no_egress_on_selection_change=false; // Set up the tool options dialog - ///options_table.attach(*manage(new Gtk::Label(_("Gradient Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + ///options_table.attach(*manage(new Gtk::Label(_("Gradient Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); options_table.attach(entry_id, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); enum_type.set_param_desc(ParamDesc("type") @@ -260,11 +261,11 @@ StateGradient_Context::StateGradient_Context(CanvasView* canvas_view): .add_enum_value(GRADIENT_RADIAL,"radial",_("Radial")) .add_enum_value(GRADIENT_CONICAL,"conical",_("Conical")) .add_enum_value(GRADIENT_SPIRAL,"spiral",_("Spiral"))); - + enum_blend.set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method") .set_local_name(_("Blend Method")) .set_description(_("The blend method the gradient will use"))); - + load_settings(); options_table.attach(enum_type, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); @@ -279,21 +280,21 @@ StateGradient_Context::StateGradient_Context(CanvasView* canvas_view): get_work_area()->allow_layer_clicks=false; get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); - + // clear out the ducks get_work_area()->clear_ducks(); - + // Refresh the work area get_work_area()->queue_draw(); - + get_work_area()->refresh_cursor(); - + // Hide the tables if they are showing get_canvas_view()->hide_tables(); - - // Hide the time bar - //get_canvas_view()->hide_timebar(); - + + // Disable the time bar + //get_canvas_view()->set_sensitive_timebar(false); + // Connect a signal //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateGradient_Context::on_user_click)); @@ -310,7 +311,7 @@ StateGradient_Context::refresh_tool_options() } Smach::event_result -StateGradient_Context::event_refresh_tool_options(const Smach::event& x) +StateGradient_Context::event_refresh_tool_options(const Smach::event& /*x*/) { refresh_tool_options(); return Smach::RESULT_ACCEPT; @@ -327,13 +328,12 @@ StateGradient_Context::~StateGradient_Context() App::dialog_tool_options->clear(); - // Show the time bar - if(get_canvas_view()->get_canvas()->rend_desc().get_time_start()!=get_canvas_view()->get_canvas()->rend_desc().get_time_end()) - get_canvas_view()->show_timebar(); + // Enable the time bar + //get_canvas_view()->set_sensitive_timebar(true); // Bring back the tables if they were out before //if(prev_table_status)get_canvas_view()->show_tables(); - + // Refresh the work area get_work_area()->queue_draw(); @@ -345,13 +345,13 @@ StateGradient_Context::~StateGradient_Context() } Smach::event_result -StateGradient_Context::event_stop_handler(const Smach::event& x) +StateGradient_Context::event_stop_handler(const Smach::event& /*x*/) { throw Smach::egress_exception(); } Smach::event_result -StateGradient_Context::event_refresh_handler(const Smach::event& x) +StateGradient_Context::event_refresh_handler(const Smach::event& /*x*/) { refresh_ducks(); return Smach::RESULT_ACCEPT; @@ -364,10 +364,10 @@ StateGradient_Context::make_gradient(const Point& _p1, const Point& _p2) synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL); Layer::Handle layer; - + Canvas::Handle canvas(get_canvas_view()->get_canvas()); int depth(0); - + // we are temporarily using the layer to hold something layer=get_canvas_view()->get_selection_manager()->get_selected_layer(); if(layer) @@ -382,7 +382,7 @@ StateGradient_Context::make_gradient(const Point& _p1, const Point& _p2) switch(get_type()) { case GRADIENT_INTERPOLATION_LINEAR: - + layer=get_canvas_interface()->add_layer_to("linear_gradient",canvas,depth); layer->set_param("p1",p1); get_canvas_interface()->signal_layer_param_changed()(layer,"p1"); @@ -422,13 +422,13 @@ StateGradient_Context::make_gradient(const Point& _p1, const Point& _p2) default: return; } - + layer->set_param("blend_method",get_blend()); get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method"); - + layer->set_description(get_id()); get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description()); - + no_egress_on_selection_change=true; get_canvas_interface()->get_selection_manager()->clear_selected_layers(); get_canvas_interface()->get_selection_manager()->set_selected_layer(layer); @@ -442,7 +442,7 @@ Smach::event_result StateGradient_Context::event_mouse_click_handler(const Smach::event& x) { const EventMouse& event(*reinterpret_cast(&x)); - + if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT) { point_holder=get_work_area()->snap_point_to_grid(event.pos); @@ -456,7 +456,7 @@ StateGradient_Context::event_mouse_click_handler(const Smach::event& x) point2_duck->set_point(point_holder); point2_duck->set_name("p2"); point2_duck->set_type(Duck::TYPE_POSITION); - get_work_area()->add_duck(point2_duck); + get_work_area()->add_duck(point2_duck); handle bezier(new Duckmatic::Bezier()); bezier->p1=bezier->c1=duck; @@ -469,7 +469,7 @@ StateGradient_Context::event_mouse_click_handler(const Smach::event& x) if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT) { point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos)); - get_work_area()->queue_draw(); + get_work_area()->queue_draw(); return Smach::RESULT_ACCEPT; } @@ -488,5 +488,5 @@ void StateGradient_Context::refresh_ducks() { get_work_area()->clear_ducks(); - get_work_area()->queue_draw(); + get_work_area()->queue_draw(); }