summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-06-13 09:52:54 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-06-13 09:52:54 -0400
commit9142d1edf588136f98edb0ce145a9dd76e898f5b (patch)
tree89ddf23a947b6caaf9e5fcc2b20864f94602373f /libs/gtkmm2ext
parentceb0bce971026944d4cc2cc900acab7b4f68c57e (diff)
working version of pane position mgmt for OS X
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/pane.h5
-rw-r--r--libs/gtkmm2ext/pane.cc101
2 files changed, 67 insertions, 39 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/pane.h b/libs/gtkmm2ext/gtkmm2ext/pane.h
index 2fa35eb3a5..dfe2ef7ffe 100644
--- a/libs/gtkmm2ext/gtkmm2ext/pane.h
+++ b/libs/gtkmm2ext/gtkmm2ext/pane.h
@@ -64,6 +64,8 @@ class LIBGTKMM2EXT_API Pane : public Gtk::Container
GType child_type_vfunc() const;
void set_drag_cursor (Gdk::Cursor);
+ void set_check_divider_position (bool);
+
protected:
bool horizontal;
@@ -101,8 +103,11 @@ class LIBGTKMM2EXT_API Pane : public Gtk::Container
typedef std::list<Divider*> Dividers;
Dividers dividers;
int divider_width;
+ bool check_fract;
+
void add_divider ();
void handle_child_visibility ();
+ bool fract_is_ok (Dividers::size_type, float fract);
};
class LIBGTKMM2EXT_API HPane : public Pane
diff --git a/libs/gtkmm2ext/pane.cc b/libs/gtkmm2ext/pane.cc
index 2cd05c1681..edc066fa06 100644
--- a/libs/gtkmm2ext/pane.cc
+++ b/libs/gtkmm2ext/pane.cc
@@ -31,6 +31,7 @@ Pane::Pane (bool h)
: horizontal (h)
, did_move (false)
, divider_width (2)
+ , check_fract (false)
{
using namespace Gdk;
@@ -342,6 +343,58 @@ Pane::handle_release_event (GdkEventButton* ev, Divider* d)
return false;
}
+void
+Pane::set_check_divider_position (bool yn)
+{
+ check_fract = yn;
+}
+
+bool
+Pane::fract_is_ok (Dividers::size_type div, float fract)
+{
+#ifdef __APPLE__
+ if (!check_fract) {
+ return true;
+ }
+
+ /* On Quartz, if the pane handle (divider) gets to
+ be adjacent to the window edge, you can no longer grab it:
+ any attempt to do so is interpreted by the Quartz window
+ manager ("Finder") as a resize drag on the window edge.
+ */
+
+ if (horizontal) {
+ if (div == dividers.size() - 1) {
+ if (get_allocation().get_width() * (1.0 - fract) < (divider_width*2)) {
+ /* too close to right edge */
+ return false;
+ }
+ }
+
+ if (div == 0) {
+ if (get_allocation().get_width() * fract < (divider_width*2)) {
+ /* too close to left edge */
+ return false;
+ }
+ }
+ } else {
+ if (div == dividers.size() - 1) {
+ if (get_allocation().get_height() * (1.0 - fract) < (divider_width*2)) {
+ /* too close to bottom */
+ return false;
+ }
+ }
+
+ if (div == 0) {
+ if (get_allocation().get_width() * fract < (divider_width*2)) {
+ /* too close to top */
+ return false;
+ }
+ }
+ }
+#endif
+ return true;
+}
bool
Pane::handle_motion_event (GdkEventMotion* ev, Divider* d)
@@ -360,8 +413,9 @@ Pane::handle_motion_event (GdkEventMotion* ev, Divider* d)
d->translate_coordinates (*this, ev->x, ev->y, px, py);
Dividers::iterator prev = dividers.end();
+ Dividers::size_type div = 0;
- for (Dividers::iterator di = dividers.begin(); di != dividers.end(); ++di) {
+ for (Dividers::iterator di = dividers.begin(); di != dividers.end(); ++di, ++div) {
if (*di == d) {
break;
}
@@ -391,6 +445,10 @@ Pane::handle_motion_event (GdkEventMotion* ev, Divider* d)
new_fract = min (1.0f, max (0.0f, new_fract));
+ if (!fract_is_ok (div, new_fract)) {
+ return true;
+ }
+
if (new_fract != d->fract) {
d->fract = new_fract;
reallocate (get_allocation ());
@@ -417,47 +475,12 @@ Pane::set_divider (Dividers::size_type div, float fract)
}
fract = max (0.0f, min (1.0f, fract));
+ std::cerr << "Div = " << div << " of " << dividers.size() << std::endl;
-#ifdef __APPLE__
-
- /* On Quartz, if the pane handle (divider) gets to
- be adjacent to the window edge, you can no longer grab it:
- any attempt to do so is interpreted by the Quartz window
- manager ("Finder") as a resize drag on the window edge.
- */
-
- if (horizontal) {
- if (div == dividers.size() - 1) {
- if (get_allocation().get_width() * (1.0 - fract) < (divider_width*2)) {
- /* too close to right edge */
- return;
- }
- }
-
- if (div == dividers.size() - 1) {
- if (get_allocation().get_width() * fract < (divider_width*2)) {
- /* too close to left edge */
- return;
- }
- }
- } else {
- if (div == dividers.size() - 1) {
- if (get_allocation().get_height() * (1.0 - fract) < (divider_width*2)) {
- /* too close to bottom */
- return;
- }
- }
-
- if (div == dividers.size() - 1) {
- if (get_allocation().get_width() * fract < (divider_width*2)) {
- /* too close to top */
- return;
- }
- }
+ if (!fract_is_ok (div, fract)) {
+ return;
}
-#endif
-
if (fract != (*d)->fract) {
(*d)->fract = fract;
/* our size hasn't changed, but our internal allocations have */