mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-14 00:39:55 +02:00
Merge branch 'master' into 2016-02-colorpicker
This commit is contained in:
73
imgui.cpp
73
imgui.cpp
@ -441,6 +441,7 @@
|
||||
!- window: begin with *p_opened == false should return false.
|
||||
- window: get size/pos helpers given names (see discussion in #249)
|
||||
- window: a collapsed window can be stuck behind the main menu bar?
|
||||
- window: when window is small, prioritize resize button over close button.
|
||||
- window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later.
|
||||
- window/tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||
- window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
|
||||
@ -450,15 +451,19 @@
|
||||
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc.
|
||||
- widgets: clean up widgets internal toward exposing everything.
|
||||
- widgets: add disabled and read-only modes (#211)
|
||||
- main: considering adding EndFrame()/Init(). some constructs are awkward in the implementation because of the lack of them.
|
||||
- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: considering adding an Init() function? some constructs are awkward in the implementation because of the lack of them.
|
||||
!- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
|
||||
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
||||
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now.
|
||||
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
||||
- input text: flag to disable live update of the user buffer (also applies to float/int text input)
|
||||
- input text: resize behavior - field could stretch when being edited? hover tooltip shows more text?
|
||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
||||
- input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
|
||||
- input text multi-line: way to dynamically grow the buffer without forcing the user to initially allocate for worse case (follow up on #200)
|
||||
- input text multi-line: line numbers? status bar? (follow up on #200)
|
||||
- input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position.
|
||||
- input number: optional range min/max for Input*() functions
|
||||
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
||||
- input number: use mouse wheel to step up/down
|
||||
@ -497,7 +502,7 @@
|
||||
- statusbar: add a per-window status bar helper similar to what menubar does.
|
||||
- tabs (#261, #351)
|
||||
- separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y)
|
||||
- color: the color helpers/typing is a mess and needs sorting out.
|
||||
!- color: the color helpers/typing is a mess and needs sorting out.
|
||||
- color: add a better color picker (#346)
|
||||
- node/graph editor (#306)
|
||||
- pie menus patterns (#434)
|
||||
@ -512,14 +517,11 @@
|
||||
- slider & drag: int data passing through a float
|
||||
- drag float: up/down axis
|
||||
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
||||
- text edit: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now.
|
||||
- text edit: centered text for slider as input text so it matches typical positioning.
|
||||
- text edit: flag to disable live update of the user buffer.
|
||||
- text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
|
||||
- tree node / optimization: avoid formatting when clipped.
|
||||
- tree node: clarify spacing, perhaps provide API to query exact spacing. provide API to draw the primitive. same with Bullet().
|
||||
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
|
||||
- tree node: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
|
||||
- tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits?
|
||||
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
|
||||
- textwrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (git issue #249)
|
||||
- settings: write more decent code to allow saving/loading new fields
|
||||
@ -529,6 +531,7 @@
|
||||
- style: color-box not always square?
|
||||
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
|
||||
- style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
|
||||
- style/opt: PopStyleVar could be optimized by having GetStyleVar returns the type, using a table mapping stylevar enum to data type.
|
||||
- style: global scale setting.
|
||||
- text: simple markup language for color change?
|
||||
- font: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
|
||||
@ -552,7 +555,8 @@
|
||||
- style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? (#438)
|
||||
- style editor: color child window height expressed in multiple of line height.
|
||||
- remote: make a system like RemoteImGui first-class citizen/project (#75)
|
||||
- drawlist: user probably can't call Clear() because we expect a texture to be pushed in the stack.
|
||||
!- demo: custom render demo pushes a clipping rectangle past parent window bounds. expose ImGui::PushClipRect() from imgui_internal.h?
|
||||
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
||||
- examples: directx9/directx11: save/restore device state more thoroughly.
|
||||
- optimization: use another hash function than crc32, e.g. FNV1a
|
||||
- optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
|
||||
@ -789,6 +793,14 @@ ImGuiIO::ImGuiIO()
|
||||
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
||||
SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
|
||||
ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
|
||||
|
||||
// Set OS X style defaults based on __APPLE__ compile time flag
|
||||
#ifdef __APPLE__
|
||||
WordMovementUsesAltKey = true; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
||||
ShortcutsUseSuperKey = true; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
|
||||
DoubleClickSelectsWord = true; // OS X style: Double click selects by word instead of selecting whole text
|
||||
MultiSelectUsesSuperKey = true; // OS X style: Multi-selection in lists uses Cmd/Super instead of Ctrl
|
||||
#endif
|
||||
}
|
||||
|
||||
// Pass in translated ASCII characters for text input.
|
||||
@ -7090,8 +7102,18 @@ static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* ob
|
||||
r->num_chars = (int)(text_remaining - (text + line_start_idx));
|
||||
}
|
||||
|
||||
static bool is_separator(unsigned int c) { return c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; }
|
||||
#define STB_TEXTEDIT_IS_SPACE(CH) ( ImCharIsSpace((unsigned int)CH) || is_separator((unsigned int)CH) )
|
||||
static bool is_separator(unsigned int c) { return ImCharIsSpace(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; }
|
||||
static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator( obj->Text[idx-1] ) && !is_separator( obj->Text[idx] ) ) : 1; }
|
||||
static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator( obj->Text[idx-1] ) && is_separator( obj->Text[idx] ) ) : 1; }
|
||||
static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; }
|
||||
#ifdef __APPLE__ // FIXME: Move setting to IO structure
|
||||
static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; }
|
||||
#else
|
||||
static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; }
|
||||
#endif
|
||||
#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
|
||||
#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
|
||||
|
||||
static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n)
|
||||
{
|
||||
ImWchar* dst = obj->Text.Data + pos;
|
||||
@ -7321,6 +7343,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
const bool is_ctrl_down = io.KeyCtrl;
|
||||
const bool is_shift_down = io.KeyShift;
|
||||
const bool is_alt_down = io.KeyAlt;
|
||||
const bool is_super_down = io.KeySuper;
|
||||
const bool focus_requested = FocusableItemRegister(window, g.ActiveId == id, (flags & (ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_AllowTabInput)) == 0); // Using completion callback disable keyboard tabbing
|
||||
const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent);
|
||||
const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code;
|
||||
@ -7408,11 +7431,17 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
const float mouse_x = (g.IO.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
||||
const float mouse_y = (is_multiline ? (g.IO.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f));
|
||||
|
||||
if (select_all || (hovered && io.MouseDoubleClicked[0]))
|
||||
if (select_all || (hovered && !io.DoubleClickSelectsWord && io.MouseDoubleClicked[0]))
|
||||
{
|
||||
edit_state.SelectAll();
|
||||
edit_state.SelectedAllMouseLock = true;
|
||||
}
|
||||
else if (hovered && io.DoubleClickSelectsWord && io.MouseDoubleClicked[0])
|
||||
{
|
||||
// Select a word only, OS X style (by simulating keystrokes)
|
||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT);
|
||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
|
||||
}
|
||||
else if (io.MouseClicked[0] && !edit_state.SelectedAllMouseLock)
|
||||
{
|
||||
stb_textedit_click(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
|
||||
@ -7450,9 +7479,11 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
// Handle various key-presses
|
||||
bool cancel_edit = false;
|
||||
const int k_mask = (is_shift_down ? STB_TEXTEDIT_K_SHIFT : 0);
|
||||
const bool is_ctrl_only = is_ctrl_down && !is_alt_down && !is_shift_down;
|
||||
if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_WORDLEFT | k_mask : STB_TEXTEDIT_K_LEFT | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_WORDRIGHT | k_mask : STB_TEXTEDIT_K_RIGHT | k_mask); }
|
||||
const bool is_shortcutkey_only = (io.ShortcutsUseSuperKey ? (is_super_down && !is_alt_down && !is_shift_down && !is_ctrl_down) : (is_ctrl_down && !is_alt_down && !is_shift_down && !is_super_down));
|
||||
const bool is_wordmove_key_down = (io.WordMovementUsesAltKey ? io.KeyAlt : io.KeyCtrl);
|
||||
|
||||
if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed(is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT | k_mask : STB_TEXTEDIT_K_LEFT | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed(is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT | k_mask : STB_TEXTEDIT_K_RIGHT | k_mask); }
|
||||
else if (is_multiline && IsKeyPressedMap(ImGuiKey_UpArrow)) { if (is_ctrl_down) SetWindowScrollY(draw_window, draw_window->Scroll.y - g.FontSize); else edit_state.OnKeyPressed(STB_TEXTEDIT_K_UP | k_mask); }
|
||||
else if (is_multiline && IsKeyPressedMap(ImGuiKey_DownArrow)) { if (is_ctrl_down) SetWindowScrollY(draw_window, draw_window->Scroll.y + g.FontSize); else edit_state.OnKeyPressed(STB_TEXTEDIT_K_DOWN| k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Home)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
|
||||
@ -7480,11 +7511,11 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
if (InputTextFilterCharacter(&c, flags, callback, user_data))
|
||||
edit_state.OnKeyPressed((int)c);
|
||||
}
|
||||
else if (IsKeyPressedMap(ImGuiKey_Escape)) { SetActiveID(0); cancel_edit = true; }
|
||||
else if (is_ctrl_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); }
|
||||
else if (is_ctrl_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); }
|
||||
else if (is_ctrl_only && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); edit_state.CursorFollow = true; }
|
||||
else if (is_ctrl_only && !is_password && ((IsKeyPressedMap(ImGuiKey_X) && is_editable) || IsKeyPressedMap(ImGuiKey_C)) && (!is_multiline || edit_state.HasSelection()))
|
||||
else if (IsKeyPressedMap(ImGuiKey_Escape)) { SetActiveID(0); cancel_edit = true; }
|
||||
else if (is_shortcutkey_only && IsKeyPressedMap(ImGuiKey_Z) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); edit_state.ClearSelection(); }
|
||||
else if (is_shortcutkey_only && IsKeyPressedMap(ImGuiKey_Y) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); edit_state.ClearSelection(); }
|
||||
else if (is_shortcutkey_only && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); edit_state.CursorFollow = true; }
|
||||
else if (is_shortcutkey_only && !is_password && ((IsKeyPressedMap(ImGuiKey_X) && is_editable) || IsKeyPressedMap(ImGuiKey_C)) && (!is_multiline || edit_state.HasSelection()))
|
||||
{
|
||||
// Cut, Copy
|
||||
const bool cut = IsKeyPressedMap(ImGuiKey_X);
|
||||
@ -7506,7 +7537,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
stb_textedit_cut(&edit_state, &edit_state.StbState);
|
||||
}
|
||||
}
|
||||
else if (is_ctrl_only && IsKeyPressedMap(ImGuiKey_V) && is_editable)
|
||||
else if (is_shortcutkey_only && IsKeyPressedMap(ImGuiKey_V) && is_editable)
|
||||
{
|
||||
// Paste
|
||||
if (g.IO.GetClipboardTextFn)
|
||||
|
Reference in New Issue
Block a user