Skip to content

Commit

Permalink
Add MU_OPT_NODRAG
Browse files Browse the repository at this point in the history
Derived from GitHub PR rxi/microui#50
  • Loading branch information
ashn-dot-dev committed Dec 30, 2023
1 parent 158d839 commit a1a124f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ test_window(mu_Context* ctx)
static void
log_window(mu_Context* ctx)
{
if (mu_begin_window(ctx, "Log Window", mu_rect(350, 40, 300, 200))) {
if (mu_begin_window_ex(ctx, "Log Window", mu_rect(350, 40, 300, 200), MU_OPT_NODRAG)) {
/* output text panel */
mu_layout_row(ctx, 1, (int[]) { -1 }, -25);
mu_begin_panel(ctx, "Log Output");
Expand Down
2 changes: 1 addition & 1 deletion demo.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func test_window(ui: *smol::ui) void {
var textbox_buffer = (:[128]char)[0...];
func log_window(ui: *smol::ui) void
{
if ui.*.begin_window("Log Window", smol::rect::init(350, 40, 300, 200)) {
if ui.*.begin_window_ex("Log Window", smol::rect::init(350, 40, 300, 200), smol::OPT_NODRAG) {
# output text panel
ui.*.layout_row((:[]sint)[-1], -25);
ui.*.begin_panel("Log Output");
Expand Down
2 changes: 1 addition & 1 deletion microui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ mu_begin_window_ex(mu_Context* ctx, char const* title, mu_Rect rect, int opt)
mu_Id id = mu_get_id(ctx, "!title", 6);
mu_update_control(ctx, id, tr, opt);
mu_draw_control_text(ctx, title, tr, MU_COLOR_TITLETEXT, opt);
if (id == ctx->focus && ctx->mouse_down == MU_MOUSE_LEFT) {
if (id == ctx->focus && ctx->mouse_down == MU_MOUSE_LEFT && ~opt & MU_OPT_NODRAG) {
cnt->rect.x += ctx->mouse_delta.x;
cnt->rect.y += ctx->mouse_delta.y;
}
Expand Down
11 changes: 6 additions & 5 deletions microui.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ enum {
MU_OPT_NOSCROLL = (1 << 5),
MU_OPT_NOCLOSE = (1 << 6),
MU_OPT_NOTITLE = (1 << 7),
MU_OPT_HOLDFOCUS = (1 << 8),
MU_OPT_AUTOSIZE = (1 << 9),
MU_OPT_POPUP = (1 << 10),
MU_OPT_CLOSED = (1 << 11),
MU_OPT_EXPANDED = (1 << 12)
MU_OPT_NODRAG = (1 << 8),
MU_OPT_HOLDFOCUS = (1 << 9),
MU_OPT_AUTOSIZE = (1 << 10),
MU_OPT_POPUP = (1 << 11),
MU_OPT_CLOSED = (1 << 12),
MU_OPT_EXPANDED = (1 << 13)
};

enum {
Expand Down
11 changes: 6 additions & 5 deletions microui.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ let MU_OPT_NORESIZE = (:sint)(1u << 4);
let MU_OPT_NOSCROLL = (:sint)(1u << 5);
let MU_OPT_NOCLOSE = (:sint)(1u << 6);
let MU_OPT_NOTITLE = (:sint)(1u << 7);
let MU_OPT_HOLDFOCUS = (:sint)(1u << 8);
let MU_OPT_AUTOSIZE = (:sint)(1u << 9);
let MU_OPT_POPUP = (:sint)(1u << 10);
let MU_OPT_CLOSED = (:sint)(1u << 11);
let MU_OPT_EXPANDED = (:sint)(1u << 12);
let MU_OPT_NODRAG = (:sint)(1u << 8);
let MU_OPT_HOLDFOCUS = (:sint)(1u << 9);
let MU_OPT_AUTOSIZE = (:sint)(1u << 10);
let MU_OPT_POPUP = (:sint)(1u << 11);
let MU_OPT_CLOSED = (:sint)(1u << 12);
let MU_OPT_EXPANDED = (:sint)(1u << 13);

let MU_MOUSE_LEFT = (:sint)(1u << 0);
let MU_MOUSE_RIGHT = (:sint)(1u << 1);
Expand Down
1 change: 1 addition & 0 deletions smolui.sunder
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let OPT_NORESIZE = MU_OPT_NORESIZE;
let OPT_NOSCROLL = MU_OPT_NOSCROLL;
let OPT_NOCLOSE = MU_OPT_NOCLOSE;
let OPT_NOTITLE = MU_OPT_NOTITLE;
let OPT_NODRAG = MU_OPT_NODRAG;
let OPT_HOLDFOCUS = MU_OPT_HOLDFOCUS;
let OPT_AUTOSIZE = MU_OPT_AUTOSIZE;
let OPT_POPUP = MU_OPT_POPUP;
Expand Down

0 comments on commit a1a124f

Please sign in to comment.