summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3aa18d8)
raw | patch | inline | side by side (parent: 3aa18d8)
author | joncruz <joncruz@users.sourceforge.net> | |
Sat, 24 May 2008 13:43:22 +0000 (13:43 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sat, 24 May 2008 13:43:22 +0000 (13:43 +0000) |
index 6a6d4010d4ae88fc973265968428e740c64b4f66..3ef24399ef0534df337fa5a88f33b3567be62303 100644 (file)
<dependency type="executable" location="extensions">inkex.py</dependency>\r
<param name="tab" type="notebook">\r
<page name="common" _gui-text="Model File">\r
- <param name="obj" type="optiongroup" _gui-text="Object:">\r
+ <param name="obj" type="optiongroup" appearance="minimal" _gui-text="Object:">\r
<_option value="cube">Cube</_option>\r
<_option value="t_cube">Truncated Cube</_option>\r
<_option value="sn_cube">Snub Cube</_option>\r
<_option value="from_file">Load From File</_option>\r
</param>\r
<param name="spec_file" type="string" _gui-text="Filename:">great_rhombicuboct.obj</param>\r
- <param name="type" type="optiongroup" _gui-text="Object Type">\r
+ <param name="type" type="optiongroup" appearance="minimal" _gui-text="Object Type">\r
<_option value="face">Face-Specified</_option>\r
<_option value="edge">Edge-Specified</_option></param>\r
<param name="cw_wound" type="boolean" _gui-text="Clockwise Wound Object">0</param>\r
</page>\r
<page name="view" _gui-text="View">\r
- <param name="r1_ax" type="optiongroup" _gui-text="Rotate Around:">\r
+ <param name="r1_ax" type="optiongroup" appearance="minimal" _gui-text="Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="r1_ang" type="float" min="-360" max="360" _gui-text="Rotation / Degrees">0</param>\r
- <param name="r2_ax" type="optiongroup" _gui-text="Then Rotate Around:">\r
+ <param name="r2_ax" type="optiongroup" appearance="minimal" _gui-text="Then Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="r2_ang" type="float" min="-360" max="360" _gui-text="Rotation / Degrees">0</param>\r
- <param name="r3_ax" type="optiongroup" _gui-text="Then Rotate Around:">\r
+ <param name="r3_ax" type="optiongroup" appearance="minimal" _gui-text="Then Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="r3_ang" type="float" min="-360" max="360" _gui-text="Rotation / Degrees">0</param>\r
- <param name="r4_ax" type="optiongroup" _gui-text="Rotate Around:">\r
+ <param name="r4_ax" type="optiongroup" appearance="minimal" _gui-text="Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="r4_ang" type="float" min="-360" max="360" _gui-text="Rotation / Degrees">0</param>\r
- <param name="r5_ax" type="optiongroup" _gui-text="Then Rotate Around:">\r
+ <param name="r5_ax" type="optiongroup" appearance="minimal" _gui-text="Then Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="r5_ang" type="float" min="-360" max="360" _gui-text="Rotation / Degrees">0</param>\r
- <param name="r6_ax" type="optiongroup" _gui-text="Then Rotate Around:">\r
+ <param name="r6_ax" type="optiongroup" appearance="minimal" _gui-text="Then Rotate Around:">\r
<_option value="x">X-Axis</_option>\r
<_option value="y">Y-Axis</_option>\r
<_option value="z">Z-Axis</_option></param>\r
<param name="lv_x" type="float" min="-100" max="100" _gui-text="Light x-Position">1</param>\r
<param name="lv_y" type="float" min="-100" max="100" _gui-text="Light y-Position">1</param>\r
<param name="lv_z" type="float" min="-100" max="100" _gui-text="Light z-Position">-2</param>\r
- <param name="show" type="optiongroup" _gui-text="Show:">\r
+ <param name="show" type="optiongroup" appearance="minimal" _gui-text="Show:">\r
<_option value="vtx">Vertices</_option>\r
<_option value="edg">Edges</_option>\r
<_option value="fce">Faces</_option></param>\r
<param name="back" type="boolean" _gui-text="Draw Back-Facing Polygons">0</param>\r
- <param name="z_sort" type="optiongroup" _gui-text="Z-Sort Faces By:">\r
+ <param name="z_sort" type="optiongroup" appearance="minimal" _gui-text="Z-Sort Faces By:">\r
<_option value="max">Maximum</_option>\r
<_option value="min">Minimum</_option>\r
<_option value="mean">Mean</_option></param>\r
index b356c297e9c3a75696fbb617024ca097b1e8daf6..6d1a1570c2f52a406000e222c9b993454c039ee4 100644 (file)
@@ -103,6 +103,7 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
}
/* else stays false */
}
+ const gchar* appearance = in_repr->attribute("appearance");
/* In this case we just don't have enough information */
if (name == NULL || type == NULL) {
@@ -140,7 +141,11 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
} else if (!strcmp(type, "notebook")) {
param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
} else if (!strcmp(type, "optiongroup")) {
- param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+ if (appearance && !strcmp(appearance, "minimal")) {
+ param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::MINIMAL);
+ } else {
+ param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::FULL);
+ }
} else if (!strcmp(type, "color")) {
param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
}
index ba96486189d79d4176c9578eb526e05f3af501b7..76c3506af0fbf94400341b9537ed84cc87c6db26 100644 (file)
* Johan Engelen <johan@shouraizou.nl>
*
* Copyright (C) 2006-2007 Johan Engelen
+ * Copyright (C) 2008 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gtkmm/box.h>
+#include <gtkmm/comboboxtext.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/radiobuttongroup.h>
#include <gtkmm/tooltips.h>
Glib::ustring * guitext;
};
-ParamRadioButton::ParamRadioButton (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ParamRadioButton::ParamRadioButton (const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode) :
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(0),
+ _mode(mode),
+ choices(0)
{
- choices = NULL;
- _value = NULL;
-
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
if (xml != NULL) {
@@ -79,14 +89,14 @@ ParamRadioButton::ParamRadioButton (const gchar * name, const gchar * guitext, c
// don't translate when 'option' but do translate when '_option'
newguitext = new Glib::ustring( !strcmp(chname, "_option") ? _(contents) : contents );
else
- continue;
-
+ continue;
+
const char * val = child_repr->attribute("value");
if (val != NULL)
newvalue = new Glib::ustring(val);
else
newvalue = new Glib::ustring(contents);
-
+
if ( (newguitext) && (newvalue) ) { // logical error if this is not true here
choices = g_slist_append( choices, new optionentry(newvalue, newguitext) );
}
}
+class ComboWdg : public Gtk::ComboBoxText {
+public:
+ ComboWdg(ParamRadioButton* base, SPDocument * doc, Inkscape::XML::Node * node) :
+ Gtk::ComboBoxText(),
+ base(base),
+ doc(doc),
+ node(node)
+ {
+ }
+ virtual ~ComboWdg() {}
+
+protected:
+ ParamRadioButton* base;
+ SPDocument* doc;
+ Inkscape::XML::Node* node;
+
+ virtual void on_changed() {
+ if ( base ) {
+ base->set(get_active_text().c_str(), doc, node);
+ }
+ }
+};
/**
\brief Creates a combobox widget for an enumeration parameter
Gtk::Widget *
ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) return NULL;
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0));
@@ -235,28 +267,48 @@ ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc
label->show();
hbox->pack_start(*label, false, false);
+ Gtk::ComboBoxText* cbt = 0;
+ bool comboSet = false;
+ if (_mode == MINIMAL) {
+ cbt = Gtk::manage(new ComboWdg(this, doc, node));
+ cbt->show();
+ vbox->pack_start(*cbt, false, false);
+ }
+
// add choice strings as radiobuttons
// and select last selected option (_value)
- bool first = true;
- ParamRadioButtonWdg * radio;
Gtk::RadioButtonGroup group;
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
optionentry * entr = reinterpret_cast<optionentry *>(list->data);
Glib::ustring * text = entr->guitext;
- if (first) {
- radio = Gtk::manage(new ParamRadioButtonWdg(*text, this, doc, node, changeSignal));
- group = radio->get_group();
- first = false;
- } else {
- radio = Gtk::manage(new ParamRadioButtonWdg(group, *text, this, doc, node, changeSignal));
- }
- radio->show();
- vbox->pack_start(*radio, true, true);
- if (!entr->value->compare(_value)) {
- radio->set_active();
+ switch ( _mode ) {
+ case MINIMAL:
+ {
+ cbt->append_text(*text);
+ if (!entr->value->compare(_value)) {
+ cbt->set_active_text(*text);
+ comboSet = true;
+ }
+ }
+ break;
+ case COMPACT:
+ case FULL:
+ {
+ ParamRadioButtonWdg * radio = Gtk::manage(new ParamRadioButtonWdg(group, *text, this, doc, node, changeSignal));
+ radio->show();
+ vbox->pack_start(*radio, true, true);
+ if (!entr->value->compare(_value)) {
+ radio->set_active();
+ }
+ }
+ break;
}
}
+ if ( (_mode == MINIMAL) && !comboSet) {
+ cbt->set_active(0);
+ }
+
vbox->show();
hbox->pack_end(*vbox, false, false);
hbox->show();
@@ -269,3 +321,13 @@ ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc
} /* namespace Extension */
} /* namespace Inkscape */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
index 4bf596e4f1f83d966ca2c316775b26d028aabe96..ea8440de2df36a663f6b8a82c22359c6ce8472e7 100644 (file)
// \brief A class to represent a radiobutton parameter of an extension
class ParamRadioButton : public Parameter {
+public:
+ enum AppearanceMode {
+ FULL, COMPACT, MINIMAL
+ };
+
+ ParamRadioButton(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
+ virtual ~ParamRadioButton(void);
+ Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+ void string (std::string &string);
+
+ const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+
private:
/** \brief Internal value. This should point to a string that has
been allocated in memory. And should be free'd.
It is the value of the current selected string */
gchar * _value;
+ AppearanceMode _mode;
GSList * choices; /**< A table to store the choice strings */
-public:
- ParamRadioButton(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
- virtual ~ParamRadioButton(void);
- Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
-
- const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
- const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
}; /* class ParamRadioButton */