From: cilix42 Date: Mon, 20 Aug 2007 12:20:43 +0000 (+0000) Subject: Avoid 'flashing' between front and rear face during initial dragging process of 3D... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bfbe1a13d86c5f5796f307e583677e5150f9a530;p=inkscape.git Avoid 'flashing' between front and rear face during initial dragging process of 3D boxes --- diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 3b45abdb2..8ef5f5960 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -362,8 +362,11 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded) { /* once shift is pressed, set bc->extruded (no need to create further faces; - all of them are already created in sp_3dbox_init) */ + all of them are already created in sp_3dbox_init); since we made the rear face + invisible in the beginning to avoid "flashing", we must set its correct style now */ bc->extruded = true; + g_assert (bc->item); + SP_3DBOX (bc->item)->faces[5]->set_style (NULL, true); } if (!bc->extruded) { @@ -585,6 +588,8 @@ static void sp_3dbox_drag(SP3DBoxContext &bc, guint state) for (int i = 0; i < 6; ++i) { SP_3DBOX(bc.item)->faces[i]->hook_path_to_3dbox(); } + // make rear face invisible in the beginning to avoid "flashing" + SP_3DBOX (bc.item)->faces[5]->set_style (NULL, false); bc.item->updateRepr(); sp_3dbox_set_z_orders (SP_3DBOX (bc.item)); diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp index 9a6ca2ef2..de52031da 100644 --- a/src/box3d-face.cpp +++ b/src/box3d-face.cpp @@ -177,16 +177,36 @@ void Box3DFace::hook_path_to_3dbox(SPPath * existing_path) return; } - SPDesktop *desktop = inkscape_active_desktop(); + /* create new path for face */ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(SP_OBJECT(parent_box3d))); - /* apply style */ - bool use_current = prefs_get_int_attribute("tools.shapes.3dbox", "usecurrent", 0); Inkscape::XML::Node *repr_face = xml_doc->createElement("svg:path"); repr_face->setAttribute("inkscape:box3dface", this->axes_string()); + this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face)); + Inkscape::GC::release(repr_face); + + /* set the correct style */ + this->set_style (repr_face); +} + +void Box3DFace::set_style(Inkscape::XML::Node *repr_face, bool extruded) +{ + if (repr_face == NULL) { + repr_face = SP_OBJECT_REPR (this->path); + } - gchar *descr = g_strconcat ("desktop.", axes_string(), NULL); + if (!extruded && !strcmp (axes_string (), "XYrear")) { + // to avoid "flashing" during the initial dragging process, we make the rear face invisible in this case + repr_face->setAttribute("style", "fill:none"); + return; + } + + gchar *descr = g_strconcat ("desktop.", axes_string (), NULL); const gchar * cur_style = prefs_get_string_attribute(descr, "style"); + g_free (descr); + + SPDesktop *desktop = inkscape_active_desktop(); + bool use_current = prefs_get_int_attribute("tools.shapes.3dbox", "usecurrent", 0); if (use_current && cur_style !=NULL) { /* use last used style */ repr_face->setAttribute("style", cur_style); @@ -196,9 +216,6 @@ void Box3DFace::hook_path_to_3dbox(SPPath * existing_path) g_string_printf (pstring, "tools.shapes.3dbox.%s", axes_string()); sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false); } - g_free (descr); - this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face)); - Inkscape::GC::release(repr_face); } /** diff --git a/src/box3d-face.h b/src/box3d-face.h index d3d83e702..091a8108b 100644 --- a/src/box3d-face.h +++ b/src/box3d-face.h @@ -43,6 +43,7 @@ public: //void set_face (NR::Point const A, NR::Point const C, Box3D::Axis const dir1, Box3D::Axis const dir2); void hook_path_to_3dbox(SPPath * existing_path = NULL); + void set_style(Inkscape::XML::Node *repr_face = NULL, bool extruded = true); void set_path_repr(); void set_curve(); inline void lower_to_bottom() { SP_ITEM (path)->lowerToBottom(); }