grid-arrange-tab.cpp revision d36f9108475df68e0366d50193c333aed0b72c49
/*
* A simple dialog for creating grid type arrangements of selected objects
*
* Authors:
* Bob Jamison ( based off trace dialog)
* John Cliff
* Other dudes from The Inkscape Organization
* Abhishek Sharma
* Declara Denis
*
* Copyright (C) 2004 Bob Jamison
* Copyright (C) 2004 John Cliff
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
//#define DEBUG_GRID_ARRANGE 1
#include "ui/dialog/grid-arrange-tab.h"
#if WITH_GTKMM_3_0
#else
#endif
#include "verbs.h"
#include "preferences.h"
#include "inkscape.h"
#include "selection.h"
#include "document.h"
#include "document-undo.h"
#include "sp-item.h"
#include "desktop.h"
//#include "sp-item-transform.h" FIXME
/*
* Sort items by their x co-ordinates, taking account of y (keeps rows intact)
*
* <0 *elem1 goes before *elem2
* 0 *elem1 == *elem2
* >0 *elem1 goes after *elem2
*/
{
using Geom::X;
using Geom::Y;
if ( !a || !b ) {
// FIXME?
return false;
}
double const a_height = a->dimensions()[Y];
double const b_height = b->dimensions()[Y];
bool a_in_b_vert = false;
a_in_b_vert = true;
a_in_b_vert = true;
a_in_b_vert = true;
} else {
a_in_b_vert = false;
}
if (!a_in_b_vert) {
return true;
}
return false;
}
return true;
}
return false;
}
/*
* Sort items by their y co-ordinates.
*/
{
if ( !a || !b ) {
// FIXME?
return false;
}
return false;
}
return true;
}
return false;
}
namespace Inkscape {
namespace UI {
namespace Dialog {
//#########################################################################
//## E V E N T S
//#########################################################################
/*
*
* This arranges the selection in a grid pattern.
*
*/
void GridArrangeTab::arrange()
{
double total_col_width,total_row_height;
col_width = 0;
row_height = 0;
// check for correct numbers in the row- and col-spinners
// set padding to manual values
width = 0;
for (a=0;a<NoOfCols; a++){
}
height = 0;
for (a=0;a<NoOfRows; a++){
}
grid_left = 99999;
grid_top = 99999;
if (!b) {
continue;
}
}
}
}
if (height > row_height) {
row_height = height;
}
}
// require the sorting done before we can calculate row heights etc.
// Calculate individual Row and Column sizes if necessary
cnt=0;
if (b) {
}
}
}
cnt++;
}
/// Make sure the top and left of the grid dont move by compensating for align values.
if (RowHeightButton.get_active()){
}
if (ColumnWidthButton.get_active()){
}
#ifdef DEBUG_GRID_ARRANGE
#endif
// Calculate total widths and heights, allowing for columns and rows non uniformly sized.
if (ColumnWidthButton.get_active()){
col_widths.clear();
for (a=0;a<NoOfCols; a++){
}
} else {
for (a = 0; a < (int)col_widths.size(); a++)
{
total_col_width += col_widths[a] ;
}
}
if (RowHeightButton.get_active()){
row_heights.clear();
for (a=0;a<NoOfRows; a++){
}
} else {
for (a = 0; a < (int)row_heights.size(); a++)
{
total_row_height += row_heights[a] ;
}
}
// Fit to bbox, calculate padding between rows accordingly.
#ifdef DEBUG_GRID_ARRANGE
g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y));
#endif
}
/*
Horizontal align - Left = 0
Centre = 1
Right = 2
Vertical align - Top = 0
Middle = 1
Bottom = 2
X position is calculated by taking the grids left co-ord, adding the distance to the column,
then adding 1/2 the spacing multiplied by the align variable above,
Y position likewise, takes the top of the grid, adds the y to the current row then adds the padding in to align it.
*/
// Calculate row and column x and y coords required to allow for columns and rows which are non uniformly sized.
for (a=0;a<NoOfCols; a++){
}
for (a=0;a<NoOfRows; a++){
}
cnt=0;
col_cnt = 0;
col_cnt++;
}
if (b) {
} else {
}
// signs are inverted between x and y due to y inversion
cnt +=1;
}
}
_("Arrange in a grid"));
}
//#########################################################################
//## E V E N T S
//#########################################################################
/**
* changed value in # of columns spinbox.
*/
{
// quit if run by the attr_changed listener
if (updating) {
return;
}
// in turn, prevent listener from responding
updating = true;
updating=false;
}
/**
* changed value in # of rows spinbox.
*/
{
// quit if run by the attr_changed listener
if (updating) {
return;
}
// in turn, prevent listener from responding
updating = true;
updating=false;
}
/**
* changed value in x padding spinbox.
*/
{
}
/**
* changed value in y padding spinbox.
*/
{
}
/**
*/
{
if (RowHeightButton.get_active()) {
} else {
}
}
/**
*/
{
if (ColumnWidthButton.get_active()) {
} else {
}
}
/**
* changed value in columns spinbox.
*/
{
// quit if run by the attr_changed listener
if (updating) {
return;
}
// in turn, prevent listener from responding
updating = true;
updating=false;
}
/**
* changed value in rows spinbox.
*/
{
// quit if run by the attr_changed listener
if (updating) {
return;
}
// in turn, prevent listener from responding
updating = true;
updating=false;
}
/**
* changed Radio button in Spacing group.
*/
void GridArrangeTab::Spacing_button_changed()
{
if (SpaceManualRadioButton.get_active()) {
} else {
}
}
/**
* changed Anchor selection widget.
*/
void GridArrangeTab::Align_changed()
{
}
/**
* Desktop selection changed
*/
void GridArrangeTab::updateSelection()
{
// quit if run by the attr_changed listener
if (updating) {
return;
}
// in turn, prevent listener from responding
updating = true;
// Update the number of rows assuming number of columns wanted remains same.
// if the selection has less than the number set for one row, reduce it appropriately
}
} else {
}
}
updating = false;
}
//#########################################################################
//## C O N S T R U C T O R / D E S T R U C T O R
//#########################################################################
/**
* Constructor
*/
XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns", &PaddingUnitMenu),
YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows", &PaddingUnitMenu),
#if WITH_GTKMM_3_0
#else
#endif
{
// bool used by spin button callbacks to stop loops where they change each other.
updating = false;
// could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!)
{
// Selection Change signal
INKSCAPE.signal_selection_changed.connect(sigc::hide<0>(sigc::mem_fun(*this, &GridArrangeTab::updateSelection)));
}
#define MARGIN 2
//##Set up the panel
int selcount = 1;
}
/*#### Number of Rows ####*/
#ifdef DEBUG_GRID_ARRANGE
#endif
NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed));
RowHeightButton.set_use_underline(true);
if (AutoRow>0)
AutoRowSize=true;
else
AutoRowSize=false;
RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it"));
RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed));
/*#### Label for X ####*/
/*#### Number of columns ####*/
NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed));
if (AutoCol>0)
AutoColSize=true;
else
AutoColSize=false;
ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it"));
ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed));
// Anchor selection widget
AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed));
{
/*#### Radio buttons to control spacing manually or to fit selection bbox ####*/
SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed));
SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed));
}
{
/*#### Padding ####*/
YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed));
XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed));
}
#if WITH_GTKMM_3_0
#else
#endif
if (SpacingType>0) {
ManualSpacing=true;
} else {
ManualSpacing=false;
}
//## The OK button FIXME
/*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY);
TileOkButton->set_use_underline(true);
TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/
}
} //namespace Dialog
} //namespace UI
} //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:fileencoding=utf-8:textwidth=99 :