MeshLib Documentation
Loading...
Searching...
No Matches
MRRibbonMenuSearch.h
Go to the documentation of this file.
1#pragma once
2#include "MRViewerFwd.h"
3#include "MRMesh/MRVector2.h"
4#include "MRRibbonSchema.h"
5#include "MRMesh/MRSignal.h"
6#include <string>
7#include <functional>
8
9namespace MR
10{
11
12class RibbonButtonDrawer;
13class RibbonFontManager;
14
15// separate class for search in ribbon menu
16class MRVIEWER_CLASS RibbonMenuSearch
17{
18public:
19 // returns search imgui popup window name
20 const char* windowName() const { return "##RibbonGlobalSearchPopup[rect_allocator_ignore]"; }
21 // add item to recent items list
22 void pushRecentItem( const std::shared_ptr<RibbonMenuItem>& item );
23
31 // draws search elements and window with its logic
32 MRVIEWER_API void drawMenuUI( const Parameters& params );
33
34 // set draw mode (true - small button, false - input string )
35 void setSmallUI( bool on ) { isSmallUI_ = on; }
36
37 // get width ui element in top panel
38 // return unscaled value
39 MRVIEWER_API float getWidthMenuUI() const;
40
41 // get search string width (+ item spacing)
42 MRVIEWER_API float getSearchStringWidth() const;
43
44 // activate search from outside (i.e. shortcut)
45 MRVIEWER_API void activate();
46
47 // this signal is emitted when search bar is focused
49 // this signal is emitted when tool is activated within search
50 Signal<void( std::shared_ptr<RibbonMenuItem> )> onToolActivateSignal;
51private:
52 bool smallSearchButton_( const Parameters& params );
53
54 void drawWindow_( const Parameters& params );
55
56 void deactivateSearch_();
57
58 bool searchInputText_( const char* label, std::string& str, const RibbonMenuSearch::Parameters& params );
59
60 void updateSearchResult_();
61
62 std::string searchLine_;
63 std::vector<RibbonSchemaHolder::SearchResult> searchResult_;
64 std::vector<RibbonSchemaHolder::SearchResultWeight> searchResultWeight_;
65 std::vector<RibbonSchemaHolder::SearchResult> recentItems_;
66 int hightlightedSearchItem_{ 0 };
67 int captionCount_ = 0;
68
69
70 bool isSmallUI_ = false;
71 bool active_ = false;
72 bool prevFrameActive_ = false;
73 bool isSmallUILast_ = false;
74 bool mainInputFocused_ = false;
75 bool blockSearchBtn_ = false;
76 bool setInputFocus_ = false;
77#ifndef NDEBUG
78 bool showResultWeight_ = false;
79#endif
80};
81
82}
class for drawing ribbon menu buttons
Definition MRRibbonButtonDrawer.h:48
Definition MRRibbonFontManager.h:11
Definition MRRibbonMenuSearch.h:17
const char * windowName() const
Definition MRRibbonMenuSearch.h:20
Signal< void(std::shared_ptr< RibbonMenuItem >)> onToolActivateSignal
Definition MRRibbonMenuSearch.h:50
MRVIEWER_API void activate()
MRVIEWER_API float getWidthMenuUI() const
void setSmallUI(bool on)
Definition MRRibbonMenuSearch.h:35
void pushRecentItem(const std::shared_ptr< RibbonMenuItem > &item)
Signal< void()> onFocusSignal
Definition MRRibbonMenuSearch.h:48
MRVIEWER_API void drawMenuUI(const Parameters &params)
MRVIEWER_API float getSearchStringWidth() const
Definition MRCameraOrientationPlugin.h:8
Definition MRRibbonMenuSearch.h:25
RibbonFontManager & fontManager
Definition MRRibbonMenuSearch.h:27
float scaling
Definition MRRibbonMenuSearch.h:29
std::function< void(int)> changeTabFunc
Definition MRRibbonMenuSearch.h:28
RibbonButtonDrawer & btnDrawer
Definition MRRibbonMenuSearch.h:26
Definition MRSignal.h:24