diff --git a/fluid/Fd_Snap_Action.cxx b/fluid/Fd_Snap_Action.cxx index 56d1486e2..f226ff156 100644 --- a/fluid/Fd_Snap_Action.cxx +++ b/fluid/Fd_Snap_Action.cxx @@ -921,8 +921,8 @@ static void draw_right_brace(const Fl_Widget *w); static void draw_top_brace(const Fl_Widget *w); static void draw_bottom_brace(const Fl_Widget *w); static void draw_grid(int x, int y, int dx, int dy); -static void draw_width(int x, int y, int r, Fl_Align a); -static void draw_height(int x, int y, int b, Fl_Align a); +void draw_width(int x, int y, int r, Fl_Align a); +void draw_height(int x, int y, int b, Fl_Align a); static int nearest(int x, int left, int grid, int right=0x7fff) { int grid_x = ((x-left+grid/2)/grid)*grid+left; @@ -1734,7 +1734,7 @@ static void draw_bottom_brace(const Fl_Widget *w) { fl_xyline(x-2, y, x+w->w()+1); } -static void draw_height(int x, int y, int b, Fl_Align a) { +void draw_height(int x, int y, int b, Fl_Align a) { char buf[16]; int h = b - y; sprintf(buf, "%d", h); @@ -1768,7 +1768,7 @@ static void draw_height(int x, int y, int b, Fl_Align a) { fl_xyline(x - 4, b, x + 4); } -static void draw_width(int x, int y, int r, Fl_Align a) { +void draw_width(int x, int y, int r, Fl_Align a) { char buf[16]; int w = r-x; sprintf(buf, "%d", w); diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx index 4b49b481c..f1c68c888 100644 --- a/fluid/Fl_Group_Type.cxx +++ b/fluid/Fl_Group_Type.cxx @@ -515,6 +515,25 @@ void Fl_Flex_Type::insert_child_at(Fl_Widget *child, int x, int y) { } } +void Fl_Flex_Type::keyboard_move_child(Fl_Widget_Type *child, int key) { + Fl_Flex *flex = ((Fl_Flex*)o); + int ix = flex->find(child->o); + if (ix == flex->children()) return; + if (flex->horizontal()) { + if (key==FL_Right) { + flex->insert(*child->o, ix+2); + } else if (key==FL_Left) { + if (ix > 0) flex->insert(*child->o, ix-1); + } + } else { + if (key==FL_Down) { + flex->insert(*child->o, ix+2); + } else if (key==FL_Up) { + if (ix > 0) flex->insert(*child->o, ix-1); + } + } +} + int Fl_Flex_Type::size(Fl_Type *t, char fixed_only) { if (!t->is_widget()) return 0; if (!t->parent) return 0; diff --git a/fluid/Fl_Group_Type.h b/fluid/Fl_Group_Type.h index ca7d20a9a..694d2a01f 100644 --- a/fluid/Fl_Group_Type.h +++ b/fluid/Fl_Group_Type.h @@ -126,6 +126,7 @@ public: void layout_widget() FL_OVERRIDE; void change_subtype_to(int n); void insert_child_at(Fl_Widget *child, int x, int y); + void keyboard_move_child(Fl_Widget_Type*, int key); static int parent_is_flex(Fl_Type*); static int size(Fl_Type*, char fixed_only=0); static int is_fixed(Fl_Type*); diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx index 73ad4be40..93e40c0b8 100644 --- a/fluid/Fl_Window_Type.cxx +++ b/fluid/Fl_Window_Type.cxx @@ -40,12 +40,16 @@ #include #include #include +#include #include "../src/flstring.h" #include #include #include +extern void draw_width(int x, int y, int r, Fl_Align a); +extern void draw_height(int x, int y, int b, Fl_Align a); + extern Fl_Preferences fluid_prefs; // Update the XYWH values in the widget panel... @@ -618,23 +622,13 @@ void Fl_Window_Type::draw_overlay() { int x,y,r,t; newposition(myo,x,y,r,t); if (!show_guides || !drag || numselected != 1) { - if (Fl_Flex_Type::parent_is_flex(q) && !Fl_Flex_Type::is_fixed(q)) { - if (((Fl_Flex*)((Fl_Flex_Type*)q->parent)->o)->horizontal()) { - int yh = y + (t-y)/2; - fl_begin_loop(); - fl_vertex(x+2, yh); fl_vertex(x+12, yh+5); fl_vertex(x+12, yh-5); - fl_end_loop(); - fl_begin_loop(); - fl_vertex(r-3, yh); fl_vertex(r-13, yh+5); fl_vertex(r-13, yh-5); - fl_end_loop(); + if (Fl_Flex_Type::parent_is_flex(q) && Fl_Flex_Type::is_fixed(q)) { + Fl_Flex *flex = ((Fl_Flex*)((Fl_Flex_Type*)q->parent)->o); + Fl_Widget *wgt = myo->o; + if (flex->horizontal()) { + draw_width(wgt->x(), wgt->y()+15, wgt->x()+wgt->w(), FL_ALIGN_CENTER); } else { - int xh = x + (r-x)/2; - fl_begin_loop(); - fl_vertex(xh, y+2); fl_vertex(xh+5, y+12); fl_vertex(xh-5, y+12); - fl_end_loop(); - fl_begin_loop(); - fl_vertex(xh, t-3); fl_vertex(xh+5, t-13); fl_vertex(xh-5, t-13); - fl_end_loop(); + draw_height(wgt->x()+15, wgt->y(), wgt->y()+wgt->h(), FL_ALIGN_CENTER); } } fl_rect(x,y,r-x,t-y); @@ -837,8 +831,11 @@ extern Fl_Menu_Item New_Menu[]; This is not ideal for widgets that are moved or resized within a group that manages the layout of its children. We must create a more universal way to modify move events per widget type. + + \param[in] key if key is not 0, it contains the code of the keypress that + caused this call. This must only be set when handle FL_KEYBOARD events. */ -void Fl_Window_Type::moveallchildren() +void Fl_Window_Type::moveallchildren(int key) { undo_checkpoint(); Fl_Type *i; @@ -862,7 +859,9 @@ void Fl_Window_Type::moveallchildren() // so that the user request is reflected. Fl_Flex_Type* ft = (Fl_Flex_Type*)myo->parent; Fl_Flex* f = (Fl_Flex*)ft->o; - if (drag & FD_DRAG) { + if (key) { + ft->keyboard_move_child(myo, key); + } else if (drag & FD_DRAG) { ft->insert_child_at(myo->o, Fl::event_x(), Fl::event_y()); } else { if (f->horizontal()) { @@ -1181,7 +1180,7 @@ int Fl_Window_Type::handle(int event) { dx *= x_step; dy *= y_step; } - moveallchildren(); + moveallchildren(Fl::event_key()); drag = 0; return 1; diff --git a/fluid/Fl_Window_Type.h b/fluid/Fl_Window_Type.h index 758ae2402..56abd630f 100644 --- a/fluid/Fl_Window_Type.h +++ b/fluid/Fl_Window_Type.h @@ -72,7 +72,7 @@ protected: Fl_Widget_Type *_make() FL_OVERRIDE {return 0;} // we don't call this Fl_Widget *widget(int,int,int,int) FL_OVERRIDE {return 0;} int recalc; // set by fix_overlay() - void moveallchildren(); + void moveallchildren(int key=0); ID id() const FL_OVERRIDE { return ID_Window; } bool is_a(ID inID) const FL_OVERRIDE { return (inID==ID_Window) ? true : super::is_a(inID); } void open_();