AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
ARulerView.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12//
13// Created by alex2 on 6/25/2021.
14//
15
16
17#pragma once
18
19#include <AUI/View/AView.h>
20#include <AUI/Util/ALayoutDirection.h>
21#include <AUI/GL/Vao.h>
22#include "AUI/Font/IFontView.h"
23
28class API_AUI_VIEWS ARulerView: public AView, public IFontView {
29private:
30 ALayoutDirection mLayoutDirection;
31 _<gl::Vao> mPrecompiledLines;
32
33 int mOffsetPx = 0;
34
35 float mUnit = 1.f;
36
37 int getLongestSide() const;
38 int getShortestSide() const;
39
40public:
41 explicit ARulerView(ALayoutDirection layoutDirection);
42
43 void invalidateFont() override;
44
45 void render(ARenderContext ctx) override;
46
47 void setOffsetPx(int offsetPx) {
48 mOffsetPx = offsetPx;
49 redraw();
50 }
51
52};
53
54
A Photoshop-like ruler for measuring display units.
Definition: ARulerView.h:28
Base class of all UI objects.
Definition: AView.h:77
void redraw()
Request window manager to redraw this AView.
Definition: AView.cpp:68
virtual void render(ARenderContext ctx)
Draws this AView. Noone should call this function except rendering routine.
Definition: AView.cpp:142
Interface of a AView that works with fonts (i.e., ALabel, ATextField, AText, etc.....
Definition: IFontView.h:19
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Render context passed to AView::render.
Definition: ARenderContext.h:43