working version of pane position mgmt for OS X
This commit is contained in:
parent
ceb0bce971
commit
9142d1edf5
@ -64,6 +64,8 @@ class LIBGTKMM2EXT_API Pane : public Gtk::Container
|
|||||||
GType child_type_vfunc() const;
|
GType child_type_vfunc() const;
|
||||||
void set_drag_cursor (Gdk::Cursor);
|
void set_drag_cursor (Gdk::Cursor);
|
||||||
|
|
||||||
|
void set_check_divider_position (bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool horizontal;
|
bool horizontal;
|
||||||
|
|
||||||
@ -101,8 +103,11 @@ class LIBGTKMM2EXT_API Pane : public Gtk::Container
|
|||||||
typedef std::list<Divider*> Dividers;
|
typedef std::list<Divider*> Dividers;
|
||||||
Dividers dividers;
|
Dividers dividers;
|
||||||
int divider_width;
|
int divider_width;
|
||||||
|
bool check_fract;
|
||||||
|
|
||||||
void add_divider ();
|
void add_divider ();
|
||||||
void handle_child_visibility ();
|
void handle_child_visibility ();
|
||||||
|
bool fract_is_ok (Dividers::size_type, float fract);
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIBGTKMM2EXT_API HPane : public Pane
|
class LIBGTKMM2EXT_API HPane : public Pane
|
||||||
|
@ -31,6 +31,7 @@ Pane::Pane (bool h)
|
|||||||
: horizontal (h)
|
: horizontal (h)
|
||||||
, did_move (false)
|
, did_move (false)
|
||||||
, divider_width (2)
|
, divider_width (2)
|
||||||
|
, check_fract (false)
|
||||||
{
|
{
|
||||||
using namespace Gdk;
|
using namespace Gdk;
|
||||||
|
|
||||||
@ -342,6 +343,58 @@ Pane::handle_release_event (GdkEventButton* ev, Divider* d)
|
|||||||
|
|
||||||
return false;
|
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
|
bool
|
||||||
Pane::handle_motion_event (GdkEventMotion* ev, Divider* d)
|
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);
|
d->translate_coordinates (*this, ev->x, ev->y, px, py);
|
||||||
|
|
||||||
Dividers::iterator prev = dividers.end();
|
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) {
|
if (*di == d) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -391,6 +445,10 @@ Pane::handle_motion_event (GdkEventMotion* ev, Divider* d)
|
|||||||
|
|
||||||
new_fract = min (1.0f, max (0.0f, new_fract));
|
new_fract = min (1.0f, max (0.0f, new_fract));
|
||||||
|
|
||||||
|
if (!fract_is_ok (div, new_fract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (new_fract != d->fract) {
|
if (new_fract != d->fract) {
|
||||||
d->fract = new_fract;
|
d->fract = new_fract;
|
||||||
reallocate (get_allocation ());
|
reallocate (get_allocation ());
|
||||||
@ -417,47 +475,12 @@ Pane::set_divider (Dividers::size_type div, float fract)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fract = max (0.0f, min (1.0f, fract));
|
fract = max (0.0f, min (1.0f, fract));
|
||||||
|
std::cerr << "Div = " << div << " of " << dividers.size() << std::endl;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
if (!fract_is_ok (div, fract)) {
|
||||||
|
return;
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fract != (*d)->fract) {
|
if (fract != (*d)->fract) {
|
||||||
(*d)->fract = fract;
|
(*d)->fract = fract;
|
||||||
/* our size hasn't changed, but our internal allocations have */
|
/* our size hasn't changed, but our internal allocations have */
|
||||||
|
Loading…
Reference in New Issue
Block a user