-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command palette and continued work on menus (#117)
* don't close menus when clicking disabled items * using menu callbacks for other GUI elements * searchbox, simpledialog refactor * Update imagelistpanel.cpp * some refactoring * first stab at command palette * CommandPalette improvements + crash fixes * centering command palette * command palette improvements - fix size flicker upon first drawing command palette - fade all other content on screen when palette is opened * modal dialogs fade the screen * adding search text highlighting to command palette * command palette items are persistent while filtering * command palette supports aliases * command palette clean up * removing shortcuts from help window now that we have the command palette * RGBA statistics, AlignedLabel * Update hdrviewscreen.cpp * allow closing popup menus with Esc key * fixing bug where search filter isn't applied when empty * moving selected/highlighted logic from DropDown to PopupMenu * consolidating highlight logic into MenuItem * menu keyboard navigation done * submenus (w/ keyboard navigation) seem to work now * minor include tweaks * cleanup * adding command palette screenshot, updating readme
- Loading branch information
Showing
51 changed files
with
2,723 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright (C) Wojciech Jarosz <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can | ||
// be found in the LICENSE.txt file. | ||
// | ||
|
||
#include "alignedlabel.h" | ||
#include <nanogui/opengl.h> | ||
|
||
NAMESPACE_BEGIN(nanogui) | ||
|
||
AlignedLabel::AlignedLabel(Widget *parent, const std::string &caption, const std::string &font, int font_size) : | ||
Label(parent, caption, font, font_size), m_alignment(Alignment::Right) | ||
{ | ||
} | ||
|
||
void AlignedLabel::draw(NVGcontext *ctx) | ||
{ | ||
// Label::draw(ctx); | ||
Widget::draw(ctx); | ||
nvgFontFace(ctx, m_font.c_str()); | ||
nvgFontSize(ctx, font_size()); | ||
nvgFillColor(ctx, m_color); | ||
|
||
int draw_pos_x = m_pos.x(); | ||
|
||
auto vert_align = m_fixed_size.x() > 0 ? NVG_ALIGN_TOP : NVG_ALIGN_MIDDLE; | ||
switch (m_alignment) | ||
{ | ||
case Alignment::Left: nvgTextAlign(ctx, NVG_ALIGN_LEFT | vert_align); break; | ||
case Alignment::Right: | ||
nvgTextAlign(ctx, NVG_ALIGN_RIGHT | vert_align); | ||
draw_pos_x += m_size.x(); | ||
break; | ||
case Alignment::Center: | ||
nvgTextAlign(ctx, NVG_ALIGN_CENTER | vert_align); | ||
draw_pos_x += m_size.x() * 0.5f; | ||
break; | ||
} | ||
|
||
if (m_fixed_size.x() > 0) | ||
nvgTextBox(ctx, m_pos.x(), m_pos.y(), m_fixed_size.x(), m_caption.c_str(), nullptr); | ||
else | ||
nvgText(ctx, draw_pos_x, m_pos.y() + m_size.y() * 0.5f, m_caption.c_str(), nullptr); | ||
} | ||
|
||
NAMESPACE_END(nanogui) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright (C) Wojciech Jarosz <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can | ||
// be found in the LICENSE.txt file. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <nanogui/label.h> | ||
|
||
NAMESPACE_BEGIN(nanogui) | ||
|
||
/// Like Label, but allows alignment | ||
class AlignedLabel : public Label | ||
{ | ||
public: | ||
/// How to align the text. | ||
enum class Alignment | ||
{ | ||
Left, | ||
Center, | ||
Right | ||
}; | ||
|
||
AlignedLabel(Widget *parent, const std::string &caption, const std::string &font = "sans", int font_size = -1); | ||
|
||
Alignment alignment() const { return m_alignment; } | ||
void set_alignment(Alignment align) { m_alignment = align; } | ||
|
||
/// Draw the label | ||
virtual void draw(NVGcontext *ctx) override; | ||
|
||
protected: | ||
Alignment m_alignment; | ||
}; | ||
|
||
NAMESPACE_END(nanogui) |
Oops, something went wrong.