summaryrefslogtreecommitdiff
path: root/starmath/inc
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-06-01 11:20:12 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-06-02 12:51:41 +0200
commitd79c527c2a599c7821d27cf03b95cb79e2abe685 (patch)
treef48c85d924086b7112b43137712de5e438556c38 /starmath/inc
parentf6fbdb87a15f7de97e18676560eeba988fac1b67 (diff)
Use IconView in SmElementsControl
Allows to send individual images over the wire in lok case, instead of sending full canvas at every scroll operation. The control's horizontal and vertical modes (when it's docked to a vertical or a horizontal parent window side) are now identical. Some TODOs: * Re-implement a11y - that needs to be implemented on IconView level; * Make sure that sub-pixel positioning is not used when creating the elements icons (makes elements look a bit slim on Windows); * Maybe restore mouse hover indication; in non-GTK case, a call to m_xIconView->SetHoverSelection would suffice in SalInstanceIconView. Change-Id: Idbc35f4e38e2b49fd0848a96da557fa2c1a1f6e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134761 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'starmath/inc')
-rw-r--r--starmath/inc/AccessibleSmElement.hxx101
-rw-r--r--starmath/inc/AccessibleSmElementsControl.hxx106
-rw-r--r--starmath/inc/ElementsDockingWindow.hxx106
3 files changed, 21 insertions, 292 deletions
diff --git a/starmath/inc/AccessibleSmElement.hxx b/starmath/inc/AccessibleSmElement.hxx
deleted file mode 100644
index c1e7e6526872..000000000000
--- a/starmath/inc/AccessibleSmElement.hxx
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include <com/sun/star/accessibility/XAccessible.hpp>
-#include <com/sun/star/accessibility/XAccessibleAction.hpp>
-#include <com/sun/star/accessibility/XAccessibleContext.hpp>
-#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
-#include <com/sun/star/awt/Rectangle.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/implbase3.hxx>
-#include <comphelper/accessiblecomponenthelper.hxx>
-#include <sal/types.h>
-
-class SmElementsControl;
-
-typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::accessibility::XAccessible,
- css::accessibility::XAccessibleAction>
- AccessibleSmElement_BASE;
-
-class AccessibleSmElement final : public comphelper::OAccessibleComponentHelper,
- public AccessibleSmElement_BASE
-{
- SmElementsControl* m_pSmElementsControl;
- const sal_Int32 m_nIndexInParent; ///< index in the parent XAccessible
- const sal_uInt16 m_nItemId; ///< index in the SmElementsControl
- bool m_bHasFocus;
- sal_Int16 m_nRole;
-
- ~AccessibleSmElement() override;
- void SAL_CALL disposing() override;
- css::awt::Rectangle implGetBounds() override;
-
- void testAction(sal_Int32) const;
-
-public:
- explicit AccessibleSmElement(SmElementsControl* pSmElementsControl, sal_uInt16 nItemId,
- sal_Int32 nIndexInParent);
-
- void SetFocus(bool _bFocus);
- sal_uInt16 itemId() const { return m_nItemId; }
-
- DECLARE_XINTERFACE()
- DECLARE_XTYPEPROVIDER()
-
- // XAccessible
- css::uno::Reference<css::accessibility::XAccessibleContext>
- SAL_CALL getAccessibleContext() override;
-
- // XServiceInfo
- OUString SAL_CALL getImplementationName() override;
- sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
- css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
-
- // XAccessibleContext
- sal_Int32 SAL_CALL getAccessibleChildCount() override;
- css::uno::Reference<css::accessibility::XAccessible>
- SAL_CALL getAccessibleChild(sal_Int32 i) override;
- css::uno::Reference<css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override;
- sal_Int32 SAL_CALL getAccessibleIndexInParent() override;
- sal_Int16 SAL_CALL getAccessibleRole() override;
- OUString SAL_CALL getAccessibleDescription() override;
- OUString SAL_CALL getAccessibleName() override;
- css::uno::Reference<css::accessibility::XAccessibleRelationSet>
- SAL_CALL getAccessibleRelationSet() override;
- css::uno::Reference<css::accessibility::XAccessibleStateSet>
- SAL_CALL getAccessibleStateSet() override;
-
- // XAccessibleComponent
- css::uno::Reference<css::accessibility::XAccessible>
- SAL_CALL getAccessibleAtPoint(const css::awt::Point& aPoint) override;
- void SAL_CALL grabFocus() override;
- sal_Int32 SAL_CALL getForeground() override;
- sal_Int32 SAL_CALL getBackground() override;
-
- // XAccessibleAction
- sal_Int32 SAL_CALL getAccessibleActionCount() override;
- sal_Bool SAL_CALL doAccessibleAction(sal_Int32 nIndex) override;
- OUString SAL_CALL getAccessibleActionDescription(sal_Int32 nIndex) override;
- css::uno::Reference<css::accessibility::XAccessibleKeyBinding>
- SAL_CALL getAccessibleActionKeyBinding(sal_Int32 nIndex) override;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/AccessibleSmElementsControl.hxx b/starmath/inc/AccessibleSmElementsControl.hxx
deleted file mode 100644
index bdb5e25ea724..000000000000
--- a/starmath/inc/AccessibleSmElementsControl.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include <comphelper/accessiblecomponenthelper.hxx>
-#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/implbase3.hxx>
-#include <rtl/ref.hxx>
-
-#include <vector>
-
-class AccessibleSmElement;
-class SmElementsControl;
-
-typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::accessibility::XAccessible,
- css::accessibility::XAccessibleSelection>
- AccessibleSmElementsControl_BASE;
-
-class AccessibleSmElementsControl final : public comphelper::OAccessibleComponentHelper,
- public AccessibleSmElementsControl_BASE
-{
- std::vector<rtl::Reference<AccessibleSmElement>> m_aAccessibleChildren;
- SmElementsControl* m_pControl;
-
- void UpdateFocus(sal_uInt16);
- inline void TestControl();
-
- ~AccessibleSmElementsControl() override;
- void SAL_CALL disposing() override;
- css::awt::Rectangle implGetBounds() override;
-
-public:
- AccessibleSmElementsControl(SmElementsControl& rControl);
-
- void ReleaseAllItems();
- void AddAllItems();
- inline void AcquireFocus();
- inline void ReleaseFocus(sal_uInt16);
-
- DECLARE_XINTERFACE()
- DECLARE_XTYPEPROVIDER()
-
- // XAccessible
- css::uno::Reference<css::accessibility::XAccessibleContext>
- SAL_CALL getAccessibleContext() override;
-
- // XServiceInfo
- OUString SAL_CALL getImplementationName() override;
- sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
- css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
-
- // XAccessibleComponent
- sal_Bool SAL_CALL containsPoint(const css::awt::Point& aPoint) override;
- css::uno::Reference<css::accessibility::XAccessible>
- SAL_CALL getAccessibleAtPoint(const css::awt::Point& aPoint) override;
- void SAL_CALL grabFocus() override;
- sal_Int32 SAL_CALL getForeground() override;
- sal_Int32 SAL_CALL getBackground() override;
-
- // XAccessibleContext
- sal_Int32 SAL_CALL getAccessibleChildCount() override;
- css::uno::Reference<css::accessibility::XAccessible>
- SAL_CALL getAccessibleChild(sal_Int32 i) override;
- css::uno::Reference<css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override;
- sal_Int16 SAL_CALL getAccessibleRole() override;
- OUString SAL_CALL getAccessibleDescription() override;
- OUString SAL_CALL getAccessibleName() override;
- css::uno::Reference<css::accessibility::XAccessibleRelationSet>
- SAL_CALL getAccessibleRelationSet() override;
- css::uno::Reference<css::accessibility::XAccessibleStateSet>
- SAL_CALL getAccessibleStateSet() override;
-
- // XAccessibleSelection
- void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override;
- sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override;
- void SAL_CALL clearAccessibleSelection() override;
- void SAL_CALL selectAllAccessibleChildren() override;
- sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override;
- css::uno::Reference<css::accessibility::XAccessible>
- SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override;
- void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override;
-};
-
-void AccessibleSmElementsControl::AcquireFocus() { UpdateFocus(SAL_MAX_UINT16); }
-
-void AccessibleSmElementsControl::ReleaseFocus(sal_uInt16 nPos) { UpdateFocus(nPos); }
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index 28a564f7a1e7..859b7b73a826 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -26,90 +26,44 @@
#include "node.hxx"
#include "parsebase.hxx"
-#include "AccessibleSmElementsControl.hxx"
-class SmDocShell;
-
-class SmElement
-{
- std::unique_ptr<SmNode> mpNode;
- OUString maText;
- OUString maHelpText;
-
-public:
- Point mBoxLocation;
- Size mBoxSize;
-
- SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText);
- virtual ~SmElement();
-
- const std::unique_ptr<SmNode>& getNode() const;
- const OUString& getText() const { return maText; }
- const OUString& getHelpText() const { return maHelpText; }
+#include <memory>
+#include <vector>
- virtual bool isSeparator() const { return false; }
-};
-
-class SmElementSeparator final : public SmElement
-{
-public:
- SmElementSeparator();
-
- bool isSeparator() const override { return true; }
-};
+class SmDocShell;
+class SvTreeListBox;
+struct ElementData;
-class SmElementsControl : public weld::CustomWidgetController
+class SmElementsControl
{
- friend class ElementSelectorUIObject;
- friend class ElementUIObject;
-
std::unique_ptr<AbstractSmParser> maParser;
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
- virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
- virtual bool MouseMove(const MouseEvent& rMEvt) override;
- virtual OUString RequestHelp(tools::Rectangle& rRect) override;
- virtual void Resize() override;
- virtual void GetFocus() override;
- virtual void LoseFocus() override;
- virtual bool KeyInput(const KeyEvent& rKEvt) override;
- css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
-
SmDocShell* mpDocShell;
SmFormat maFormat;
TranslateId msCurrentSetId;
- sal_uInt16 m_nCurrentElement;
- sal_uInt16 m_nCurrentRolloverElement;
- sal_uInt16 m_nCurrentOffset;
sal_uInt16 m_nSmSyntaxVersion;
- Link<SmElement&,void> maSelectHdlLink;
- std::vector< std::unique_ptr<SmElement> > maElementList;
- Size maMaxElementDimensions;
bool mbVerticalMode;
- std::unique_ptr<weld::ScrolledWindow> mxScroll;
- bool m_bFirstPaintAfterLayout;
- rtl::Reference<AccessibleSmElementsControl> m_xAccessible;
+ std::vector<std::unique_ptr<ElementData>> maItemDatas;
+ std::unique_ptr<weld::IconView> mpIconView;
- void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
- SmElement* current() const;
- void setCurrentElement(sal_uInt16);
- bool hasRollover() const { return m_nCurrentRolloverElement != SAL_MAX_UINT16; }
+ Link<OUString, void> maSelectHdlLink;
- void stepFocus(const bool bBackward);
- void pageFocus(const bool bBackward);
- // common code of page and step focus
- inline void scrollToElement(const bool, const SmElement*);
- inline sal_uInt16 nextElement(const bool, const sal_uInt16, const sal_uInt16);
+ void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
+ void addElements(const TranslateId& rCategory);
void build();
- //if bDraw is true, then draw, otherwise just layout
- void LayoutOrPaintContents(vcl::RenderContext& rContext, bool bDraw);
+ DECL_LINK(QueryTooltipHandler, const weld::TreeIter&, OUString);
+ DECL_LINK(ElementActivatedHandler, weld::IconView&, bool);
+
+ static OUString GetElementSource(const OUString& itemId);
+ static OUString GetElementHelpText(const OUString& itemId);
public:
- explicit SmElementsControl(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow);
- virtual ~SmElementsControl() override;
+
+ explicit SmElementsControl(std::unique_ptr<weld::IconView> pIconView);
+ ~SmElementsControl();
static const std::vector<TranslateId>& categories();
const TranslateId& elementSetId() const { return msCurrentSetId; }
@@ -117,41 +71,23 @@ public:
void setVerticalMode(bool bVertical);
- sal_uInt16 itemCount() const;
- sal_uInt16 itemHighlighted() const;
- sal_uInt16 itemAtPos(const Point& rPos) const;
- tools::Rectangle itemPosRect(sal_uInt16) const;
- bool itemIsSeparator(sal_uInt16) const;
- bool itemIsVisible(sal_uInt16) const;
- OUString itemName(sal_uInt16) const;
- bool itemTrigger(sal_uInt16);
- void setItemHighlighted(sal_uInt16);
void setSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion);
- sal_uInt16 itemOffset() const { return m_nCurrentOffset; }
- virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ void SetSelectHdl(const Link<OUString, void>& rLink) { maSelectHdlLink = rLink; }
- DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
-
- void SetSelectHdl(const Link<SmElement&,void>& rLink) { maSelectHdlLink = rLink; }
-
- const rtl::Reference<AccessibleSmElementsControl> & GetAccessible() const { return m_xAccessible; }
static Color GetTextColor();
static Color GetControlBackground();
-
- virtual FactoryFunction GetUITestFactory() const override;
};
class SmElementsDockingWindow final : public SfxDockingWindow
{
std::unique_ptr<SmElementsControl> mxElementsControl;
- std::unique_ptr<weld::CustomWeld> mxElementsControlWin;
std::unique_ptr<weld::ComboBox> mxElementListBox;
virtual void Resize() override;
SmViewShell* GetView();
- DECL_LINK(SelectClickHandler, SmElement&, void);
+ DECL_LINK(SelectClickHandler, OUString, void);
DECL_LINK(ElementSelectedHandle, weld::ComboBox&, void);
public: