diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 19:04:24 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-06 19:04:24 +0500 |
| commit | 793fa5a91f24358aa7ce21abf6ee4e93a17b04ee (patch) | |
| tree | e81d1e60ffdf068ac1e93e8d36d9c2046b2d7c50 /fluid/app/Snap_Action.cxx | |
| parent | b4995f979d127cea667b4e2b71c91e9db4ab52ef (diff) | |
wip
Diffstat (limited to 'fluid/app/Snap_Action.cxx')
| -rw-r--r-- | fluid/app/Snap_Action.cxx | 300 |
1 files changed, 150 insertions, 150 deletions
diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index 39a328b24..db68d6dd1 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -45,10 +45,10 @@ void select_layout_suite_cb(Fl_Widget *, void *user_data); -int fld::app::Snap_Action::eex = 0; -int fld::app::Snap_Action::eey = 0; +int Snap_Action::eex = 0; +int Snap_Action::eey = 0; -static fld::app::Layout_Preset fltk_app = { +static Layout_Preset fltk_app = { 15, 15, 15, 15, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 25, 25, // tabs: t, b @@ -56,7 +56,7 @@ static fld::app::Layout_Preset fltk_app = { 20, 4, 8, // widget_y: min, inc, gap 0, 14, -1, 14 // labelfont/size, textfont/size }; -static fld::app::Layout_Preset fltk_dlg = { +static Layout_Preset fltk_dlg = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -64,7 +64,7 @@ static fld::app::Layout_Preset fltk_dlg = { 20, 5, 5, // widget_y: min, inc, gap 0, 11, -1, 11 // labelfont/size, textfont/size }; -static fld::app::Layout_Preset fltk_tool = { +static Layout_Preset fltk_tool = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 18, 18, // tabs: t, b @@ -73,7 +73,7 @@ static fld::app::Layout_Preset fltk_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -static fld::app::Layout_Preset grid_app = { +static Layout_Preset grid_app = { 12, 12, 12, 12, 12, 12, // window: l, r, t, b, gx, gy 12, 12, 12, 12, 12, 12, // group: l, r, t, b, gx, gy 24, 24, // tabs: t, b @@ -82,7 +82,7 @@ static fld::app::Layout_Preset grid_app = { 0, 14, -1, 14 // labelfont/size, textfont/size }; -static fld::app::Layout_Preset grid_dlg = { +static Layout_Preset grid_dlg = { 10, 10, 10, 10, 10, 10, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 10, 10, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -91,7 +91,7 @@ static fld::app::Layout_Preset grid_dlg = { 0, 12, -1, 12 // labelfont/size, textfont/size }; -static fld::app::Layout_Preset grid_tool = { +static Layout_Preset grid_tool = { 8, 8, 8, 8, 8, 8, // window: l, r, t, b, gx, gy 8, 8, 8, 8, 8, 8, // group: l, r, t, b, gx, gy 16, 16, // tabs: t, b @@ -100,9 +100,9 @@ static fld::app::Layout_Preset grid_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -fld::app::Layout_Preset *fld::app::default_layout_preset = &fltk_app; +Layout_Preset *default_layout_preset = &fltk_app; -static fld::app::Layout_Suite static_suite_list[] = { +static Layout_Suite static_suite_list[] = { { (char*)"FLTK", (char*)"@fd_beaker FLTK", { &fltk_app, &fltk_dlg, &fltk_tool }, FLD_TOOL_STORE_INTERNAL }, { (char*)"Grid", (char*)"@fd_beaker Grid", { &grid_app, &grid_dlg, &grid_tool }, FLD_TOOL_STORE_INTERNAL } }; @@ -154,12 +154,12 @@ void edit_layout_preset_cb(Fl_Button *w, void *user_data) { } } -// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - +// ---- Layout_Suite ------------------------------------------------ MARK: - /** Write presets to a Preferences database. */ -void fld::app::Layout_Preset::write(Fl_Preferences &prefs) { +void Layout_Preset::write(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.set("left_margin", left_window_margin); @@ -199,7 +199,7 @@ void fld::app::Layout_Preset::write(Fl_Preferences &prefs) { /** Read presets from a Preferences database. */ -void fld::app::Layout_Preset::read(Fl_Preferences &prefs) { +void Layout_Preset::read(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.get("left_margin", left_window_margin, 15); @@ -239,7 +239,7 @@ void fld::app::Layout_Preset::read(Fl_Preferences &prefs) { /** Write presets to an .fl project file. */ -void fld::app::Layout_Preset::write(fld::io::Project_Writer *out) { +void Layout_Preset::write(Project_Writer *out) { out->write_string(" preset { 1\n"); // preset format version out->write_string(" %d %d %d %d %d %d\n", left_window_margin, right_window_margin, @@ -261,7 +261,7 @@ void fld::app::Layout_Preset::write(fld::io::Project_Writer *out) { /** Read presets from an .fl project file. */ -void fld::app::Layout_Preset::read(fld::io::Project_Reader *in) { +void Layout_Preset::read(Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -317,7 +317,7 @@ void fld::app::Layout_Preset::read(fld::io::Project_Reader *in) { /** Return the preferred text size, but make sure it's not 0. */ -int fld::app::Layout_Preset::textsize_not_null() { +int Layout_Preset::textsize_not_null() { // try the user selected text size if (textsize > 0) return textsize; // if the user did not set one, try the label size @@ -327,12 +327,12 @@ int fld::app::Layout_Preset::textsize_not_null() { } -// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - +// ---- Layout_Suite ------------------------------------------------ MARK: - /** Write a presets suite to a Preferences database. */ -void fld::app::Layout_Suite::write(Fl_Preferences &prefs) { +void Layout_Suite::write(Fl_Preferences &prefs) { assert(this); assert(name_); prefs.set("name", name_); @@ -347,7 +347,7 @@ void fld::app::Layout_Suite::write(Fl_Preferences &prefs) { /** Read a presets suite from a Preferences database. */ -void fld::app::Layout_Suite::read(Fl_Preferences &prefs) { +void Layout_Suite::read(Fl_Preferences &prefs) { assert(this); int i; for (i = 0; i < 3; ++i) { @@ -360,7 +360,7 @@ void fld::app::Layout_Suite::read(Fl_Preferences &prefs) { /** Write a presets suite to an .fl project file. */ -void fld::app::Layout_Suite::write(fld::io::Project_Writer *out) { +void Layout_Suite::write(Project_Writer *out) { out->write_string(" suite {\n"); out->write_string(" name "); out->write_word(name_); out->write_string("\n"); int i; @@ -373,7 +373,7 @@ void fld::app::Layout_Suite::write(fld::io::Project_Writer *out) { /** Read a presets suite from an .fl project file. */ -void fld::app::Layout_Suite::read(fld::io::Project_Reader *in) { +void Layout_Suite::read(Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -401,7 +401,7 @@ void fld::app::Layout_Suite::read(fld::io::Project_Reader *in) { \brief Update the menu_label to show a symbol representing the storage location. Also updates the FLUID user interface. */ -void fld::app::Layout_Suite::update_label() { +void Layout_Suite::update_label() { const char *sym = ""; switch (storage_) { case FLD_TOOL_STORE_INTERNAL: sym = "@fd_beaker "; break; @@ -421,7 +421,7 @@ void fld::app::Layout_Suite::update_label() { \brief Update the Suite name and the Suite menu_label. Also updates the FLUID user interface. */ -void fld::app::Layout_Suite::name(const char *n) { +void Layout_Suite::name(const char *n) { if (name_) ::free(name_); if (n) @@ -434,7 +434,7 @@ void fld::app::Layout_Suite::name(const char *n) { /** Initialize the class for first use. */ -void fld::app::Layout_Suite::init() { +void Layout_Suite::init() { name_ = 0; menu_label = 0; layout[0] = layout[1] = layout[2] = 0; @@ -444,7 +444,7 @@ void fld::app::Layout_Suite::init() { /** Free all allocated resources. */ -fld::app::Layout_Suite::~Layout_Suite() { +Layout_Suite::~Layout_Suite() { if (storage_ == FLD_TOOL_STORE_INTERNAL) return; if (name_) ::free(name_); int i; @@ -453,7 +453,7 @@ fld::app::Layout_Suite::~Layout_Suite() { } } -// ---- fld::app::Layout_List ------------------------------------------------- MARK: - +// ---- Layout_List ------------------------------------------------- MARK: - /** Draw a little FLUID beaker symbol. @@ -596,7 +596,7 @@ void fd_file(Fl_Color c) { /** Instantiate the class that holds a list of all layouts and manages the UI. */ -fld::app::Layout_List::Layout_List() +Layout_List::Layout_List() : main_menu_(main_layout_submenu_), choice_menu_(static_choice_menu), list_(static_suite_list), @@ -615,16 +615,16 @@ fld::app::Layout_List::Layout_List() /** Release allocated resources. */ -fld::app::Layout_List::~Layout_List() { +Layout_List::~Layout_List() { assert(this); if (!list_is_static_) { ::free(main_menu_); ::free(choice_menu_); int i; for (i = 0; i < list_size_; i++) { - fld::app::Layout_Suite &suite = list_[i]; + Layout_Suite &suite = list_[i]; if (suite.storage_ != FLD_TOOL_STORE_INTERNAL) - suite.fld::app::Layout_Suite::~Layout_Suite(); + suite.Layout_Suite::~Layout_Suite(); } ::free(list_); } @@ -633,7 +633,7 @@ fld::app::Layout_List::~Layout_List() { /** Update the Setting dialog and menus to reflect the current Layout selection state. */ -void fld::app::Layout_List::update_dialogs() { +void Layout_List::update_dialogs() { static Fl_Menu_Item *preset_menu = 0; if (!preset_menu) { preset_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(select_layout_preset_cb); @@ -657,7 +657,7 @@ void fld::app::Layout_List::update_dialogs() { /** Refresh the label pointers for both pulldown menus. */ -void fld::app::Layout_List::update_menu_labels() { +void Layout_List::update_menu_labels() { int i; for (i =0; i<list_size_; i++) { main_menu_[i].label(list_[i].menu_label); @@ -668,7 +668,7 @@ void fld::app::Layout_List::update_menu_labels() { /** Load all user layouts from the FLUID user preferences. */ -int fld::app::Layout_List::load(const char *filename) { +int Layout_List::load(const char *filename) { remove_all(FLD_TOOL_STORE_FILE); Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, Fl_Preferences::C_LOCALE); read(prefs, FLD_TOOL_STORE_FILE); @@ -678,7 +678,7 @@ int fld::app::Layout_List::load(const char *filename) { /** Save all user layouts to the FLUID user preferences. */ -int fld::app::Layout_List::save(const char *filename) { +int Layout_List::save(const char *filename) { assert(this); Fl_Preferences prefs(filename, "layout.fluid.fltk.org", 0, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR)); prefs.clear(); @@ -689,7 +689,7 @@ int fld::app::Layout_List::save(const char *filename) { /** Write Suite and Layout selection and selected layout data to Preferences database. */ -void fld::app::Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) { +void Layout_List::write(Fl_Preferences &prefs, Tool_Store storage) { Fl_Preferences prefs_list(prefs, "Layouts"); prefs_list.clear(); prefs_list.set("current_suite", list_[current_suite()].name_); @@ -697,7 +697,7 @@ void fld::app::Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage int n = 0; int i; for (i = 0; i < list_size_; ++i) { - fld::app::Layout_Suite &suite = list_[i]; + Layout_Suite &suite = list_[i]; if (suite.storage_ == storage) { Fl_Preferences prefs_suite(prefs_list, Fl_Preferences::Name(n++)); suite.write(prefs_suite); @@ -708,7 +708,7 @@ void fld::app::Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage /** Read Suite and Layout selection and selected layout data to Preferences database. */ -void fld::app::Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) { +void Layout_List::read(Fl_Preferences &prefs, Tool_Store storage) { Fl_Preferences prefs_list(prefs, "Layouts"); char *cs_ptr = 0; int cp = 0; @@ -737,7 +737,7 @@ void fld::app::Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) /** Write Suite and Layout selection and project layout data to an .fl project file. */ -void fld::app::Layout_List::write(fld::io::Project_Writer *out) { +void Layout_List::write(Project_Writer *out) { // Don't write the Snap field if no custom layout was used int i; if ((current_suite()==0) && (current_preset()==0)) { @@ -751,7 +751,7 @@ void fld::app::Layout_List::write(fld::io::Project_Writer *out) { out->write_string(" current_suite "); out->write_word(list_[current_suite()].name_); out->write_string("\n"); out->write_string(" current_preset %d\n", current_preset()); for (i =0; i<list_size_; i++) { - fld::app::Layout_Suite &suite = list_[i]; + Layout_Suite &suite = list_[i]; if (suite.storage_ == FLD_TOOL_STORE_PROJECT) suite.write(out); } @@ -761,7 +761,7 @@ void fld::app::Layout_List::write(fld::io::Project_Writer *out) { /** Read Suite and Layout selection and project layout data from an .fl project file. */ -void fld::app::Layout_List::read(fld::io::Project_Reader *in) { +void Layout_List::read(Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -798,7 +798,7 @@ void fld::app::Layout_List::read(fld::io::Project_Reader *in) { Set the current Suite. \param[in] ix index into list of suites */ -void fld::app::Layout_List::current_suite(int ix) { +void Layout_List::current_suite(int ix) { assert(ix >= 0); assert(ix < list_size_); current_suite_ = ix; @@ -810,11 +810,11 @@ void fld::app::Layout_List::current_suite(int ix) { \param[in] arg_name name of the selected suite \return if no name is given or the name is not found, keep the current suite selected */ -void fld::app::Layout_List::current_suite(const char *arg_name) { +void Layout_List::current_suite(const char *arg_name) { if (!arg_name || !arg_name[0]) return; int i; for (i = 0; i < list_size_; ++i) { - fld::app::Layout_Suite &suite = list_[i]; + Layout_Suite &suite = list_[i]; if (suite.name_ && (strcmp(suite.name_, arg_name) == 0)) { current_suite(i); break; @@ -826,7 +826,7 @@ void fld::app::Layout_List::current_suite(const char *arg_name) { Select a Preset within the current Suite. \param[in] ix 0 = application, 1 = dialog, 2 = toolbox */ -void fld::app::Layout_List::current_preset(int ix) { +void Layout_List::current_preset(int ix) { assert(ix >= 0); assert(ix < 3); current_preset_ = ix; @@ -836,7 +836,7 @@ void fld::app::Layout_List::current_preset(int ix) { /** Allocate enough space for n entries in the list. */ -void fld::app::Layout_List::capacity(int n) { +void Layout_List::capacity(int n) { static Fl_Menu_Item *suite_menu = 0; if (!suite_menu) suite_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(layout_suite_marker); @@ -844,7 +844,7 @@ void fld::app::Layout_List::capacity(int n) { int old_n = list_size_; int i; - fld::app::Layout_Suite *new_list = (fld::app::Layout_Suite*)::calloc(n, sizeof(fld::app::Layout_Suite)); + Layout_Suite *new_list = (Layout_Suite*)::calloc(n, sizeof(Layout_Suite)); for (i = 0; i < old_n; i++) new_list[i] = list_[i]; if (!list_is_static_) ::free(list_); @@ -872,21 +872,21 @@ void fld::app::Layout_List::capacity(int n) { \brief Clone the currently selected suite and append it to the list. Selects the new layout and updates the UI. */ -int fld::app::Layout_List::add(const char *name) { +int Layout_List::add(const char *name) { if (list_size_ == list_capacity_) { capacity(list_capacity_ * 2); } int n = list_size_; - fld::app::Layout_Suite &old_suite = list_[current_suite_]; - fld::app::Layout_Suite &new_suite = list_[n]; + Layout_Suite &old_suite = list_[current_suite_]; + Layout_Suite &new_suite = list_[n]; new_suite.init(); new_suite.name(name); int i; for (i =0; i<3; ++i) { - new_suite.layout[i] = new fld::app::Layout_Preset; - ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(fld::app::Layout_Preset)); + new_suite.layout[i] = new Layout_Preset; + ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(Layout_Preset)); } - fld::Tool_Store new_storage = old_suite.storage_; + Tool_Store new_storage = old_suite.storage_; if (new_storage == FLD_TOOL_STORE_INTERNAL) new_storage = FLD_TOOL_STORE_USER; new_suite.storage(new_storage); @@ -903,7 +903,7 @@ int fld::app::Layout_List::add(const char *name) { /** Rename the current Suite. */ -void fld::app::Layout_List::rename(const char *name) { +void Layout_List::rename(const char *name) { int n = current_suite(); list_[n].name(name); main_menu_[n].label(list_[n].menu_label); @@ -914,7 +914,7 @@ void fld::app::Layout_List::rename(const char *name) { Remove the given suite. \param[in] ix index into list of suites */ -void fld::app::Layout_List::remove(int ix) { +void Layout_List::remove(int ix) { int tail = list_size_-ix-1; if (tail) { int i; @@ -932,7 +932,7 @@ void fld::app::Layout_List::remove(int ix) { Remove all Suites that use the given storage attribute. \param[in] storage storage attribute, see FLD_TOOL_STORE_INTERNAL, etc. */ -void fld::app::Layout_List::remove_all(fld::Tool_Store storage) { +void Layout_List::remove_all(Tool_Store storage) { int i; for (i =list_size_-1; i>=0; --i) { if (list_[i].storage_ == storage) @@ -959,19 +959,19 @@ static int nearest(int x, int left, int grid, int right=0x7fff) { return grid_x; } -static bool in_window(fld::app::Snap_Data &d) { +static bool in_window(Snap_Data &d) { return (d.wgt && d.wgt->parent == d.win); } -static bool in_group(fld::app::Snap_Data &d) { +static bool in_group(Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Group) && d.wgt->parent != d.win); } -static bool in_tabs(fld::app::Snap_Data &d) { +static bool in_tabs(Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Tabs)); } -static Fl_Group *parent(fld::app::Snap_Data &d) { +static Fl_Group *parent(Snap_Data &d) { return (d.wgt->o->parent()); } @@ -1002,7 +1002,7 @@ static Fl_Group *parent(fld::app::Snap_Data &d) { \return -1 if this point is closer than any previous check, and this is the new distance to beat. */ -int fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) { +int Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) { int dd = x_ref + d.dx - x_snap; int d2 = abs(dd); if (d2 > d.x_dist) return 1; @@ -1015,9 +1015,9 @@ int fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_sna /** \brief Check if a snap action has reached a preferred y position. - \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) + \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) */ -int fld::app::Snap_Action::check_y_(fld::app::Snap_Data &d, int y_ref, int y_snap) { +int Snap_Action::check_y_(Snap_Data &d, int y_ref, int y_snap) { int dd = y_ref + d.dy - y_snap; int d2 = abs(dd); if (d2 > d.y_dist) return 1; @@ -1030,9 +1030,9 @@ int fld::app::Snap_Action::check_y_(fld::app::Snap_Data &d, int y_ref, int y_sna /** \brief Check if a snap action has reached a preferred x and y position. - \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) + \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) */ -void fld::app::Snap_Action::check_x_y_(fld::app::Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { +void Snap_Action::check_x_y_(Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { int ddx = x_ref + d.dx - x_snap; int d2x = abs(ddx); int ddy = y_ref + d.dy - y_snap; @@ -1053,7 +1053,7 @@ void fld::app::Snap_Action::check_x_y_(fld::app::Snap_Data &d, int x_ref, int x_ should be drawn. \param[inout] d current event data */ -bool fld::app::Snap_Action::matches(fld::app::Snap_Data &d) { +bool Snap_Action::matches(Snap_Data &d) { switch (type) { case 1: return (d.drag & mask) && (eex == ex) && (d.dx == dx); case 2: return (d.drag & mask) && (eey == ey) && (d.dy == dy); @@ -1066,7 +1066,7 @@ bool fld::app::Snap_Action::matches(fld::app::Snap_Data &d) { \brief Run through all possible snap actions and store the winning coordinates in eex and eey. \param[inout] d current event data */ -void fld::app::Snap_Action::check_all(fld::app::Snap_Data &data) { +void Snap_Action::check_all(Snap_Data &data) { int i; for (i =0; list[i]; i++) { if (list[i]->mask & data.drag) @@ -1083,7 +1083,7 @@ void fld::app::Snap_Action::check_all(fld::app::Snap_Data &data) { coordinate, all of them will be drawn. \param[inout] d current event data */ -void fld::app::Snap_Action::draw_all(fld::app::Snap_Data &data) { +void Snap_Action::draw_all(Snap_Data &data) { int i; for (i =0; list[i]; i++) { if (list[i]->matches(data)) @@ -1092,8 +1092,8 @@ void fld::app::Snap_Action::draw_all(fld::app::Snap_Data &data) { } /** Return a sensible step size for resizing a widget. */ -void fld::app::Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; +void Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { + Layout_Preset *layout = Fluid.proj.layout; if ((layout->widget_inc_w > 1) && (layout->widget_inc_h > 1)) { x_step = layout->widget_inc_w; y_step = layout->widget_inc_h; @@ -1107,8 +1107,8 @@ void fld::app::Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { } /** Return a sensible step size for moving a widget. */ -void fld::app::Snap_Action::get_move_stepsize(int &x_step, int &y_step) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; +void Snap_Action::get_move_stepsize(int &x_step, int &y_step) { + Layout_Preset *layout = Fluid.proj.layout; if ((layout->group_grid_x > 1) && (layout->group_grid_y > 1)) { x_step = layout->group_grid_x; y_step = layout->group_grid_y; @@ -1122,8 +1122,8 @@ void fld::app::Snap_Action::get_move_stepsize(int &x_step, int &y_step) { } /** Fix the given size to the same or next bigger snap position. */ -void fld::app::Snap_Action::better_size(int &w, int &h) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; +void Snap_Action::better_size(int &w, int &h) { + Layout_Preset *layout = Fluid.proj.layout; int x_min = 1, y_min = 1, x_inc = 1, y_inc = 1; get_resize_stepsize(x_inc, y_inc); if (x_inc < 1) x_inc = 1; @@ -1148,7 +1148,7 @@ void fld::app::Snap_Action::better_size(int &w, int &h) { /** Base class for all actions that drag the left side or the entire widget. */ -class Fd_Snap_Left : public fld::app::Snap_Action { +class Fd_Snap_Left : public Snap_Action { public: Fd_Snap_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } }; @@ -1156,7 +1156,7 @@ public: /** Base class for all actions that drag the right side or the entire widget. */ -class Fd_Snap_Right : public fld::app::Snap_Action { +class Fd_Snap_Right : public Snap_Action { public: Fd_Snap_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } }; @@ -1164,7 +1164,7 @@ public: /** Base class for all actions that drag the top side or the entire widget. */ -class Fd_Snap_Top : public fld::app::Snap_Action { +class Fd_Snap_Top : public Snap_Action { public: Fd_Snap_Top() { type = 2; mask = FD_TOP|FD_DRAG; } }; @@ -1172,7 +1172,7 @@ public: /** Base class for all actions that drag the bottom side or the entire widget. */ -class Fd_Snap_Bottom : public fld::app::Snap_Action { +class Fd_Snap_Bottom : public Snap_Action { public: Fd_Snap_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } }; @@ -1184,8 +1184,8 @@ public: */ class Fd_Snap_Left_Window_Edge : public Fd_Snap_Left { public: - void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } - void draw(fld::app::Snap_Data &d) { draw_left_brace(d.win->o); } + void check(Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } + void draw(Snap_Data &d) { draw_left_brace(d.win->o); } }; Fd_Snap_Left_Window_Edge snap_left_window_edge; @@ -1194,8 +1194,8 @@ Fd_Snap_Left_Window_Edge snap_left_window_edge; */ class Fd_Snap_Right_Window_Edge : public Fd_Snap_Right { public: - void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } - void draw(fld::app::Snap_Data &d) { draw_right_brace(d.win->o); } + void check(Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } + void draw(Snap_Data &d) { draw_right_brace(d.win->o); } }; Fd_Snap_Right_Window_Edge snap_right_window_edge; @@ -1204,8 +1204,8 @@ Fd_Snap_Right_Window_Edge snap_right_window_edge; */ class Fd_Snap_Top_Window_Edge : public Fd_Snap_Top { public: - void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.by, 0); } - void draw(fld::app::Snap_Data &d) { draw_top_brace(d.win->o); } + void check(Snap_Data &d) { clr(); check_y_(d, d.by, 0); } + void draw(Snap_Data &d) { draw_top_brace(d.win->o); } }; Fd_Snap_Top_Window_Edge snap_top_window_edge; @@ -1214,8 +1214,8 @@ Fd_Snap_Top_Window_Edge snap_top_window_edge; */ class Fd_Snap_Bottom_Window_Edge : public Fd_Snap_Bottom { public: - void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } - void draw(fld::app::Snap_Data &d) { draw_bottom_brace(d.win->o); } + void check(Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } + void draw(Snap_Data &d) { draw_bottom_brace(d.win->o); } }; Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; @@ -1224,11 +1224,11 @@ Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; */ class Fd_Snap_Left_Window_Margin : public Fd_Snap_Left { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.bx, Fluid.proj.layout->left_window_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_h_arrow(d.bx, (d.by+d.bt)/2, 0); } }; @@ -1236,11 +1236,11 @@ Fd_Snap_Left_Window_Margin snap_left_window_margin; class Fd_Snap_Right_Window_Margin : public Fd_Snap_Right { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.br, d.win->o->w()-Fluid.proj.layout->right_window_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_h_arrow(d.br, (d.by+d.bt)/2, d.win->o->w()-1); } }; @@ -1248,11 +1248,11 @@ Fd_Snap_Right_Window_Margin snap_right_window_margin; class Fd_Snap_Top_Window_Margin : public Fd_Snap_Top { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.by, Fluid.proj.layout->top_window_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.by, 0); } }; @@ -1260,11 +1260,11 @@ Fd_Snap_Top_Window_Margin snap_top_window_margin; class Fd_Snap_Bottom_Window_Margin : public Fd_Snap_Bottom { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.bt, d.win->o->h()-Fluid.proj.layout->bottom_window_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.bt, d.win->o->h()-1); } }; @@ -1277,11 +1277,11 @@ Fd_Snap_Bottom_Window_Margin snap_bottom_window_margin; */ class Fd_Snap_Left_Group_Edge : public Fd_Snap_Left { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_left_brace(parent(d)); } }; @@ -1289,11 +1289,11 @@ Fd_Snap_Left_Group_Edge snap_left_group_edge; class Fd_Snap_Right_Group_Edge : public Fd_Snap_Right { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x() + parent(d)->w()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_right_brace(parent(d)); } }; @@ -1301,11 +1301,11 @@ Fd_Snap_Right_Group_Edge snap_right_group_edge; class Fd_Snap_Top_Group_Edge : public Fd_Snap_Top { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.by, parent(d)->y()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_top_brace(parent(d)); } }; @@ -1313,11 +1313,11 @@ Fd_Snap_Top_Group_Edge snap_top_group_edge; class Fd_Snap_Bottom_Group_Edge : public Fd_Snap_Bottom { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.bt, parent(d)->y() + parent(d)->h()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_bottom_brace(parent(d)); } }; @@ -1329,11 +1329,11 @@ Fd_Snap_Bottom_Group_Edge snap_bottom_group_edge; */ class Fd_Snap_Left_Group_Margin : public Fd_Snap_Left { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x() + Fluid.proj.layout->left_group_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_left_brace(parent(d)); draw_h_arrow(d.bx, (d.by+d.bt)/2, parent(d)->x()); } @@ -1342,11 +1342,11 @@ Fd_Snap_Left_Group_Margin snap_left_group_margin; class Fd_Snap_Right_Group_Margin : public Fd_Snap_Right { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x()+parent(d)->w()-Fluid.proj.layout->right_group_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_right_brace(parent(d)); draw_h_arrow(d.br, (d.by+d.bt)/2, parent(d)->x()+parent(d)->w()-1); } @@ -1355,11 +1355,11 @@ Fd_Snap_Right_Group_Margin snap_right_group_margin; class Fd_Snap_Top_Group_Margin : public Fd_Snap_Top { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_group_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_top_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.by, parent(d)->y()); } @@ -1368,11 +1368,11 @@ Fd_Snap_Top_Group_Margin snap_top_group_margin; class Fd_Snap_Bottom_Group_Margin : public Fd_Snap_Bottom { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_group_margin); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_bottom_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.bt, parent(d)->y()+parent(d)->h()-1); } @@ -1386,7 +1386,7 @@ Fd_Snap_Bottom_Group_Margin snap_bottom_group_margin; */ class Fd_Snap_Top_Tabs_Margin : public Fd_Snap_Top_Group_Margin { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_tabs_margin); } @@ -1395,7 +1395,7 @@ Fd_Snap_Top_Tabs_Margin snap_top_tabs_margin; class Fd_Snap_Bottom_Tabs_Margin : public Fd_Snap_Bottom_Group_Margin { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_tabs_margin); } @@ -1407,12 +1407,12 @@ Fd_Snap_Bottom_Tabs_Margin snap_bottom_tabs_margin; /** Base class for grid based snapping. */ -class Fd_Snap_Grid : public fld::app::Snap_Action { +class Fd_Snap_Grid : public Snap_Action { protected: int nearest_x, nearest_y; public: Fd_Snap_Grid() { type = 3; mask = FD_LEFT|FD_TOP|FD_DRAG; } - void check_grid(fld::app::Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { + void check_grid(Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { if ((grid_x <= 1) || (grid_y <= 1)) return; int suggested_x = d.bx + d.dx; nearest_x = nearest(suggested_x, left, grid_x, right); @@ -1425,7 +1425,7 @@ public: else check_x_y_(d, d.bx, nearest_x, d.by, nearest_y); } - bool matches(fld::app::Snap_Data &d) { + bool matches(Snap_Data &d) { if (d.drag == FD_LEFT) return (eex == ex); if (d.drag == FD_TOP) return (eey == ey) && (d.dx == dx); return (d.drag & mask) && (eex == ex) && (d.dx == dx) && (eey == ey) && (d.dy == dy); @@ -1437,14 +1437,14 @@ public: */ class Fd_Snap_Window_Grid : public Fd_Snap_Grid { public: - void check(fld::app::Snap_Data &d) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + void check(Snap_Data &d) { + Layout_Preset *layout = Fluid.proj.layout; clr(); if (in_window(d)) check_grid(d, layout->left_window_margin, layout->window_grid_x, d.win->o->w()-layout->right_window_margin, layout->top_window_margin, layout->window_grid_y, d.win->o->h()-layout->bottom_window_margin); } - void draw(fld::app::Snap_Data &d) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + void draw(Snap_Data &d) { + Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->window_grid_x, layout->window_grid_y); } }; @@ -1455,17 +1455,17 @@ Fd_Snap_Window_Grid snap_window_grid; */ class Fd_Snap_Group_Grid : public Fd_Snap_Grid { public: - void check(fld::app::Snap_Data &d) { + void check(Snap_Data &d) { if (in_group(d)) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + Layout_Preset *layout = Fluid.proj.layout; clr(); Fl_Widget *g = parent(d); check_grid(d, g->x()+layout->left_group_margin, layout->group_grid_x, g->x()+g->w()-layout->right_group_margin, g->y()+layout->top_group_margin, layout->group_grid_y, g->y()+g->h()-layout->bottom_group_margin); } } - void draw(fld::app::Snap_Data &d) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + void draw(Snap_Data &d) { + Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->group_grid_x, layout->group_grid_y); } }; @@ -1476,13 +1476,13 @@ Fd_Snap_Group_Grid snap_group_grid; /** Base class the check distance to other widgets in the same group. */ -class Fd_Snap_Sibling : public fld::app::Snap_Action { +class Fd_Snap_Sibling : public Snap_Action { protected: Fl_Widget *best_match; public: Fd_Snap_Sibling() : best_match(0) { } - virtual int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) = 0; - void check(fld::app::Snap_Data &d) { + virtual int sibling_check(Snap_Data &d, Fl_Widget *s) = 0; + void check(Snap_Data &d) { clr(); best_match = 0; if (!d.wgt) return; @@ -1517,10 +1517,10 @@ public: class Fd_Snap_Siblings_Left_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left_Same() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.bx, s->x()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1532,11 +1532,11 @@ Fd_Snap_Siblings_Left_Same snap_siblings_left_same; class Fd_Snap_Siblings_Left : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.bx, s->x()+s->w()), check_x_(d, d.bx, s->x()+s->w()+Fluid.proj.layout->widget_gap_x) ); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1545,10 +1545,10 @@ Fd_Snap_Siblings_Left snap_siblings_left; class Fd_Snap_Siblings_Right_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right_Same() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.br, s->x()+s->w()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1557,11 +1557,11 @@ Fd_Snap_Siblings_Right_Same snap_siblings_right_same; class Fd_Snap_Siblings_Right : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.br, s->x()), check_x_(d, d.br, s->x()-Fluid.proj.layout->widget_gap_x)); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1570,10 +1570,10 @@ Fd_Snap_Siblings_Right snap_siblings_right; class Fd_Snap_Siblings_Top_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top_Same() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.by, s->y()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1582,11 +1582,11 @@ Fd_Snap_Siblings_Top_Same snap_siblings_top_same; class Fd_Snap_Siblings_Top : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.by, s->y()+s->h()), check_y_(d, d.by, s->y()+s->h()+Fluid.proj.layout->widget_gap_y)); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1595,10 +1595,10 @@ Fd_Snap_Siblings_Top snap_siblings_top; class Fd_Snap_Siblings_Bottom_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom_Same() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.bt, s->y()+s->h()); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1607,11 +1607,11 @@ Fd_Snap_Siblings_Bottom_Same snap_siblings_bottom_same; class Fd_Snap_Siblings_Bottom : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { + int sibling_check(Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.bt, s->y()), check_y_(d, d.bt, s->y()-Fluid.proj.layout->widget_gap_y)); } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1623,11 +1623,11 @@ Fd_Snap_Siblings_Bottom snap_siblings_bottom; /** Snap horizontal resizing to min_w or min_w and a multiple of inc_w. */ -class Fd_Snap_Widget_Ideal_Width : public fld::app::Snap_Action { +class Fd_Snap_Widget_Ideal_Width : public Snap_Action { public: Fd_Snap_Widget_Ideal_Width() { type = 1; mask = FD_LEFT|FD_RIGHT; } - void check(fld::app::Snap_Data &d) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + void check(Snap_Data &d) { + Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw = 15, ih = 15; @@ -1644,17 +1644,17 @@ public: check_x_(d, d.bx, d.br-iw); } } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_width(d.bx, d.bt+7, d.br, 0); } }; Fd_Snap_Widget_Ideal_Width snap_widget_ideal_width; -class Fd_Snap_Widget_Ideal_Height : public fld::app::Snap_Action { +class Fd_Snap_Widget_Ideal_Height : public Snap_Action { public: Fd_Snap_Widget_Ideal_Height() { type = 2; mask = FD_TOP|FD_BOTTOM; } - void check(fld::app::Snap_Data &d) { - fld::app::Layout_Preset *layout = Fluid.proj.layout; + void check(Snap_Data &d) { + Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw, ih; @@ -1671,7 +1671,7 @@ public: check_y_(d, d.by, d.bt-ih); } } - void draw(fld::app::Snap_Data &d) { + void draw(Snap_Data &d) { draw_height(d.br+7, d.by, d.bt, 0); } }; @@ -1686,7 +1686,7 @@ Fd_Snap_Widget_Ideal_Height snap_widget_ideal_height; action in the list wins. All snap actions with the same distance and same winning coordinates are drawn in the overlay plane. */ -fld::app::Snap_Action *fld::app::Snap_Action::list[] = { +Snap_Action *Snap_Action::list[] = { &snap_left_window_edge, &snap_right_window_edge, &snap_top_window_edge, |
