[glom] Print Layout: Cache the selected item.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Print Layout: Cache the selected item.
- Date: Sun, 7 Aug 2011 07:14:19 +0000 (UTC)
commit cd70cae1baa83903e17e94b94e1298595e04900c
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Aug 6 14:15:19 2011 +0200
Print Layout: Cache the selected item.
* glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
Store the selected item, when it changes, instead of repeatedly
requesting it, which requires iteration.
ChangeLog | 8 +++
.../print_layouts/window_print_layout_edit.cc | 49 +++++++-------------
.../print_layouts/window_print_layout_edit.h | 5 ++
3 files changed, 30 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index faba16b..608b675 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-08-06 Murray Cumming <murrayc murrayc com>
+ Print Layout: Cache the selected item.
+
+ * glom/mode_design/print_layouts/window_print_layout_edit.[h|cc]:
+ Store the selected item, when it changes, instead of repeatedly
+ requesting it, which requires iteration.
+
+2011-08-06 Murray Cumming <murrayc murrayc com>
+
Print Layout: Allow editing of positions and size numerically,
* ui/developer/window_print_layout_edit.glade: Add a row of SpinButtons
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index 8d12363..66dd309 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -990,80 +990,65 @@ void Window_PrintLayout_Edit::on_canvas_selection_changed()
//TODO: Let the user resize groups of items.
const bool enable = (items.size() == 1);
m_box_item_position->set_sensitive(enable);
+
+ if(enable)
+ m_layout_item_selected = items[0];
+ else
+ m_layout_item_selected.reset();
}
void Window_PrintLayout_Edit::on_spinbutton_x()
{
- Canvas_PrintLayout::type_vec_items items = m_canvas.get_selected_items();
- if(items.empty())
- return;
-
- Glib::RefPtr<CanvasLayoutItem> item = items[0];
- if(!item)
+ if(!m_layout_item_selected)
return;
double x = 0;
double y = 0;
- item->get_xy(x, y);
+ m_layout_item_selected->get_xy(x, y);
- item->set_xy(
+ m_layout_item_selected->set_xy(
m_spinbutton_x->get_value(),
y);
}
void Window_PrintLayout_Edit::on_spinbutton_y()
{
- Canvas_PrintLayout::type_vec_items items = m_canvas.get_selected_items();
- if(items.empty())
- return;
-
- Glib::RefPtr<CanvasLayoutItem> item = items[0];
- if(!item)
+ if(!m_layout_item_selected)
return;
double x = 0;
double y = 0;
- item->get_xy(x, y);
+ m_layout_item_selected->get_xy(x, y);
- item->set_xy(
+ m_layout_item_selected->set_xy(
x,
m_spinbutton_y->get_value());
}
void Window_PrintLayout_Edit::on_spinbutton_width()
{
- Canvas_PrintLayout::type_vec_items items = m_canvas.get_selected_items();
- if(items.empty())
- return;
-
- Glib::RefPtr<CanvasLayoutItem> item = items[0];
- if(!item)
+ if(!m_layout_item_selected)
return;
double width = 0;
double height = 0;
- item->get_width_height(width, height);
+ m_layout_item_selected->get_width_height(width, height);
- item->set_width_height(
+ m_layout_item_selected->set_width_height(
m_spinbutton_width->get_value(),
height);
}
void Window_PrintLayout_Edit::on_spinbutton_height()
{
- Canvas_PrintLayout::type_vec_items items = m_canvas.get_selected_items();
- if(items.empty())
- return;
-
- Glib::RefPtr<CanvasLayoutItem> item = items[0];
- if(!item)
+ if(!m_layout_item_selected)
return;
double width = 0;
double height = 0;
- item->get_width_height(width, height);
+ m_layout_item_selected->get_width_height(width, height);
- item->set_width_height(
+ m_layout_item_selected->set_width_height(
width,
m_spinbutton_height->get_value());
}
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.h b/glom/mode_design/print_layouts/window_print_layout_edit.h
index 9284971..d5fad86 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.h
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.h
@@ -140,6 +140,10 @@ private:
bool m_drag_preview_requested;
Glib::RefPtr<CanvasLayoutItem> m_layout_item_dropping;
+ //A cache of the selected item,
+ //to avoid repeatedly requesting it:
+ Glib::RefPtr<CanvasLayoutItem> m_layout_item_selected;
+
GimpRuler* m_vruler;
GimpRuler* m_hruler;
@@ -158,6 +162,7 @@ private:
Gtk::Menu* m_context_menu;
Glib::RefPtr<Gtk::ActionGroup> m_context_menu_action_group;
Glib::RefPtr<Gtk::UIManager> m_context_menu_uimanager;
+
};
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]