mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-01 10:27:53 +02:00
Toolkit widget solution enhanced
- Bring text and path options to front when changing mode - Path width and text string can be configure in toolkit widget - Enter key finishes move and partial move
This commit is contained in:
@@ -67,43 +67,180 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The base class for a object properties page
|
||||
* @brief The base class for a editor options page
|
||||
*
|
||||
* The object properties page is shown in the editor options panel
|
||||
* for the active plugin.
|
||||
*
|
||||
* Pages can be toolbox widgets, i.e. they are shown in the drawing area
|
||||
* at the top of the canvas, instead of being shown in the editor options
|
||||
* panel.
|
||||
*/
|
||||
class LAYBASIC_PUBLIC EditorOptionsPage
|
||||
: public tl::Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
EditorOptionsPage ();
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~EditorOptionsPage ();
|
||||
|
||||
/**
|
||||
* @brief The title of the page
|
||||
* This title is used for the tab title the page appears
|
||||
*/
|
||||
virtual std::string title () const = 0;
|
||||
|
||||
/**
|
||||
* @brief The order in which the pages appear
|
||||
* This index specifies the position of the page. The page with the
|
||||
* lower index appears left.
|
||||
* The page with order 0 is the default page, picked when the plugin
|
||||
* becomes active.
|
||||
*/
|
||||
virtual int order () const = 0;
|
||||
|
||||
/**
|
||||
* @brief The page name
|
||||
* Giving a page name allows looking up a page by name.
|
||||
* The page name is optional and if not specified, a zero pointer
|
||||
* should be returned.
|
||||
*/
|
||||
virtual const char *name () const { return 0; }
|
||||
|
||||
/**
|
||||
* @brief A callback to apply all values
|
||||
* The page is expected to issue "config_set" calls to the dispatcher
|
||||
* to deliver the settings.
|
||||
* This callback is not used for toolbox widgets.
|
||||
*/
|
||||
virtual void apply (lay::Dispatcher * /*root*/) { }
|
||||
virtual void cancel () { }
|
||||
virtual void commit (lay::Dispatcher * /*root*/) { }
|
||||
|
||||
/**
|
||||
* @brief A callback to setup the page
|
||||
* This callback is expected to set up the page values from
|
||||
* the configuration, stored inside the dispatcher.
|
||||
* This callback is not used for toolbox widgets.
|
||||
*/
|
||||
virtual void setup (lay::Dispatcher * /*root*/) { }
|
||||
|
||||
/**
|
||||
* @brief A callback to cancel the page edits
|
||||
* This callback is used for toolbox widgets if the user presses
|
||||
* "Escape".
|
||||
*/
|
||||
virtual void cancel () { }
|
||||
|
||||
/**
|
||||
* @brief A callback to commit the values
|
||||
* This callback is used for toolbox widgets if the user presses
|
||||
* "Enter". It can either commit values to the dispatcher
|
||||
* through "config_set", or perform other functions.
|
||||
*/
|
||||
virtual void commit (lay::Dispatcher * /*root*/) { }
|
||||
|
||||
/**
|
||||
* @brief Configure the page
|
||||
* This interface can be used by plugin implementation to transfer
|
||||
* data from the plugin to a toolbox widget. This method is not
|
||||
* used by the system directly.
|
||||
*/
|
||||
virtual void configure (const std::string & /*name*/, const std::string & /*value*/) { }
|
||||
|
||||
/**
|
||||
* @brief Called by the system to commit the current settings into some "recently used" list
|
||||
*/
|
||||
virtual void commit_recent (lay::Dispatcher * /*root*/) { }
|
||||
|
||||
/**
|
||||
* @brief Called by the system to restore recent settings for a given layer
|
||||
*/
|
||||
virtual void config_recent_for_layer (lay::Dispatcher * /*root*/, const db::LayerProperties & /*lp*/, int /*cv_index*/) { }
|
||||
|
||||
/**
|
||||
* @brief Sets the focus to the page
|
||||
* This function is called by the system to establish the focus on this page.
|
||||
*/
|
||||
virtual void set_focus () { }
|
||||
|
||||
/**
|
||||
* @brief Returns the widget for the page
|
||||
* The page itself is not a Qt object. To fetch the corresponding widget, use this method.
|
||||
*/
|
||||
virtual EditorOptionsPageWidget *widget () { return 0; }
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the page is visible
|
||||
*/
|
||||
virtual bool is_visible () const { return false; }
|
||||
|
||||
/**
|
||||
* @brief Changes the visibility of the page
|
||||
*/
|
||||
virtual void set_visible (bool /*visible*/) { }
|
||||
|
||||
/**
|
||||
* @brief Returns a flag indicating whether the page is a focus page
|
||||
* Focus pages are pages that are activated when the user presses the Tab
|
||||
* key in the canvas. Toolbox widgets receive the focus and modal pages
|
||||
* are shown modally.
|
||||
*/
|
||||
bool is_focus_page () const { return m_focus_page; }
|
||||
|
||||
/**
|
||||
* @brief Sets a flag indicating whether the page is a focus page
|
||||
*/
|
||||
void set_focus_page (bool f) { m_focus_page = f; }
|
||||
|
||||
/**
|
||||
* @brief Returns a flag indicating whether the page is a modal page
|
||||
* Modal pages are shown in a modal dialog when they receive the focus.
|
||||
* Otherwise they remain invisible.
|
||||
*/
|
||||
bool is_modal_page () const { return m_modal_page; }
|
||||
|
||||
/**
|
||||
* @brief Sets a flag indicating whether the page is a modal page
|
||||
*/
|
||||
void set_modal_page (bool f) { m_modal_page = f; }
|
||||
|
||||
/**
|
||||
* @brief Returns a flag indicating whether the page is a toolbox widget
|
||||
*/
|
||||
bool is_toolbox_widget () const { return m_toolbox_widget; }
|
||||
|
||||
/**
|
||||
* @brief Sets a flag indicating whether the page is a toolbox widget
|
||||
*/
|
||||
void set_toolbox_widget (bool f) { m_toolbox_widget = f; }
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the page is active
|
||||
* A page is active when the corresponding plugin is active
|
||||
*/
|
||||
bool active () const { return m_active; }
|
||||
|
||||
/**
|
||||
* @brief Activates a page
|
||||
* This function is called when the system activates a page because the
|
||||
* corresponding plugin was activate.
|
||||
*/
|
||||
void activate (bool active);
|
||||
|
||||
/**
|
||||
* @brief Sets the owner of the page
|
||||
* This function is used by the system and must not be used otherwise.
|
||||
*/
|
||||
void set_owner (EditorOptionsPageCollection *owner);
|
||||
|
||||
/**
|
||||
@@ -112,35 +249,56 @@ public:
|
||||
*/
|
||||
int show ();
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the page is for that specific plugin (given by a declaration object)
|
||||
*/
|
||||
bool for_plugin_declaration (const lay::PluginDeclaration *pd)
|
||||
{
|
||||
return m_plugin_declarations.find (pd) != m_plugin_declarations.end ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the plugin the page is associated with
|
||||
* This function is used by the system and must not be used otherwise.
|
||||
*/
|
||||
void set_plugin_declaration (const lay::PluginDeclaration *pd)
|
||||
{
|
||||
m_plugin_declarations.clear ();
|
||||
m_plugin_declarations.insert (pd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the plugins the page is associated with
|
||||
* This function is used by the system and must not be used otherwise.
|
||||
*/
|
||||
void set_plugin_declarations (const std::vector<const lay::PluginDeclaration *> &pd)
|
||||
{
|
||||
m_plugin_declarations.clear ();
|
||||
m_plugin_declarations.insert (pd.begin (), pd.end ());
|
||||
}
|
||||
|
||||
void init (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
|
||||
|
||||
/**
|
||||
* @brief Gets the dispatcher the page is connected to
|
||||
*/
|
||||
lay::Dispatcher *dispatcher () const
|
||||
{
|
||||
return mp_dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the view the page is connected to
|
||||
*/
|
||||
lay::LayoutViewBase *view () const
|
||||
{
|
||||
return mp_view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the page
|
||||
* This function is used by the system and must not be used otherwise.
|
||||
*/
|
||||
void init (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
|
||||
|
||||
protected:
|
||||
virtual void active_cellview_changed () { }
|
||||
virtual void technology_changed (const std::string & /*tech*/) { }
|
||||
|
||||
@@ -117,6 +117,11 @@ MoveService::key_event (unsigned int key, unsigned int buttons)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (buttons == 0 && (key == lay::KeyEnter || key == lay::KeyReturn)) {
|
||||
end_move ();
|
||||
return true;
|
||||
}
|
||||
|
||||
double dx = 0.0, dy = 0.0;
|
||||
if (int (key) == lay::KeyDown) {
|
||||
dy = -1.0;
|
||||
@@ -369,6 +374,14 @@ MoveService::start_move (db::Transaction *transaction, bool transient_selection)
|
||||
return handle_click (pstart, 0, drag_transient, trans_holder.release ());
|
||||
}
|
||||
|
||||
void
|
||||
MoveService::end_move ()
|
||||
{
|
||||
if (m_dragging) {
|
||||
handle_click (m_mouse_pos, 0, false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_transient, db::Transaction *transaction)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
~MoveService ();
|
||||
|
||||
bool start_move (db::Transaction *transaction = 0, bool transient_selection = false);
|
||||
void end_move ();
|
||||
|
||||
bool configure (const std::string &name, const std::string &value);
|
||||
void function (const std::string &name, const std::string &value);
|
||||
|
||||
Reference in New Issue
Block a user