Skip to content

Commit

Permalink
Command palette and continued work on menus (#117)
Browse files Browse the repository at this point in the history
* 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
wkjarosz authored Mar 16, 2023
1 parent 00c6c7e commit 4b02bbd
Show file tree
Hide file tree
Showing 51 changed files with 2,723 additions and 751 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ add_executable(
src/filters/shift.cpp
src/filters/unsharp_mask.cpp
src/filters/zap_gremlins.cpp
src/alignedlabel.cpp
src/alignedlabel.h
src/async.h
src/box.h
src/brush.cpp
Expand All @@ -365,6 +367,8 @@ add_executable(
src/colorwheel.cpp
src/colorwheel.h
src/commandhistory.h
src/commandpalette.cpp
src/commandpalette.h
common.cpp
src/common.h
src/dialog.cpp
Expand Down Expand Up @@ -415,10 +419,14 @@ add_executable(
src/rasterdraw.cpp
src/rasterdraw.h
src/timer.h
src/searchbox.cpp
src/searchbox.h
src/tool.cpp
src/tool.h
src/well.cpp
src/well.h
src/widgetutils.cpp
src/widgetutils.h
src/xpuimage.cpp
src/xpuimage.h
${EXTRA_SOURCE})
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ Master branch:
[![Linux build](https://github.com/wkjarosz/hdrview/actions/workflows/ci-linux.yml/badge.svg?branch=master)](https://github.com/wkjarosz/hdrview/actions/workflows/ci-linux.yml)
[![Windows build](https://github.com/wkjarosz/hdrview/actions/workflows/ci-windows.yml/badge.svg?branch=master)](https://github.com/wkjarosz/hdrview/actions/workflows/ci-windows.yml)

Develop branch:
[![macOS build](https://github.com/wkjarosz/hdrview/actions/workflows/ci-mac.yml/badge.svg?branch=develop)](https://github.com/wkjarosz/hdrview/actions/workflows/ci-mac.yml)
[![Linux build](https://github.com/wkjarosz/hdrview/actions/workflows/ci-linux.yml/badge.svg?branch=develop)](https://github.com/wkjarosz/hdrview/actions/workflows/ci-linux.yml)
[![Windows build](https://github.com/wkjarosz/hdrview/actions/workflows/ci-windows.yml/badge.svg?branch=develop)](https://github.com/wkjarosz/hdrview/actions/workflows/ci-windows.yml)

HDRView is a simple research-oriented high-dynamic range image viewer with an emphasis on examining and comparing images, and including minimalistic editing and tonemapping capabilities. HDRView currently supports reading EXR, PNG, TGA, BMP, HDR, JPG, GIF, PNM, PFM, and PSD images and writing EXR, HDR, PNG, TGA, PPM, PFM, and BMP images.

HDRView can display true HDR on Apple extended dynamic range (EDR) and 10-bit displays.

## Example screenshots
HDRView supports loading several images and provides exposure and gamma/sRGB tone mapping control with high-quality dithering of HDR images.
![Screenshot](resources/screenshot1.png "Screenshot1")
When sufficiently zoomed in, HDRView can overlay the pixel grid and numeric color values on each pixel to facilitate inspection.

When sufficiently zoomed in, HDRView can overlay the pixel grid and numeric color values on each pixel to facilitate inspection:
![Screenshot](resources/screenshot2.png "Screenshot2")
Displaying HDR images naively on a 24 bit display leads to visible banding in smooth gradients.
![Screenshot](resources/screenshot3.png "Screenshot3")
HDRView supports high-quality dithering (both when viewing and when saving to an LDR file) to reduce these artifacts.

In addition to the menubar, HDRView features extensive keyboard shortcuts, and pressing `Cmd+Shift+P` brings up a VS Code/Atom/Sublime Text-style command palette allowing you to find any command with keyboard-based fuzzy searching:
![Screenshot](resources/screenshot-command-palette.png "Screenshot of command palette")

HDRView supports the extended dynamic range (XDR, 30 bit) capabilities of recent Macs, allowing it to use finer precision (reducing banding) and brighter whites (reducing clipping) when displaying HDR images.

When displaying images on a standard dynamic range (SDR, 24 bit) display (or saving to an LDR file format), HDRView uses high-quality dithering:
![Screenshot](resources/screenshot4.png "Screenshot4")

This reduces apparent banding artifacts in smooth gradients compared to naively displaying HDR images such displays:
![Screenshot](resources/screenshot3.png "Screenshot3")


## Obtaining HDRView

If you are running a recent version of macOS or Windows, you can download the pre-built binary installer DMG or zip file from the [releases page](https://github.com/wkjarosz/hdrview/releases). For Linux, you will need to build HDRView from source for now.
Expand Down
Binary file added resources/screenshot-command-palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/alignedlabel.cpp
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)
37 changes: 37 additions & 0 deletions src/alignedlabel.h
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)
Loading

0 comments on commit 4b02bbd

Please sign in to comment.