diff --git a/gui.c b/gui.c index 74aa949..615e2f7 100644 --- a/gui.c +++ b/gui.c @@ -2313,12 +2313,13 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel, switch (slot) { case GUI_SLOT_TOP: + s = &layout->slots[GUI_SLOT_TOP]; scaler.x = bounds.x; scaler.y = (bounds.y + bounds.h) - config->scaler_width; scaler.w = bounds.w; scaler.h = config->scaler_width; - if (in && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && + if (in && s->state != GUI_LOCKED && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && GUI_INBOX(mpos.x, mpos.y, scaler.x, scaler.y, scaler.w, scaler.h)) { gui_float py, dy = in->mouse_delta.y; @@ -2339,12 +2340,13 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel, bounds.h -= config->scaler_width; break; case GUI_SLOT_BOTTOM: + s = &layout->slots[GUI_SLOT_BOTTOM]; scaler.x = bounds.x; scaler.y = bounds.y; scaler.w = bounds.w; scaler.h = config->scaler_width; - if (in && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && + if (in && s->state != GUI_LOCKED && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && GUI_INBOX(mpos.x, mpos.y, scaler.x, scaler.y, scaler.w, scaler.h)) { gui_float py, dy = in->mouse_delta.y; @@ -2364,12 +2366,13 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel, bounds.h -= config->scaler_width; break; case GUI_SLOT_LEFT: + s = &layout->slots[GUI_SLOT_LEFT]; scaler.x = bounds.x + bounds.w - config->scaler_width; scaler.y = bounds.y; scaler.w = config->scaler_width; scaler.h = bounds.h; - if (in && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && + if (in && s->state != GUI_LOCKED && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && GUI_INBOX(mpos.x, mpos.y, scaler.x, scaler.y, scaler.w, scaler.h)) { gui_float dx = in->mouse_delta.x; gui_float cx, rx; @@ -2391,12 +2394,13 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel, bounds.w -= config->scaler_width; break; case GUI_SLOT_RIGHT: + s = &layout->slots[GUI_SLOT_LEFT]; scaler.x = bounds.x; scaler.y = bounds.y; scaler.w = config->scaler_width; scaler.h = bounds.h; - if (in && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && + if (in && s->state != GUI_LOCKED && !(layout->flags & GUI_LAYOUT_INACTIVE) && in->mouse_down && GUI_INBOX(mpos.x, mpos.y, scaler.x, scaler.y, scaler.w, scaler.h)) { gui_float dx = in->mouse_delta.x; gui_float cx, lx; @@ -3880,6 +3884,19 @@ gui_layout_slot(struct gui_layout *layout, enum gui_layout_slot_index slot, layout->slots[slot].capacity = count; layout->slots[slot].format = format; layout->slots[slot].value = GUI_SATURATE(ratio); + layout->slots[slot].state = GUI_UNLOCKED; +} + +void +gui_layout_slot_locked(struct gui_layout *layout, enum gui_layout_slot_index slot, + gui_float ratio, enum gui_layout_format format, gui_size count) +{ + GUI_ASSERT(layout); + GUI_ASSERT(count); + GUI_ASSERT(slot >= GUI_SLOT_TOP && slot < GUI_SLOT_MAX); + if (!layout || !count) return; + gui_layout_slot(layout, slot, ratio, format, count); + layout->slots[slot].state = GUI_LOCKED; } void diff --git a/gui.h b/gui.h index d702510..fc48d3b 100644 --- a/gui.h +++ b/gui.h @@ -2281,6 +2281,11 @@ enum gui_layout_format { /* panels in slots are added top to bottom */ }; +enum gui_layout_slot_state { + GUI_UNLOCKED, + GUI_LOCKED +}; + struct gui_layout_slot { gui_size capacity; /* number of panels inside the slot */ @@ -2292,6 +2297,8 @@ struct gui_layout_slot { /* position of the slot in the window */ enum gui_layout_format format; /* panel filling layout */ + enum gui_layout_slot_state state; + /* scaleable state */ }; enum gui_layout_state { @@ -2320,8 +2327,10 @@ struct gui_layout { }; void gui_layout_begin(struct gui_layout*, gui_size width, gui_size height, gui_flags); -void gui_layout_slot(struct gui_layout*, enum gui_layout_slot_index, - gui_float ratio, enum gui_layout_format, gui_size panel_count); +void gui_layout_slot(struct gui_layout*, enum gui_layout_slot_index, gui_float ratio, + enum gui_layout_format, gui_size panel_count); +void gui_layout_slot_locked(struct gui_layout*, enum gui_layout_slot_index, gui_float ratio, + enum gui_layout_format, gui_size panel_count); void gui_layout_end(struct gui_layout*); void gui_layout_update_size(struct gui_layout*, gui_size width, gui_size height); void gui_layout_update_state(struct gui_layout*, gui_uint state);